Module: Getch::Helpers::Void
- Defined in:
- lib/getch/helpers.rb
Overview
Helpers specific to void
Instance Method Summary collapse
-
#chroot(cmd) ⇒ Object
Used only when need password.
- #command_output(args) ⇒ Object
- #line_fstab(dev, rest) ⇒ Object
- #s_uuid(dev) ⇒ Object
Instance Method Details
#chroot(cmd) ⇒ Object
Used only when need password
138 139 140 141 142 |
# File 'lib/getch/helpers.rb', line 138 def chroot(cmd) return if system('chroot', Getch::MOUNTPOINT, '/bin/bash', '-c', cmd) raise "[-] Error with: #{cmd}" end |
#command_output(args) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/getch/helpers.rb', line 125 def command_output(args) print " => Exec: #{args}..." cmd = "chroot #{Getch::MOUNTPOINT} /bin/bash -c \"#{args}\"" Open3.popen2e(cmd) do |_, stdout_err, wait_thr| puts stdout_err.each { |l| puts l } exit_status = wait_thr.value raise("\n[-] Fail cmd #{args} - #{stdout_err}.") unless exit_status.success? end end |
#line_fstab(dev, rest) ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/getch/helpers.rb', line 152 def line_fstab(dev, rest) conf = "#{Getch::MOUNTPOINT}/etc/fstab" device = s_uuid(dev) raise "No partuuid for #{dev} #{device}" unless device raise "Bad partuuid for #{dev} #{device}" if device.is_a?(Array) add_line(conf, "PARTUUID=#{device} #{rest}") end |
#s_uuid(dev) ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/getch/helpers.rb', line 144 def s_uuid(dev) device = dev.delete_prefix('/dev/') Dir.glob('/dev/disk/by-partuuid/*').each do |f| link = File.readlink(f) return f.delete_prefix('/dev/disk/by-partuuid/') if link.match(/#{device}$/) end end |