From d30ce41a51036fe15078384e1bb0c7267a940432 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Tue, 26 Jun 2012 17:10:52 +0400 Subject: [PATCH] fixed cobbler cookbook bugs and added some features into it (fogot to add late.rb) --- cookbooks/cobbler/libraries/late.rb | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cookbooks/cobbler/libraries/late.rb diff --git a/cookbooks/cobbler/libraries/late.rb b/cookbooks/cobbler/libraries/late.rb new file mode 100644 index 000000000..46d28a424 --- /dev/null +++ b/cookbooks/cobbler/libraries/late.rb @@ -0,0 +1,46 @@ +require "base64" + +class LateFile + def initialize(source_file) + @source_file = source_file + @content = "" + @content64 = base64(@content) + end + + def init + open(@source_file , 'r') do |file| + lines = [] + while line = file.gets + lines << line + end + @content = lines.to_s + @content64 = base64(@content) + end + return self + end + + def content + @content + end + + def content64 + @content64 + end + + def base64(content) + Base64.encode64(content).to_s.strip + end + + def late_file(destfile, mode="644") + "sh -c 'file=$1; shift; echo $0 | base64 --decode > $file && chmod #{mode} $file' #{content64} #{destfile}" + end + + +end + + + + + + +