hatecf 0.0.1 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9e89a8cfac1c0bf752d1c86a7b8637ca2191eecc55e53ff8f50ccf8b80acb5c
4
- data.tar.gz: a3efe1d1aaeceb0c0566d88ad737d055e54181f5d7dece693a3129d4210e7525
3
+ metadata.gz: 827fd6c2d736fc58850a414f1e11acfba2bc5199cc867f8954df6202888a67ba
4
+ data.tar.gz: c397ba5ec14ec01d9ff7ea323da5f9d6100aae78c858dcf57c994132ecf64bec
5
5
  SHA512:
6
- metadata.gz: 1e2770dafb8f77bf2f505aa0899c33d923ea32d785331323dadc30e26620261f3406d3f73e8a0495995613b4eb4180234071c805816a1c20bcfbf81f4781a4d7
7
- data.tar.gz: 1c2ba2caa0a5c2319aa4dda79644d93e2a2f75bd9bff6963a3f5c8bc130270a766a772d324ea8afbdff6153a78ab223cb59ec5ccb4c1f114ac2c4a0e5201edbe
6
+ metadata.gz: 81827c49edfce7d0a44c9a180e88a3c092b5977d01e1c4ca7d1e906f11fe6ec983fdb3bbb19fcaf05a7d469244d540c73ad7cfc2f243d2dea12c36487d931fa7
7
+ data.tar.gz: e4fbd334575d6fb37b13dadce134f36338ab952fd1f52ed945e18b8b6221e7e886e875f0c0500e5eaac829b004429efb13308fe5d245277ae2bcc946f998ed34
data/lib/hatecf.rb CHANGED
@@ -1,2 +1 @@
1
- #require "./local_dsl.rb"
2
1
  require File.join(__dir__, "./local_dsl.rb")
data/lib/local.rb CHANGED
@@ -107,11 +107,17 @@ module Local
107
107
  FileUtils.mkdir local_files_dir
108
108
  copy_local_files_to(local_files_dir)
109
109
  end
110
- cmd = "tar -czP #{tmp_dir} | ssh #{@target[:user] || DEFAULT_TARGET[:user]}@#{@target[:host]} \"tar -xzP -C / && (cd #{tmp_dir} && ./bootstrap_ruby && RUBYLIB=. ./script.rb #{@dry_run ? "--dry " : " "}--local-home #{ENV["HOME"]} --local-script-dir #{script_dir}); rm -r #{tmp_dir}\""
110
+ script_opts = []
111
+ script_opts << "--dry" if @dry_run
112
+ script_opts << "-v" if @verbose
113
+ script_opts << "--local-home #{ENV["HOME"]}"
114
+ script_opts << "--local-script-dir #{script_dir}"
115
+ cmd = "tar -czP #{tmp_dir} | ssh #{@target[:user] || DEFAULT_TARGET[:user]}@#{@target[:host]} \"tar -xzP -C / && (cd #{tmp_dir} && ./bootstrap_ruby && RUBYLIB=. ./script.rb #{script_opts.join(" ")}); rm -r #{tmp_dir}\""
111
116
  debug "executing: #{cmd}"
112
117
  pid, status = Process.wait2(Process.spawn(cmd))
113
118
  debug "exit status: #{status.exitstatus}"
114
119
  end
120
+ # FIXME: this always returns the status of "; rm" above, doesn't it?
115
121
  exit status.exitstatus
116
122
  end
117
123
 
@@ -120,9 +126,13 @@ module Local
120
126
  opts.on "--dry", "don't change anything, just test everything" do |x|
121
127
  @dry_run = true
122
128
  end
129
+ opts.on "-v", "verbose mode: print debug messages" do |x|
130
+ @verbose = true
131
+ end
123
132
  end.parse!
124
133
 
125
134
  def debug(s)
135
+ info s if @verbose
126
136
  end
127
137
 
128
138
  def info(s)
data/lib/local_dsl.rb CHANGED
@@ -1,4 +1,3 @@
1
- #require "./local.rb"
2
1
  require File.join(__dir__, "./local.rb")
3
2
 
4
3
  def target(host:, user: nil, port: nil)
@@ -27,12 +26,14 @@ def local_file(path)
27
26
  return LocalFile.new(path)
28
27
  end
29
28
 
29
+ # FIXME: unused
30
30
  class LocalEntity
31
31
  def initialize(payload)
32
32
  @payload = payload
33
33
  end
34
34
  end
35
35
 
36
+ # FIXME: unused
36
37
  def local(x)
37
38
  LocalEntity.new(x)
38
39
  end
data/remote/remote.rb CHANGED
@@ -174,6 +174,7 @@ module Remote
174
174
  end
175
175
  end
176
176
 
177
+ require 'fileutils'
177
178
  def authorize_ssh_key(user, key)
178
179
  case key
179
180
  when LocalFile
@@ -183,7 +184,6 @@ module Remote
183
184
  else
184
185
  raise "type #{key.class} is not supported for a SSH public key"
185
186
  end
186
- require 'fileutils'
187
187
  home_dir = get_user_home_dir(user)
188
188
  ssh_dir = File.join(home_dir, ".ssh")
189
189
  authorized_keys_path = File.join(ssh_dir, "authorized_keys")
@@ -254,7 +254,7 @@ module Remote
254
254
  if dpkg_installed?(names)
255
255
  ok "installed: #{names.join(', ')}"
256
256
  else
257
- destructive "apt-get install #{names.is_a?(Array) ? names.join(' ') : names}" do
257
+ destructive "apt-get install #{names.join(' ')}" do
258
258
  unless apt_updated
259
259
  cmd = ["apt-get", "update", "-q"]
260
260
  spawn(cmd, expect_status: 0)
@@ -368,11 +368,11 @@ module Remote
368
368
  def ln_s(src, dst)
369
369
  src = File.expand_path src
370
370
  dst = File.expand_path dst
371
- if File.lstat(dst).symlink? && File.readlink(dst) == src
371
+ if File.exist?(dst) &&File.lstat(dst).symlink? && File.readlink(dst) == src
372
372
  ok "#{dst} leads to #{src}"
373
373
  else
374
374
  destructive "ln -s #{src} #{dst}" do
375
- FileUtils.ln_s src dst
375
+ FileUtils.ln_s src, dst
376
376
  end
377
377
  end
378
378
  end
@@ -462,6 +462,7 @@ module Remote
462
462
  end
463
463
 
464
464
  def debug(s)
465
+ info s if @verbose
465
466
  end
466
467
 
467
468
  def info(s)
@@ -494,5 +495,8 @@ module Remote
494
495
  opts.on "--dry" do |x|
495
496
  @dry_run = true
496
497
  end
498
+ opts.on "-v" do |x|
499
+ @verbose = true
500
+ end
497
501
  end.parse!
498
502
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatecf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Markov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Configuration management engine like Ansible but without YAML and 30
14
14
  times faster