gluez 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,8 +53,29 @@ module Gluez
53
53
  :code => "apt-get install #{name} --yes"
54
54
  }
55
55
 
56
+ when :crontab
57
+ default_file = "crontab.#{name}.erb"
58
+
59
+ raw = File.read(cfg[:file_dir] + "/files/" + opts[:source, default_file])
60
+
61
+ content = Gluez::Erb::Engine.parse(raw, opts[:vars, {}])
62
+
63
+ setup = <<-CMD
64
+ data=$(cat <<\\DATA
65
+ #{content.strip}
66
+ DATA
67
+ )
68
+ CMD
69
+
70
+ steps << {
71
+ :check => "\"$(echo -n $data | base64 -i -d | md5sum - | awk '{print $1}')\" = \"$(crontab -u #{name} -l | md5sum - | awk '{print $1}')\"",
72
+ :code => "echo -n $data | base64 -i -d | crontab -u #{name} -"
73
+ }
74
+
56
75
  when :transfer
57
- raw = File.read(cfg[:file_dir] + "/files/" + opts[:source])
76
+ default_file = name.split("/").last.gsub(/^\./, "") + ".erb"
77
+
78
+ raw = File.read(cfg[:file_dir] + "/files/" + opts[:source, default_file])
58
79
 
59
80
  content = Gluez::Erb::Engine.parse(raw, opts[:vars, {}])
60
81
 
@@ -131,6 +152,23 @@ CMD
131
152
  :check => opts[:not_if],
132
153
  :code => "su -l #{opts[:user, 'root']} -c '#{opts[:code]}'"
133
154
  }
155
+
156
+ when :umount
157
+ steps << {
158
+ :check => "$(mount | grep \"on #{name} type\" | wc -l) -eq 0",
159
+ :code => "umount #{name}"
160
+ }
161
+
162
+ when :mount
163
+
164
+ cmd = "mount -t #{opts[:type]}"
165
+ cmd = "#{cmd} -o #{opts[:options]}" if opts.key?(:options)
166
+ cmd = "#{cmd} #{opts[:device]} #{name}"
167
+
168
+ steps << {
169
+ :check => "$(mount | grep \"on #{name} type\" | wc -l) -eq 1",
170
+ :code => cmd
171
+ }
134
172
 
135
173
  when :link
136
174
  steps << {
@@ -165,7 +203,7 @@ CMD
165
203
  }
166
204
 
167
205
  steps << {
168
- :check => "-f #{opts[:binary]}",
206
+ :check => opts[:test],
169
207
  :code => <<-CODE
170
208
  [ -f #{home_dir}/tmp/#{opts[:filename]} ] && rm #{home_dir}/tmp/#{opts[:filename]}
171
209
  [ -d #{home_dir}/tmp/#{opts[:folder]} ] && rm -rf #{home_dir}/tmp/#{opts[:folder]}
@@ -3,7 +3,11 @@ module Gluez
3
3
  def initialize(options)
4
4
  @options = options
5
5
  end
6
-
6
+
7
+ def key?(key)
8
+ @options.key?(key)
9
+ end
10
+
7
11
  def [](name, default=nil)
8
12
  value = @options[name]
9
13
  if value
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gluez
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Zimmek
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-01 00:00:00 +02:00
13
+ date: 2011-05-05 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies: []
16
16