gluez 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gluez/context.rb CHANGED
@@ -141,7 +141,7 @@ module Gluez
141
141
  gid user_ctx.get(:uid)
142
142
  end
143
143
 
144
- ['.gluez', '.gluez/path', 'tmp', 'backup', 'bin', '.ssh'].each do |dir_name|
144
+ ['.gluez', '.gluez/path', 'tmp', 'backup', 'bin', '.ssh', 'log'].each do |dir_name|
145
145
  dir(dir_name) do
146
146
  as_user user_ctx.user
147
147
  end
@@ -0,0 +1,42 @@
1
+ require 'erb'
2
+ require 'base64'
3
+
4
+ resource :crontab do
5
+
6
+ mandatory :content
7
+
8
+ instance_variable_set("@vars", {})
9
+ def var(name, value)
10
+ @vars[name] = value
11
+ end
12
+
13
+ ready!
14
+
15
+ res = self
16
+ vars = Object.new
17
+
18
+ vars.class.class_eval do
19
+ res.instance_variable_get("@vars").each_pair do |key, val|
20
+ next unless val
21
+ define_method key do
22
+ val
23
+ end
24
+ end
25
+ define_method :get_binding do
26
+ binding
27
+ end
28
+ end
29
+
30
+ data = ERB.new(self.content).result(vars.get_binding).multiline_strip
31
+ base64 = Base64.encode64(data + "\n")
32
+
33
+ setup "cat >~/.gluez_transfer <<\\DATA
34
+ #{base64}
35
+ DATA"
36
+
37
+ steps do |step|
38
+ step.checks << %Q("\\$(cat ~/.gluez_transfer | base64 -d - | md5sum - | awk '{print \\$1}')" = "\\$(crontab -l | md5sum - | awk '{print \\$1}')")
39
+ step.code = "cat ~/.gluez_transfer | base64 -d - | crontab"
40
+ end
41
+
42
+ end
data/lib/gluez.rb CHANGED
@@ -27,6 +27,24 @@ class String
27
27
  word
28
28
  end
29
29
 
30
+ def multiline_strip
31
+ lines = self.split("\n")
32
+ first = lines[0]
33
+
34
+ idx = 0
35
+ while first[idx] == ' '
36
+ idx += 1
37
+ end
38
+
39
+ if idx > 0
40
+ lines = lines.map do |line|
41
+ line[idx, line.length]
42
+ end
43
+ end
44
+
45
+ lines.join("\n")
46
+ end
47
+
30
48
  # Return the string as camelcased version e.g. some_text_value becomes SomeTextValue.
31
49
  def camelize(first_letter_in_uppercase=true)
32
50
  word = self.dup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gluez
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-30 00:00:00.000000000 Z
12
+ date: 2011-12-05 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: a server configuration toolkit
15
15
  email: jan.zimmek@web.de
@@ -23,6 +23,7 @@ files:
23
23
  - lib/gluez/resources/bash_once.rb
24
24
  - lib/gluez/resources/create_group.rb
25
25
  - lib/gluez/resources/create_user.rb
26
+ - lib/gluez/resources/crontab.rb
26
27
  - lib/gluez/resources/dir.rb
27
28
  - lib/gluez/resources/disable.rb
28
29
  - lib/gluez/resources/enable.rb