LXC configuration + useful hooks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
lxc-config/hooks/lib/lxc/utils.rb

24 lines
511 B

require "fileutils"
require "pry"
module Lxc
module Utils
def self.safe_write(path, content)
dir = File.dirname(path)
begin
FileUtils.mkdir_p(dir)
rescue Errno::EEXIST #don't care
end
temp_path = path.to_s + ".tmp"
File.open(temp_path, 'w+') do |f|
f.write(content)
end
FileUtils.mv(temp_path, path)
end
def self.sh(cmd, *args)
puts "$ #{cmd} " + args.map {|a| "'#{a}'" }.join(" ")
system(cmd, *args)
end
end
end