getch 0.0.8 → 0.1.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +44 -0
  5. data/README.md +57 -8
  6. data/bin/setup.sh +4 -2
  7. data/lib/getch.rb +43 -15
  8. data/lib/getch/command.rb +26 -5
  9. data/lib/getch/config.rb +58 -0
  10. data/lib/getch/filesystem.rb +6 -0
  11. data/lib/getch/filesystem/clean.rb +51 -0
  12. data/lib/getch/filesystem/device.rb +61 -0
  13. data/lib/getch/filesystem/ext4.rb +1 -0
  14. data/lib/getch/filesystem/ext4/config.rb +8 -9
  15. data/lib/getch/filesystem/ext4/device.rb +2 -7
  16. data/lib/getch/filesystem/ext4/encrypt/config.rb +69 -47
  17. data/lib/getch/filesystem/ext4/encrypt/deps.rb +21 -15
  18. data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -9
  19. data/lib/getch/filesystem/ext4/encrypt/format.rb +10 -6
  20. data/lib/getch/filesystem/ext4/encrypt/mount.rb +6 -43
  21. data/lib/getch/filesystem/ext4/encrypt/partition.rb +57 -55
  22. data/lib/getch/filesystem/ext4/format.rb +3 -5
  23. data/lib/getch/filesystem/ext4/mount.rb +7 -46
  24. data/lib/getch/filesystem/ext4/partition.rb +16 -39
  25. data/lib/getch/filesystem/lvm.rb +1 -0
  26. data/lib/getch/filesystem/lvm/config.rb +12 -15
  27. data/lib/getch/filesystem/lvm/deps.rb +5 -20
  28. data/lib/getch/filesystem/lvm/device.rb +33 -9
  29. data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
  30. data/lib/getch/filesystem/lvm/encrypt/config.rb +71 -0
  31. data/lib/getch/filesystem/lvm/encrypt/deps.rb +46 -0
  32. data/lib/getch/filesystem/lvm/encrypt/device.rb +46 -0
  33. data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
  34. data/lib/getch/filesystem/lvm/encrypt/mount.rb +25 -0
  35. data/lib/getch/filesystem/lvm/encrypt/partition.rb +80 -0
  36. data/lib/getch/filesystem/lvm/format.rb +11 -7
  37. data/lib/getch/filesystem/lvm/mount.rb +7 -46
  38. data/lib/getch/filesystem/lvm/partition.rb +19 -31
  39. data/lib/getch/filesystem/mount.rb +56 -0
  40. data/lib/getch/filesystem/partition.rb +77 -0
  41. data/lib/getch/filesystem/zfs.rb +14 -0
  42. data/lib/getch/filesystem/zfs/config.rb +57 -0
  43. data/lib/getch/filesystem/zfs/deps.rb +95 -0
  44. data/lib/getch/filesystem/zfs/device.rb +58 -0
  45. data/lib/getch/filesystem/zfs/encrypt.rb +15 -0
  46. data/lib/getch/filesystem/zfs/encrypt/config.rb +67 -0
  47. data/lib/getch/filesystem/zfs/encrypt/deps.rb +97 -0
  48. data/lib/getch/filesystem/zfs/encrypt/device.rb +60 -0
  49. data/lib/getch/filesystem/zfs/encrypt/format.rb +105 -0
  50. data/lib/getch/filesystem/zfs/encrypt/mount.rb +51 -0
  51. data/lib/getch/filesystem/zfs/encrypt/partition.rb +65 -0
  52. data/lib/getch/filesystem/zfs/format.rb +114 -0
  53. data/lib/getch/filesystem/zfs/mount.rb +48 -0
  54. data/lib/getch/filesystem/zfs/partition.rb +64 -0
  55. data/lib/getch/gentoo.rb +8 -4
  56. data/lib/getch/gentoo/boot.rb +32 -17
  57. data/lib/getch/gentoo/chroot.rb +12 -26
  58. data/lib/getch/gentoo/config.rb +37 -12
  59. data/lib/getch/gentoo/sources.rb +26 -29
  60. data/lib/getch/gentoo/use.rb +43 -0
  61. data/lib/getch/gentoo/use_flag.rb +64 -0
  62. data/lib/getch/helpers.rb +35 -13
  63. data/lib/getch/options.rb +23 -8
  64. data/lib/getch/version.rb +1 -1
  65. metadata +46 -18
  66. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d697434a5e8a44edb8027582ece052145c440247524597afe5ad28118115154
4
- data.tar.gz: 42eb9e224e6581752f28d6997a9e10feb0e65c432e0dd80bc87236d7e597d828
3
+ metadata.gz: c141cfefd0484364edafbbf424bc6e3d1fe98d26d5a2fa96411ae88efaae501a
4
+ data.tar.gz: 117fb8c04c3525ac5c5be3da0683eac0b68de537f674955fe6d363091233ab0b
5
5
  SHA512:
6
- metadata.gz: 2e17128164b81b58d59f296e360197a2b9fbb33fd2b1cbd58128b1b04885eef4480d067c5588d40802c889e5a80861b63c37454b685bdb6263e9806b2e99b208
7
- data.tar.gz: f8eee6f6b37fb036a05003d109672615cc7439dcc5277f2d4604d58e66b2407fa648bdccb850269545f2aef5441777a0d936842326cecb7410b05dfb6dbcee64
6
+ metadata.gz: fbf00fb976d8e4a1ea8a4e3abf64de42f9804b4b33b125548021f733d27e2458d6c6ec2e9712f3f92806b66253550c600c217f3ece4bf3310f5b39c5cb58aebf
7
+ data.tar.gz: ed7af46af82c816f17296ba01301aece81d6655d4fc31c166fce5a013be8c20e5b89b8965c3d855913628c3566a47bd8b2ed123263c7dedaef5b3e3fdd0a6b4e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,6 +1,50 @@
1
+ ## 0.1.3, release 2021-05-17
2
+ * LVM use the format /dev/vg_name/lv_name for mount/format/fstab.
3
+ * Stop using `euse` from `gentoolkit`, use native Ruby code here.
4
+ * Optimization on package installation, they shouln't be installed more than once.
5
+ * Regroup use flags under Getch::Gentoo::UseFlag.
6
+ * Upd Bask v0.5 (zstd compression, better support for wifi...)
7
+ * Config for systemd-resolved, enable DNS over TLS with Quad9 (9.9.9.9)
8
+ * Add configs for systemd-network with DHCP for wifi and ethernet.
9
+ * Correct permissions (/home/[user] and /etc/portage)
10
+
11
+ ## 0.1.2, release 2021-05-12
12
+ * DOCS update.
13
+ * Keep Nano for those who need :)
14
+ * ZFS use the last version >=2.0 with kernel stable =5.10
15
+ * ZFS create a Log device and Cache device if getch is used with `--separate-cache`.
16
+ * GRUB or Systemd-boot can now be installed on separate disk with `--separate-boot`.
17
+ * Adding flag for ZFS `-o autotrim=on` (used with `zpool create`).
18
+ * Encrypted swap use: `cipher=aes-xts-plain64:sha256,size=512` by default.
19
+ * In the make.conf: add `-fomit-frame-pointer`, designed to reduce generated code size.
20
+
21
+ ## 0.1.1, release 2020-11-01
22
+ * Change mountpoint for the esp at /efi rather than /boot/efi
23
+ * Replace Garden by Bask https://github.com/szorfein/bask
24
+ * Correct option --username USERNAME, do not create a new partition.
25
+ * New set of options --separate-{boot,cache,home} to install them on another disk
26
+ * Refactor codes
27
+ * Add cpu name to COMMON_FLAGS
28
+ * Add cpuflags with app-portage/cpuid2cpuflags
29
+ + Use the whole disk space available for / when option --username is unset
30
+
31
+ ## 0.1.0, release 2020-10-15
32
+ * Add the (Zeta) filesystem ZFS
33
+ * `emerge --depclean` to save space.
34
+ * Add a message when getch have finish, keep /mnt/gentoo if you need to add something.
35
+ * Use systemd-detect-virt to detect a Virtual Guest.
36
+
37
+ ## 0.0.9, release 2020-10-03
38
+ * Add encryption on ext4 and lvm (BIOS,UEFI)
39
+ * Correct KEYMAP="yes" with genkernel
40
+ * Renaming option keyboard with keymap
41
+ * GPG verification for ebuild
42
+
43
+ ## 0.0.8, release 2020-09-30
1
44
  * Adding LVM via the option fs, `--fs lvm`.
2
45
  * Systemd-boot use the value of PARTUUID without initramfs.
3
46
  * Include lib logger.
47
+ * Enhance functions to call program system Emerge, Make, ...
4
48
 
5
49
  ## 0.0.7, release 2020-09-22
6
50
  * Correct fstab.
data/README.md CHANGED
@@ -3,15 +3,17 @@ A CLI tool to install Gentoo.
3
3
 
4
4
  ## Description
5
5
  Actually, Getch support only the [AMD64 handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64) and only with the last `stage3-amd64-systemd`.
6
- It also require a disk (only one for now) with a minimum of 20G.
7
6
 
8
- Filesystem supported by Getch are: (the list will evolve...)
9
- + ext4 with GRUB2 for BIOS based system and systemd-boot for UEFI systems.
7
+ BIOS system will use `Grub2` and `systemd-boot` for UEFI. Filesystem supported by Getch are for now:
8
+ + Ext4
9
+ + LVM
10
+ + ZFS
10
11
 
11
- I would also add disk encryption soon.
12
+ Encryption is also supported.
12
13
 
13
14
  The ISO images i was able to test and that works:
14
15
  + [Archlinux](https://www.archlinux.org/download/)
16
+ + [Archaeidae](https://github.com/szorfein/archaeidae): Custom Archiso that includes ZFS support.
15
17
 
16
18
  ## Install
17
19
  Getch is cryptographically signed, so add my public key (if you haven’t already) as a trusted certificate.
@@ -26,21 +28,68 @@ When you boot from an `iso`, you can install `ruby`, `getch` and correct your `P
26
28
  # sh <(curl -L https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh)
27
29
  # source ~/.zshrc # or ~/.bashrc
28
30
 
31
+ If you want to try the master branch:
32
+
33
+ # git clone https://github.com/szorfein/getch
34
+ # cd getch
35
+ # ruby -I lib bin/getch -h
36
+
29
37
  ## Usage
38
+ Just ensure than the script is run with a root account.
39
+
40
+ # getch -h
30
41
 
31
- $ getch -h
42
+ After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
32
43
 
33
44
  ## Examples
34
45
  For a french user:
35
46
 
36
- # getch --username ninja --zoneinfo "Europe/Paris" --language fr_FR --keyboard fr
37
-
38
- After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
47
+ # getch --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
39
48
 
40
49
  Install Gentoo on LVM:
41
50
 
42
51
  # getch --format lvm --disk sda
43
52
 
53
+ Encrypt your disk with LVM with a french keymap
54
+
55
+ # getch --format lvm --encrypt --keymap fr
56
+
57
+ Encrypt with ext4 and create a home directory /home/ninja
58
+
59
+ # getch --format ext4 --encrypt --username ninja
60
+
61
+ With ZFS:
62
+
63
+ # getch --format zfs
64
+
65
+ ## Troubleshooting
66
+
67
+ #### LVM
68
+ Unless your old LVM volume group is also named `vg0`, `getch` may fail to partition your disk. You have to clean up your device before proceed with `vgremove` and `pvremove`. An short example how doing this with a volume group named `vg0`:
69
+
70
+ # vgdisplay | grep vg0
71
+ # vgremove -f vg0
72
+ # pvremove -f /dev/sdb
73
+
74
+ #### Encryption enable on BIOS with ext4
75
+ To decrypt your disk on BIOS system, you have to enter your password two times. One time for Grub and another time for the initramfs (Genkernel). [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
76
+ Also with GRUB, only a `us` keymap is working.
77
+
78
+ #### With ZFS
79
+ When Gentoo boot, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just reboot on your ISO:
80
+
81
+ You need the partuuid, pool are create with the first 5 characters, just replace `sdX` by your real device:
82
+
83
+ # ls -l /dev/disk/by-partuuid/ | grep sdX4
84
+ -> 150ed969...
85
+ # zpool import -N -R /mnt rpool-150ed
86
+
87
+ And export them correctly:
88
+
89
+ # zpool export -a
90
+
91
+ It's all.
92
+
44
93
  ## Issues
45
94
  If need more support for your hardware (network, sound card, ...), you can submit a [new issue](https://github.com/szorfein/getch/issues/new) and post the output of the following command:
46
95
  + lspci
data/bin/setup.sh CHANGED
@@ -72,10 +72,12 @@ set_shell() {
72
72
  [ -f ~/.zshrc ] && your_shell=~/.zshrc
73
73
 
74
74
  [ -f "$your_shell" ] && {
75
- if ! grep -q ".gem/ruby/[0-9.]*/bin" "$your_shell" ; then
75
+ if ! grep -q "ruby" "$your_shell" ; then
76
76
  echo "export PATH=\$PATH:$(ruby -e 'puts Gem.user_dir')/bin" >> "$your_shell"
77
77
  fi
78
- . "$your_shell"
78
+ if $(. "$your_shell") ; then
79
+ echo "Shell loaded"
80
+ fi
79
81
  }
80
82
  }
81
83
 
data/lib/getch.rb CHANGED
@@ -5,16 +5,20 @@ require_relative 'getch/filesystem'
5
5
  require_relative 'getch/command'
6
6
  require_relative 'getch/helpers'
7
7
  require_relative 'getch/log'
8
+ require_relative 'getch/config'
8
9
 
9
10
  module Getch
10
11
 
11
12
  DEFAULT_OPTIONS = {
12
13
  language: 'en_US',
13
14
  zoneinfo: 'US/Eastern',
14
- keyboard: 'us',
15
+ keymap: 'us',
15
16
  disk: 'sda',
16
17
  fs: 'ext4',
17
18
  username: nil,
19
+ boot_disk: nil,
20
+ cache_disk: nil,
21
+ home_disk: nil,
18
22
  encrypt: false,
19
23
  verbose: false
20
24
  }
@@ -30,20 +34,38 @@ module Getch
30
34
  }
31
35
 
32
36
  MOUNTPOINT = "/mnt/gentoo".freeze
33
- OPTIONS_FS = {
34
- 'ext4' => DEFAULT_OPTIONS[:encrypt] ? Getch::FileSystem::Ext4::Encrypt : Getch::FileSystem::Ext4,
35
- 'lvm' => DEFAULT_OPTIONS[:encrypt] ? Getch::FileSystem::Lvm::Encrypt : Getch::FileSystem::Lvm
37
+ DEFAULT_FS = {
38
+ true => {
39
+ ext4: Getch::FileSystem::Ext4::Encrypt,
40
+ lvm: Getch::FileSystem::Lvm::Encrypt,
41
+ zfs: Getch::FileSystem::Zfs::Encrypt
42
+ },
43
+ false => {
44
+ ext4: Getch::FileSystem::Ext4,
45
+ lvm: Getch::FileSystem::Lvm,
46
+ zfs: Getch::FileSystem::Zfs,
47
+ }
36
48
  }.freeze
37
49
 
50
+ def self.class_fs
51
+ encrypt = DEFAULT_OPTIONS[:encrypt]
52
+ fs = DEFAULT_OPTIONS[:fs].to_sym
53
+ DEFAULT_FS[encrypt][fs]
54
+ end
55
+
38
56
  def self.resume_options(opts)
39
57
  puts "\nBuild Gentoo with the following args:\n"
40
- puts "lang: #{DEFAULT_OPTIONS[:language]}"
41
- puts "zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
42
- puts "keyboard: #{DEFAULT_OPTIONS[:keyboard]}"
43
- puts "disk: #{DEFAULT_OPTIONS[:disk]}"
44
- puts "fs: #{DEFAULT_OPTIONS[:fs]}"
45
- puts "username: #{DEFAULT_OPTIONS[:username]}"
46
- puts "encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
58
+ puts "Lang: #{DEFAULT_OPTIONS[:language]}"
59
+ puts "Zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
60
+ puts "Keymap: #{DEFAULT_OPTIONS[:keymap]}"
61
+ puts "Disk: #{DEFAULT_OPTIONS[:disk]}"
62
+ puts "Filesystem: #{DEFAULT_OPTIONS[:fs]}"
63
+ puts "Username: #{DEFAULT_OPTIONS[:username]}"
64
+ puts "Encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
65
+ puts
66
+ puts "separate-boot disk: #{DEFAULT_OPTIONS[:boot_disk]}"
67
+ puts "separate-cache disk: #{DEFAULT_OPTIONS[:cache_disk]}"
68
+ puts "separate-home disk: #{DEFAULT_OPTIONS[:home_disk]}"
47
69
  puts
48
70
  print "Continue? (n,y) "
49
71
  case gets.chomp
@@ -62,8 +84,8 @@ module Getch
62
84
  case gets.chomp
63
85
  when /^y|^Y/
64
86
  log.info("Partition start")
65
- OPTIONS_FS[fs]::Partition.new
66
- OPTIONS_FS[fs]::Format.new
87
+ class_fs::Partition.new
88
+ class_fs::Format.new
67
89
  else
68
90
  exit 1
69
91
  end
@@ -73,18 +95,24 @@ module Getch
73
95
  gentoo = Getch::Gentoo
74
96
  gentoo.stage3
75
97
  gentoo.config(options)
76
- gentoo.chroot
98
+ gentoo.chroot(options)
77
99
  gentoo.kernel
78
100
  gentoo.boot(options)
79
101
  end
80
102
 
103
+ def self.configure(options)
104
+ config = Getch::Config.new
105
+ config.network
106
+ end
107
+
81
108
  def self.main(argv)
82
109
  options = Options.new(argv)
83
110
  DEFAULT_OPTIONS.freeze
84
111
  resume_options(options)
85
112
  Getch::States.new # Update States
86
113
  format(options.disk, options.fs, options.username)
87
- OPTIONS_FS[DEFAULT_OPTIONS[:fs]]::Mount.new.run
114
+ class_fs::Mount.new.run
88
115
  init_gentoo(options)
116
+ configure(options)
89
117
  end
90
118
  end
data/lib/getch/command.rb CHANGED
@@ -17,7 +17,7 @@ module Getch
17
17
 
18
18
  # only stderr
19
19
  begin
20
- @log.error stderr.readline until stderr.eof.nil?
20
+ @log.debug stderr.readline until stderr.eof.nil?
21
21
  rescue EOFError
22
22
  end
23
23
 
@@ -127,19 +127,21 @@ module Getch
127
127
  end
128
128
  end
129
129
 
130
- class Garden
130
+ class Bask
131
131
  def initialize(cmd)
132
132
  @gentoo = MOUNTPOINT
133
133
  @cmd = cmd
134
134
  @log = Getch::Log.new
135
+ @version = "0.5"
135
136
  end
136
137
 
137
138
  def run!
138
- @log.info "Running Garden: #{@cmd}"
139
+ download_bask if ! Dir.exist? "#{MOUNTPOINT}/root/bask-#{@version}"
140
+ @log.info "Running Bask: #{@cmd}"
139
141
  cmd = "chroot #{@gentoo} /bin/bash -c \"source /etc/profile \
140
142
  && env-update \
141
- && cd /root/garden-master \
142
- && ./kernel.sh #{@cmd} -k /usr/src/linux\""
143
+ && cd /root/bask-#{@version} \
144
+ && ./bask.sh #{@cmd} -k /usr/src/linux\""
143
145
  Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
144
146
  while line = stdout_err.gets
145
147
  puts line
@@ -152,5 +154,24 @@ module Getch
152
154
  end
153
155
  end
154
156
  end
157
+
158
+ private
159
+
160
+ def download_bask
161
+ @log.info "Installing Bask..."
162
+ url = "https://github.com/szorfein/bask/archive/v#{@version}.tar.gz"
163
+ file = "bask-#{@version}.tar.gz"
164
+
165
+ Dir.chdir("#{MOUNTPOINT}/root")
166
+ Helpers::get_file_online(url, file)
167
+ Getch::Command.new("tar xzf #{file}").run!
168
+ end
169
+ end
170
+
171
+ class Chroot < Command
172
+ def initialize(cmd)
173
+ super
174
+ @cmd = "chroot #{MOUNTPOINT} /bin/bash -c \"source /etc/profile; #{cmd}\""
175
+ end
155
176
  end
156
177
  end
@@ -0,0 +1,58 @@
1
+ module Getch
2
+ class Config
3
+ def initialize
4
+ @systemd_net_dir = "#{MOUNTPOINT}/etc/systemd"
5
+ end
6
+
7
+ def network
8
+ ethernet
9
+ wifi
10
+ resolved
11
+ Getch::Chroot.new('systemctl enable systemd-networkd').run!
12
+ Getch::Chroot.new('systemctl enable systemd-resolved').run!
13
+ end
14
+
15
+ private
16
+
17
+ def ethernet
18
+ conf = "#{@systemd_net_dir}/network/20-ethernet.network"
19
+ datas = [
20
+ "[Match]",
21
+ "Name=en*",
22
+ "Name=eth*",
23
+ "[Network]",
24
+ "DHCP=yes",
25
+ "IPv6PrivacyExtensions=yes",
26
+ "[DHCP]",
27
+ "RouteMetric=512"
28
+ ]
29
+ File.write(conf, datas.join("\n"), mode: 'w')
30
+ end
31
+
32
+ def wifi
33
+ conf = "#{@systemd_net_dir}/network/20-wireless.network"
34
+ datas = [
35
+ "[Match]",
36
+ "Name=wlp*",
37
+ "Name=wlan*",
38
+ "[Network]",
39
+ "DHCP=yes",
40
+ "IPv6PrivacyExtensions=yes",
41
+ "[DHCP]",
42
+ "RouteMetric=1024",
43
+ ]
44
+ File.write(conf, datas.join("\n"), mode: 'w')
45
+ end
46
+
47
+ def resolved
48
+ conf = "#{@systemd_net_dir}/resolved.conf.d/dns_over_tls.conf"
49
+ datas = [
50
+ "[Resolve]",
51
+ "DNS=9.9.9.9#dns.quad9.net",
52
+ "DNSOverTLS=yes",
53
+ ]
54
+ Helpers::create_dir("#{@systemd_net_dir}/resolved.conf.d")
55
+ File.write(conf, datas.join("\n"), mode: 'w')
56
+ end
57
+ end
58
+ end
@@ -3,5 +3,11 @@ module Getch
3
3
  end
4
4
  end
5
5
 
6
+ require_relative 'filesystem/device'
7
+ require_relative 'filesystem/clean'
8
+ require_relative 'filesystem/partition'
9
+ require_relative 'filesystem/mount'
10
+
6
11
  require_relative 'filesystem/ext4'
7
12
  require_relative 'filesystem/lvm'
13
+ require_relative 'filesystem/zfs'
@@ -0,0 +1,51 @@
1
+ module Getch
2
+ module FileSystem
3
+ module Clean
4
+ def self.clean_hdd(disk)
5
+ return if ! disk
6
+ raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
7
+ puts
8
+ print "Cleaning data on #{disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? [y,N] "
9
+ case gets.chomp
10
+ when /^y|^Y/
11
+ bloc=`blockdev --getbsz /dev/#{disk}`.chomp
12
+ Helpers::sys("dd if=/dev/urandom of=/dev/#{disk} bs=#{bloc} status=progress")
13
+ else
14
+ return
15
+ end
16
+ end
17
+
18
+ def self.clean_struct(disk)
19
+ return if ! disk
20
+ raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
21
+ Helpers::sys("sgdisk -Z /dev/#{disk}")
22
+ Helpers::sys("wipefs -a /dev/#{disk}")
23
+ end
24
+
25
+ def self.hdd(*disks)
26
+ disks.each { |d| clean_hdd(d) }
27
+ end
28
+ # See https://wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing
29
+ # for SSD
30
+ def self.sdd
31
+ end
32
+
33
+ def self.struct(*disks)
34
+ disks.each { |d| clean_struct(d) }
35
+ end
36
+
37
+ def self.old_vg(disk, vg)
38
+ oldvg = `vgdisplay | grep #{vg}`.chomp
39
+ Helpers::sys("vgremove -f #{vg}") if oldvg != ''
40
+ Helpers::sys("pvremove -f #{disk}") if oldvg != '' and File.exist? disk
41
+ end
42
+
43
+ def self.old_zpool
44
+ oldzpool = `zpool status | grep pool:`.gsub(/pool: /, '').delete(' ').split("\n")
45
+ if oldzpool[0] != "" and $?.success?
46
+ oldzpool.each { |p| Helpers::sys("zpool destroy #{p}") if p }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end