kuzushi 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/kuzushi.rb +23 -8
  3. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
data/lib/kuzushi.rb CHANGED
@@ -92,7 +92,7 @@ class Kuzushi
92
92
  @packages = get_array("packages")
93
93
  task "install packages" do
94
94
  shell "apt-get update && apt-get upgrade -y"
95
- shell "apt-get install -y #{@packages.join(" ")}" if @packages.empty?
95
+ shell "apt-get install -y #{@packages.join(" ")}" unless @packages.empty?
96
96
  end
97
97
  end
98
98
 
@@ -150,14 +150,17 @@ class Kuzushi
150
150
  end
151
151
 
152
152
  def handle_tmpfs(m)
153
- task "mount #{m.mount}" do
154
- shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} -t tmpfs tmpfs #{m.mount}" unless mounted?(m.mount)
155
- end
153
+ m.format ||= "tmpfs"
154
+ m.device ||= "tmpfs"
156
155
  end
157
156
 
158
157
  def handle_mount(m)
159
158
  task "mount #{m.mount}" do
160
- shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} #{m.device} #{m.mount}" unless mounted?(m.mount)
159
+ unless mounted?(m.mount)
160
+ shell "mv #{m.mount} #{m.mout}.old" if File.exists?(m.mount)
161
+ shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} -t #{m.format} #{m.device} #{m.mount}"
162
+ shell "chown -R #{m.user}:#{m.group} #{m.mount}" if m.user or m.group
163
+ end
161
164
  end
162
165
  end
163
166
 
@@ -176,15 +179,27 @@ class Kuzushi
176
179
  end
177
180
 
178
181
  def process_files(f)
179
- fetch("/templates/#{f.template}") do |file|
180
- task "setting up #{f.file}" do
182
+ if f.template
183
+ write_file("/templates/#{f.template}", f.file) do |file|
181
184
  @system = system
182
185
  t = ERB.new File.read(file), 0, '<>'
183
- File.open(f.file,"w") { |f| f.write(t.result(binding)) }
186
+ t.result(binding))
187
+ end
188
+ else
189
+ src = f.source || File.basename(f.file)
190
+ write_file("/files/#{src}", f.file) do |file|
191
+ File.read(file)
184
192
  end
185
193
  end
186
194
  end
187
195
 
196
+ def write_file(src, dest, &blk)
197
+ fetch(src) do |file|
198
+ FileUtils.mkdir_p(File.dirname(dest))
199
+ File.open(f.file,"w") { |f| f.write(blk.call) }
200
+ end
201
+ end
202
+
188
203
  def process_users(user)
189
204
  (user.authorized_keys || []).each do |key|
190
205
  task "add authorized_key for user #{user.name}" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuzushi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orion Henry