getch 0.1.9 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +132 -0
  4. data/LICENSE +10 -0
  5. data/README.md +35 -29
  6. data/bin/getch +8 -6
  7. data/getch.gemspec +31 -0
  8. data/lib/clean.rb +149 -0
  9. data/lib/cryptsetup.rb +132 -0
  10. data/lib/devs.rb +199 -0
  11. data/lib/dracut/encrypt.rb +36 -0
  12. data/lib/dracut/hybrid.rb +15 -0
  13. data/lib/dracut/lvm.rb +14 -0
  14. data/lib/dracut/minimal.rb +11 -0
  15. data/lib/dracut/root.rb +45 -0
  16. data/lib/dracut/zfs.rb +35 -0
  17. data/lib/dracut.rb +11 -0
  18. data/lib/fstab/encrypt.rb +44 -0
  19. data/lib/fstab/hybrid.rb +34 -0
  20. data/lib/fstab/lvm.rb +25 -0
  21. data/lib/fstab/minimal.rb +6 -0
  22. data/lib/fstab/root.rb +93 -0
  23. data/lib/fstab/zfs.rb +23 -0
  24. data/lib/fstab.rb +11 -0
  25. data/lib/getch/assembly.rb +150 -0
  26. data/lib/getch/command.rb +88 -128
  27. data/lib/getch/config/account.rb +39 -0
  28. data/lib/getch/config/dhcp.rb +104 -0
  29. data/lib/getch/config/grub.rb +42 -0
  30. data/lib/getch/config/iwd.rb +60 -0
  31. data/lib/getch/config/keymap.rb +78 -0
  32. data/lib/getch/config/locale.rb +96 -0
  33. data/lib/getch/config/portage.rb +90 -0
  34. data/lib/getch/config/pre_network.rb +37 -0
  35. data/lib/getch/config/timezone.rb +52 -0
  36. data/lib/getch/config/void.rb +0 -36
  37. data/lib/getch/config.rb +16 -37
  38. data/lib/getch/device.rb +67 -0
  39. data/lib/getch/filesystem/ext4/encrypt/config.rb +9 -71
  40. data/lib/getch/filesystem/ext4/encrypt/deps.rb +15 -25
  41. data/lib/getch/filesystem/ext4/encrypt/device.rb +11 -5
  42. data/lib/getch/filesystem/ext4/encrypt/format.rb +6 -15
  43. data/lib/getch/filesystem/ext4/encrypt/mount.rb +7 -11
  44. data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -76
  45. data/lib/getch/filesystem/ext4/encrypt/void.rb +0 -38
  46. data/lib/getch/filesystem/ext4/encrypt.rb +2 -1
  47. data/lib/getch/filesystem/ext4/hybrid/config.rb +27 -0
  48. data/lib/getch/filesystem/ext4/hybrid/deps.rb +55 -0
  49. data/lib/getch/filesystem/ext4/hybrid/device.rb +24 -0
  50. data/lib/getch/filesystem/ext4/hybrid/format.rb +23 -0
  51. data/lib/getch/filesystem/ext4/hybrid/mount.rb +21 -0
  52. data/lib/getch/filesystem/ext4/hybrid/partition.rb +27 -0
  53. data/lib/getch/filesystem/{lvm/encrypt → ext4/hybrid}/void.rb +0 -39
  54. data/lib/getch/filesystem/ext4/hybrid.rb +19 -0
  55. data/lib/getch/filesystem/ext4/lvm/config.rb +25 -0
  56. data/lib/getch/filesystem/ext4/lvm/deps.rb +56 -0
  57. data/lib/getch/filesystem/ext4/lvm/device.rb +28 -0
  58. data/lib/getch/filesystem/ext4/lvm/format.rb +21 -0
  59. data/lib/getch/filesystem/ext4/lvm/mount.rb +21 -0
  60. data/lib/getch/filesystem/ext4/lvm/partition.rb +28 -0
  61. data/lib/getch/filesystem/{lvm.rb → ext4/lvm.rb} +6 -4
  62. data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
  63. data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +3 -1
  64. data/lib/getch/filesystem/ext4/minimal/device.rb +22 -0
  65. data/lib/getch/filesystem/ext4/minimal/format.rb +23 -0
  66. data/lib/getch/filesystem/ext4/minimal/mount.rb +21 -0
  67. data/lib/getch/filesystem/ext4/minimal/partition.rb +28 -0
  68. data/lib/getch/filesystem/ext4/minimal.rb +19 -0
  69. data/lib/getch/filesystem/ext4.rb +7 -7
  70. data/lib/getch/filesystem/zfs/encrypt/config.rb +10 -39
  71. data/lib/getch/filesystem/zfs/encrypt/deps.rb +4 -55
  72. data/lib/getch/filesystem/zfs/encrypt/device.rb +7 -51
  73. data/lib/getch/filesystem/zfs/encrypt/format.rb +6 -90
  74. data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -35
  75. data/lib/getch/filesystem/zfs/encrypt/partition.rb +6 -54
  76. data/lib/getch/filesystem/zfs/encrypt.rb +2 -1
  77. data/lib/getch/filesystem/zfs/minimal/config.rb +37 -0
  78. data/lib/getch/filesystem/zfs/minimal/deps.rb +126 -0
  79. data/lib/getch/filesystem/zfs/minimal/device.rb +24 -0
  80. data/lib/getch/filesystem/zfs/minimal/format.rb +23 -0
  81. data/lib/getch/filesystem/zfs/minimal/mount.rb +23 -0
  82. data/lib/getch/filesystem/zfs/minimal/partition.rb +23 -0
  83. data/lib/getch/filesystem/zfs/minimal.rb +19 -0
  84. data/lib/getch/filesystem/zfs.rb +1 -7
  85. data/lib/getch/filesystem.rb +0 -6
  86. data/lib/getch/gentoo/bootloader.rb +23 -44
  87. data/lib/getch/gentoo/finalize.rb +25 -0
  88. data/lib/getch/gentoo/post_config.rb +75 -0
  89. data/lib/getch/gentoo/pre_config.rb +37 -0
  90. data/lib/getch/gentoo/services.rb +18 -0
  91. data/lib/getch/gentoo/sources.rb +39 -33
  92. data/lib/getch/gentoo/tarball.rb +91 -0
  93. data/lib/getch/gentoo/terraform.rb +34 -0
  94. data/lib/getch/gentoo/update.rb +54 -0
  95. data/lib/getch/gentoo/use.rb +9 -6
  96. data/lib/getch/gentoo/use_flag.rb +17 -20
  97. data/lib/getch/gentoo.rb +9 -75
  98. data/lib/getch/guard.rb +3 -3
  99. data/lib/getch/helpers.rb +63 -115
  100. data/lib/getch/log.rb +87 -25
  101. data/lib/getch/options.rb +41 -11
  102. data/lib/getch/states.rb +28 -8
  103. data/lib/getch/tree.rb +56 -0
  104. data/lib/getch/version.rb +1 -1
  105. data/lib/getch/void/bootloader.rb +18 -0
  106. data/lib/getch/void/finalize.rb +31 -0
  107. data/lib/getch/void/post_config.rb +19 -0
  108. data/lib/getch/void/pre_config.rb +18 -0
  109. data/lib/getch/void/services.rb +18 -0
  110. data/lib/getch/void/{stage.rb → tarball.rb} +34 -14
  111. data/lib/getch/void/terraform.rb +28 -0
  112. data/lib/getch/void/update.rb +33 -0
  113. data/lib/getch/void.rb +9 -59
  114. data/lib/getch.rb +58 -90
  115. data/lib/luks.rb +239 -0
  116. data/lib/lvm2.rb +112 -0
  117. data/lib/mkfs/zfs.rb +167 -0
  118. data/lib/mkfs.rb +144 -0
  119. data/lib/mountfs.rb +154 -0
  120. data/lib/nito.rb +131 -0
  121. data/lib/sgdisk.rb +160 -0
  122. data.tar.gz.sig +0 -0
  123. metadata +113 -74
  124. metadata.gz.sig +0 -0
  125. data/lib/getch/config/gentoo.rb +0 -58
  126. data/lib/getch/filesystem/clean.rb +0 -58
  127. data/lib/getch/filesystem/device.rb +0 -63
  128. data/lib/getch/filesystem/ext4/config.rb +0 -62
  129. data/lib/getch/filesystem/ext4/deps.rb +0 -24
  130. data/lib/getch/filesystem/ext4/format.rb +0 -31
  131. data/lib/getch/filesystem/ext4/mount.rb +0 -26
  132. data/lib/getch/filesystem/ext4/partition.rb +0 -55
  133. data/lib/getch/filesystem/ext4/void.rb +0 -44
  134. data/lib/getch/filesystem/lvm/config.rb +0 -44
  135. data/lib/getch/filesystem/lvm/deps.rb +0 -44
  136. data/lib/getch/filesystem/lvm/device.rb +0 -45
  137. data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -74
  138. data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -49
  139. data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -48
  140. data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -35
  141. data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -27
  142. data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -84
  143. data/lib/getch/filesystem/lvm/encrypt.rb +0 -18
  144. data/lib/getch/filesystem/lvm/format.rb +0 -32
  145. data/lib/getch/filesystem/lvm/mount.rb +0 -26
  146. data/lib/getch/filesystem/lvm/partition.rb +0 -72
  147. data/lib/getch/filesystem/lvm/void.rb +0 -46
  148. data/lib/getch/filesystem/mount.rb +0 -63
  149. data/lib/getch/filesystem/partition.rb +0 -85
  150. data/lib/getch/filesystem/zfs/config.rb +0 -43
  151. data/lib/getch/filesystem/zfs/deps.rb +0 -67
  152. data/lib/getch/filesystem/zfs/device.rb +0 -66
  153. data/lib/getch/filesystem/zfs/encrypt/void.rb +0 -97
  154. data/lib/getch/filesystem/zfs/format.rb +0 -117
  155. data/lib/getch/filesystem/zfs/mount.rb +0 -47
  156. data/lib/getch/filesystem/zfs/partition.rb +0 -69
  157. data/lib/getch/filesystem/zfs/void.rb +0 -81
  158. data/lib/getch/gentoo/boot.rb +0 -64
  159. data/lib/getch/gentoo/chroot.rb +0 -75
  160. data/lib/getch/gentoo/config.rb +0 -167
  161. data/lib/getch/gentoo/stage.rb +0 -73
  162. data/lib/getch/void/boot.rb +0 -84
  163. data/lib/getch/void/chroot.rb +0 -56
  164. data/lib/getch/void/config.rb +0 -90
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46439ee6483306d467923074b461ad5df9d9f7a9a32981936952b586e85173f9
4
- data.tar.gz: e4232a6832086eafb46e9f29da73b461762c65c6232071cf2854c9ddb7680e2f
3
+ metadata.gz: 6e6d53101249982f83b05a372decd08d8967c52fc952b930dff7bf4d6c31634f
4
+ data.tar.gz: 3410eab0dff20d434691e6ddb7e5f8279c6a2eb70e4d675ac5791932638cb614
5
5
  SHA512:
6
- metadata.gz: 8689b833a86f39c1b5a310ed193e588399fed86384012015f04251d39175e3bd6121a7f65540086fc1556f831017a6d56467a3325ec29f78651295adcdd3ed23
7
- data.tar.gz: ac28be3804fddb3f995a8b86c438d447216547078855ca103ac4151a038934a9e7369a8a96500165b14ca38fdcac6ece31bbb5a1324e036b553ad76a0f456621
6
+ metadata.gz: d96be1666a606ef3eacd482bc539e75612844cf83406095113566901c42834e3e604d23908bbd87ab41b830c6fd1d6381a3ae36f04122c0b184dbebba192f0f8
7
+ data.tar.gz: 9ff7cb0caa78084a6bc04a6e72acec5c582e17191473583ffd0fcf9401e9275b9ae8ed9e59f68e49be0a4477f78b941348bba550c7b3d6e99b7181725b08bad9
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,132 @@
1
+ ## 0.3.2, release 2022-10-01
2
+ * Support disk with a sector size of 512.
3
+ * Support vdx disk.
4
+
5
+ ## 0.3.0, release 2022-02-17
6
+ * Gentoo with musl use an additional repo https://github.com/gentoo/musl.git.
7
+ * Gentoo use the kernel `sys-kernel/gentoo-kernel-bin` to install more quickly.
8
+ * No more need to enter password twice with Grub and encrypted system.
9
+ * Can restart the whole installation from scratch with the option `--restart`
10
+ * ZFS create pool with disk id `/dev/disk/by-id`.
11
+ * New option `--lvm` instead of `-f lvm`.
12
+ * Rename option `-z | --zoneinfo` for `-t | --timezone`. Default use `UTC`.
13
+ * Use a generic hostname `host` rather than '{os}-hatch-{randomID}'
14
+ * Musl can be installed with the `--musl` option.
15
+ * Use colors in the script, look better.
16
+
17
+ ## 0.1.9, release 2022-01-26
18
+ * Gentoo use now the kernel `sys-kernel/gentoo-kernel` [project](https://wiki.gentoo.org/wiki/Project:Distribution_Kernel), updates are automatic.
19
+ * Correct the download of the `rootfs tarball` for VoidLinux.
20
+ * ZFS now import pool by ID.
21
+ * ZFS use the cmdline `zfs_arc_max` to limit the max Memory used.
22
+ * Gentoo and Void use `Dracut`, remove `Genkernel`.
23
+ * Gentoo use PAM sha512 with `libpwquality` for the authentication.
24
+ * Add the code linter Rubocop, correct around 1.5k lines of code.
25
+
26
+ ## 0.1.6, release 2021-06-30
27
+ + Getch can also install [Void Linux](https://voidlinux.org/).
28
+ + New option `-o|--os NAME`, work only with NAME = gentoo | void.
29
+ + ZFS write the hostid with `zgenhostid $(hostid)`
30
+ + Add a systctl.conf to enforce TCP/IP stack hardened.
31
+ + README improved.
32
+ + More close of the community standard [github](https://github.com/szorfein/getch/community).
33
+
34
+ ## 0.1.4, release 2021-06-20
35
+ * Install `iptables` by default.
36
+ * Control input for options `--disk`, `--format`, `--zoneinfo`, `--keymap`.
37
+ * Add a `/etc/portage/bashrc` to automatically signing kernel modules with `emerge`.
38
+ * Now clean properly another disk used with option `--separate-x DISK`.
39
+ * For ZFS, use `blockdev --getpbsz` to find correct bloc (sector) size.
40
+ * Populate `/etc/modules-load.d/` with modules found with `lsmod` (only few wifi's, flash usb related (ehci, ohci, xhci, etc)).
41
+ * Remove the package `dev-util/dwarves`.
42
+
43
+ ## 0.1.3, release 2021-05-17
44
+ * LVM use the format /dev/vg_name/lv_name for mount/format/fstab.
45
+ * Stop using `euse` from `gentoolkit`, use native Ruby code here.
46
+ * Optimization on package installation, they shouln't be installed more than once.
47
+ * Regroup use flags under Getch::Gentoo::UseFlag.
48
+ * Upd Bask v0.5 (zstd compression, better support for wifi...)
49
+ * Config for systemd-resolved, enable DNS over TLS with Quad9 (9.9.9.9)
50
+ * Add configs for systemd-network with DHCP for wifi and ethernet.
51
+ * Correct permissions (/home/[user] and /etc/portage)
52
+
53
+ ## 0.1.2, release 2021-05-12
54
+ * DOCS update.
55
+ * Keep Nano for those who need :)
56
+ * ZFS use the last version >=2.0 with kernel stable =5.10
57
+ * ZFS create a Log device and Cache device if getch is used with `--separate-cache`.
58
+ * GRUB or Systemd-boot can now be installed on separate disk with `--separate-boot`.
59
+ * Adding flag for ZFS `-o autotrim=on` (used with `zpool create`).
60
+ * Encrypted swap use: `cipher=aes-xts-plain64:sha256,size=512` by default.
61
+ * In the make.conf: add `-fomit-frame-pointer`, designed to reduce generated code size.
62
+
63
+ ## 0.1.1, release 2020-11-01
64
+ * Change mountpoint for the esp at /efi rather than /boot/efi
65
+ * Replace Garden by Bask https://github.com/szorfein/bask
66
+ * Correct option --username USERNAME, do not create a new partition.
67
+ * New set of options --separate-{boot,cache,home} to install them on another disk
68
+ * Refactor codes
69
+ * Add cpu name to COMMON_FLAGS
70
+ * Add cpuflags with app-portage/cpuid2cpuflags
71
+ + Use the whole disk space available for / when option --username is unset
72
+
73
+ ## 0.1.0, release 2020-10-15
74
+ * Add the (Zeta) filesystem ZFS
75
+ * `emerge --depclean` to save space.
76
+ * Add a message when getch have finish, keep /mnt/gentoo if you need to add something.
77
+ * Use systemd-detect-virt to detect a Virtual Guest.
78
+
79
+ ## 0.0.9, release 2020-10-03
80
+ * Add encryption on ext4 and lvm (BIOS,UEFI)
81
+ * Correct KEYMAP="yes" with genkernel
82
+ * Renaming option keyboard with keymap
83
+ * GPG verification for ebuild
84
+
85
+ ## 0.0.8, release 2020-09-30
86
+ * Adding LVM via the option fs, `--fs lvm`.
87
+ * Systemd-boot use the value of PARTUUID without initramfs.
88
+ * Include lib logger.
89
+ * Enhance functions to call program system Emerge, Make, ...
90
+
91
+ ## 0.0.7, release 2020-09-22
92
+ * Correct fstab.
93
+ * Repair GRUB/fstab for BIOS system, add secure cmdline.
94
+ * Create a swap volume equal to the memory installed.
95
+ * Add vim and sudo
96
+
97
+ ## 0.0.6, release 2020-09-19
98
+ * Add support for QEMU guest with KVM and Virtio driver
99
+ * Kernel compilation, initialize a config file with `make localyesconfig`.
100
+ * More modular codes to start with encryption and other filesystems.
101
+ * Add the new option --verbose to display output of compilation, etc...
102
+
103
+ ## 0.0.5, release 2020-09-17
104
+ * Generate a hostname
105
+ * Configure systemd-boot for UEFI system
106
+
107
+ ## 0.0.4, release 2020-09-16
108
+ * Boot on a BIOS system with VirtualBox
109
+ * Install Grub
110
+ * Create user
111
+ * Create passwd for root and user
112
+ * Check lsmod to install deps (like wpa_supplicant) and patch the kernel
113
+
114
+ ## 0.0.3, release 2020-09-14
115
+ * Add dhcpcd, gentoo-sources, linux-firmware
116
+ * Kernel build by using https://github.com/szorfein/garden
117
+ * Populate /etc/portage (/etc/portage/package.{use,unmask,accept_keywords}/zzz_via_autounmask)
118
+ * Download all the lastest ebuild via emerge-webrsync
119
+ * Update gentoo via emerge -uDN @world
120
+
121
+ ## 0.0.2, release 2020-09-12
122
+ * Getch genere a file /tmp/install_gentoo to avoid to remake same task over and over
123
+ * Support for ext4
124
+ * Mount partition on /mnt/gentoo during the install
125
+ * Download, verify the checksum and decompress the last stage3-amd64-systemd
126
+
127
+ ## 0.0.1, release 2020-09-10
128
+ * Partition disk (at least 15G required) with sgdisk (create /boot, /, /home, and swap)
129
+ * Support for one disk with -d|--disk
130
+ * Add few options for the CLI
131
+ * Add bin/setup.sh to install ruby when boot on a ISO file
132
+ * Init project
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 szorfein
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Gem Version](https://badge.fury.io/rb/getch.svg)](https://badge.fury.io/rb/getch)
7
7
  ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/szorfein/getch/Rubocop/develop)
8
8
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
9
- ![GitHub](https://img.shields.io/github/license/szorfein/ardecy)
9
+ ![GitHub](https://img.shields.io/github/license/szorfein/getch)
10
10
 
11
11
  </div>
12
12
 
@@ -22,11 +22,12 @@ Hardened System:
22
22
  + sysctl.conf with TCP/IP stack hardening and more [Arch](https://wiki.archlinux.org/title/Sysctl)
23
23
  + Kernel parameters enforced (dmesg restricted, kexec disabled, etc)
24
24
  + Kernel source (Gentoo) patched with [bask](https://github.com/szorfein/bask).
25
+ + Musl optionnal
25
26
 
26
27
  ## Description
27
- Actually, Getch support only the `x86_64` architecture and only with the following archives:
28
- + **Gentoo**: `stage3-amd64-systemd` [Gentoo](https://www.gentoo.org/downloads/).
29
- + **Void**: `rootfs glibc` [Void](https://voidlinux.org/download/).
28
+ Actually, Getch support only the `x86_64` architecture with the following archives:
29
+ + **Gentoo**: `stage3-amd64-systemd` or `stage3-amd64-musl` [Gentoo](https://www.gentoo.org/downloads/).
30
+ + **Void**: `rootfs tarball glibc` or `rootfs tarball musl` [Void](https://voidlinux.org/download/).
30
31
 
31
32
  Filesystem supported (with or without encryption)
32
33
  + Ext4
@@ -34,13 +35,15 @@ Filesystem supported (with or without encryption)
34
35
  + ZFS
35
36
 
36
37
  Boot Manager:
37
- + **Gentoo**: `BIOS` will use `Grub2` and `systemd-boot` for `UEFI`.
38
- + **Void**: use only Grub2, encryption for the root fs use luks1.
38
+ + **Gentoo**: `BIOS` and `musl` will use `Grub2` and `systemd-boot` for `UEFI`.
39
+ + **Void**: use only Grub2.
39
40
 
40
41
  The ISO images i was able to test and that works:
41
42
  + [Archlinux](https://www.archlinux.org/download/)
42
43
  + [Archaeidae](https://github.com/szorfein/archaeidae): Custom Archiso that includes ZFS support.
43
44
 
45
+ You can also use your current `linux` host, just pay attention to the disk that will be used.
46
+
44
47
  ## Dependencies
45
48
  Getch is build without external libs, so it only require `ruby >= 2.5`.
46
49
 
@@ -71,11 +74,11 @@ For a french user:
71
74
 
72
75
  Install Gentoo on LVM and use a different root disk `/dev/sdc`
73
76
 
74
- # getch --format lvm --disk sdc
77
+ # getch --format ext4 --lvm --disk sdc
75
78
 
76
79
  Encrypt your disk with LVM with a french keymap
77
80
 
78
- # getch --format lvm --encrypt --keymap fr
81
+ # getch --format ext4 --lvm --encrypt --keymap fr
79
82
 
80
83
  Encrypt with ext4 and create a new user `ninja`:
81
84
 
@@ -85,9 +88,9 @@ With ZFS, if used with `--encrypt`, it use the native ZFS encryption:
85
88
 
86
89
  # getch --format zfs
87
90
 
88
- With `Void Linux`:
91
+ With `Void Linux` and `Musl` enable:
89
92
 
90
- # getch --os void --encrypt -k fr
93
+ # getch --os void --encrypt -k fr --musl
91
94
 
92
95
  ## Troubleshooting
93
96
 
@@ -98,33 +101,36 @@ If a old volume group exist, `getch` may fail to partition your disk. You have t
98
101
  # vgremove -f vg0
99
102
  # pvremove -f /dev/sdb
100
103
 
101
- #### Encryption enable on BIOS with ext4
102
- To decrypt your disk on BIOS system, you have to enter your password twice. One time for Grub and another time for Genkernel. [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
103
- Also with GRUB, only a `us` keymap is working.
104
+ #### Encryption with GRUB
105
+ To decrypt your disk on GRUB, only the `us` keymap is working for now.
104
106
 
105
- #### ZFS for Void Linux - Enable the boot pool
106
- You have some extras step to do after booting to enable the boot pool, you need this pool when you update your system. It's used mainly by Grub and Dracut.
107
- By default, your /boot is empty because your boot pool is not imported...
107
+ #### ZFS with Grub
108
+ By default, if you use ZFS with `musl` or `voidlinux` the `/boot` partition is not mounted automatically, so before an update, mout the partition.
108
109
 
109
- # zpool import -f -d /dev/disk/by-id -N bpool-150ed
110
- # zfs mount bpool-150ed/BOOT/void
110
+ # zpool status
111
+ # zfs mount bpool/BOOT/void
111
112
  # ls /boot
112
113
 
113
- You should see something in the boot (initramfs, vmlinuz).. Recreate the initramfs.
114
-
115
- # xbps-reconfigure -fa
116
-
117
- Make the `bpool` available at the boot:
118
-
119
- # zfs set canmount=on bpool-150ed/BOOT/void
114
+ #### ZFS with and without encryption
115
+ First time on ZFS after 5min
120
116
 
121
- And reboot, the `/boot` partition should be mounted automatically after that.
117
+ ```txt
118
+ dracut Warning: /dev/disk/by-uuid/<DISK> does not exist
119
+ ```
122
120
 
123
- #### ZFS Encrypted with Void
124
- Well, another weird issue, the first time you boot on your encrypted pool, nothing append. Dracut try to mount inexistent device. Just wait for enter in the shell:
121
+ Dracut try to mount inexistent device. Just wait for enter in the shell and remove the disk uuid from `/lib/dracut/hooks/initqueue/finished/`
125
122
 
126
123
  # ls /lib/dracut/hooks/initqueue/finished/*
127
124
  # rm /lib/dracut/hooks/initqueue/finished/dev*
128
125
  # exit
129
126
 
130
- Dracut should finally start `mount-zfs.sh` and ask for your password. After you first login, follow instructions above for recompile the initramfs and mount the boot pool and your good.
127
+ Dracut should finally start `mount-zfs.sh` and ask for a password if encrypted. After you first login, mount the `/boot` partition and recompile the initramfs and your good.
128
+
129
+ + For Gentoo: `emerge --config sys-kernel/gentoo-kernel-bin`
130
+ + For Voidlinux: `xbps-reconfigure -fa`
131
+
132
+ If it doesn't work, try to start script manually (always in the shell):
133
+
134
+ # . /lib/dracut/hooks/mount/98-mount-zsh.sh
135
+ # . /lib/dracut/hooks/mount/99-mount-root.sh
136
+ # exit
data/bin/getch CHANGED
@@ -3,15 +3,17 @@
3
3
  require 'getch'
4
4
 
5
5
  getch = Getch::Main.new(
6
- :cli => Getch::Options.new(ARGV)
6
+ cli: Getch::Options.new(ARGV)
7
7
  )
8
8
 
9
9
  getch.resume
10
10
 
11
- getch.partition
12
- getch.format
13
- getch.mount
11
+ getch.prepare_disk
14
12
 
15
- getch.install
13
+ getch.install_system
16
14
 
17
- getch.configure
15
+ getch.terraform
16
+
17
+ getch.bootloader
18
+
19
+ getch.finalize
data/getch.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/lib/getch/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'getch'
5
+ s.version = Getch::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.summary = 'A CLI tool to install Gentoo or VoidLinux.'
8
+ s.author = 'szorfein'
9
+ s.email = ['szorfein@protonmail.com']
10
+ s.homepage = 'https://github.com/szorfein/getch'
11
+ s.metadata = {
12
+ 'source_code_uri' => 'https://github.com/szorfein/getch',
13
+ 'changelog_uri' => 'https://github.com/szorfein/getch/blob/master/CHANGELOG.md',
14
+ 'bug_tracker_uri' => 'https://github.com/szorfein/getch/issues',
15
+ 'wiki_uri' => 'https://github.com/szorfein/getch'
16
+ }
17
+ s.license = 'MIT'
18
+ s.required_ruby_version = '>= 2.5.0'
19
+
20
+ s.files = Dir.glob('{assets,lib}/**/*', File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
21
+
22
+ s.files += %w[CHANGELOG.md LICENSE README.md]
23
+ s.files += %w[getch.gemspec]
24
+
25
+ s.bindir = 'bin'
26
+ s.executables << 'getch'
27
+ s.require_paths = ['lib']
28
+
29
+ s.cert_chain = ['certs/szorfein.pem']
30
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
31
+ end
data/lib/clean.rb ADDED
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nito'
4
+ require_relative 'getch/command'
5
+ require_relative 'getch/log'
6
+
7
+ class Clean
8
+ include NiTo
9
+
10
+ def initialize(args)
11
+ @root = args[:disk] ||= nil
12
+ @boot = args[:boot_disk] ||= nil
13
+ @home = args[:home_disk] ||= nil
14
+ @cache = args[:cache_disk] ||= nil
15
+ @vg = args[:vg_name] ||= nil
16
+ @luks = args[:luks_name] ||= nil
17
+ @zfs = args[:zfs_name] ||= 'pool'
18
+ @log = Getch::Log.new
19
+ @mountpoint = args[:mountpoint] ||= '/mnt/getch'
20
+ end
21
+
22
+ def x
23
+ umount_all
24
+ swap_off
25
+ disable_lvs
26
+ cryptsetup_close
27
+ old_zfs
28
+ old_lvm
29
+ zap_all @root, @boot, @home, @cache
30
+ wipe_all @root, @boot, @home, @cache
31
+ dd
32
+ end
33
+
34
+ protected
35
+
36
+ def umount_all
37
+ paths = []
38
+ File.open('/proc/mounts').each do |l|
39
+ tmp = l.split(' ') if l =~ /#{@mountpoint}/
40
+ tmp && paths << tmp[1]
41
+ end
42
+ paths.each { |p| umount_r p }
43
+ umount '/tmp/boot'
44
+ end
45
+
46
+ def swap_off
47
+ swapoff @root
48
+ File.exist?("/dev/#{@vg}/swap") && swapoff_dm("#{@vg}-swap")
49
+ end
50
+
51
+ def disable_lvs
52
+ lvchange_n 'home'
53
+ lvchange_n 'swap'
54
+ lvchange_n 'root'
55
+ end
56
+
57
+ def cryptsetup_close
58
+ close "boot-#{@luks}"
59
+ close "root-#{@luks}"
60
+ close "home-#{@luks}"
61
+ end
62
+
63
+ def old_zfs
64
+ return unless File.exist? '/usr/bin/zpool'
65
+
66
+ destroy_zpool "b#{@zfs}"
67
+ destroy_zpool "r#{@zfs}"
68
+ cmd "rm -rf #{@mountpoint}/*" if Dir.exist? @mountpoint
69
+ end
70
+
71
+ def destroy_zpool(name)
72
+ if system("zpool list | grep #{name}")
73
+ cmd "zpool destroy -f #{name}"
74
+ end
75
+ end
76
+
77
+ def old_lvm
78
+ lvm = `lvs | grep #{@vg}`
79
+ lvm.match?(/#{@vg}/) || return
80
+
81
+ vgremove
82
+ pvremove @root, @home, @cache
83
+ end
84
+
85
+ def zap_all(*devs)
86
+ devs.each { |d| zap(d) }
87
+ end
88
+
89
+ def wipe_all(*devs)
90
+ devs.each { |d| wipe(d) }
91
+ end
92
+
93
+ def dd
94
+ cmd "dd if=/dev/zero of=/dev/#{@root} bs=1M count=100"
95
+ end
96
+
97
+ private
98
+
99
+ def wipe(dev)
100
+ dev || return
101
+
102
+ cmd "wipefs --all /dev/#{dev}"
103
+ end
104
+
105
+ def umount_r(dir)
106
+ dir || return
107
+
108
+ cmd 'umount', '-R', dir if mount? dir
109
+ end
110
+
111
+ def zap(dev)
112
+ dev || return
113
+
114
+ cmd 'sgdisk', '-Z', "/dev/#{dev}"
115
+ end
116
+
117
+ def lvchange_n(name)
118
+ return unless File.exist? "/dev/#{@vg}/#{name}"
119
+
120
+ cmd 'lvchange', '-an', "/dev/#{@vg}/#{name}"
121
+ end
122
+
123
+ def close(name)
124
+ return unless File.exist? "/dev/mapper/#{name}"
125
+
126
+ cmd 'cryptsetup', 'close', name
127
+ end
128
+
129
+ def vgremove
130
+ cmd 'vgremove', '-y', @vg
131
+ end
132
+
133
+ def pvremove(*devs)
134
+ devs.each { |d| pvdel(d) }
135
+ end
136
+
137
+ def pvdel(dev)
138
+ dev || return
139
+
140
+ disk = dev[/[a-z]*/]
141
+ disk.match?(/[a-z]{3}/) || @log.fatal("pvdel - No disk #{dev} - #{disk}")
142
+
143
+ cmd 'pvremove', '-f', "/dev/#{disk}*"
144
+ end
145
+
146
+ def cmd(*args)
147
+ Getch::Command.new(args)
148
+ end
149
+ end
data/lib/cryptsetup.rb ADDED
@@ -0,0 +1,132 @@
1
+ require 'luks'
2
+
3
+ class CryptSetup
4
+ def initialize(devs, options)
5
+ @boot = devs[:boot]
6
+ @root = devs[:root]
7
+ @home = devs[:home]
8
+ @swap = devs[:swap] ||= nil
9
+ @options = options
10
+ @luks = options[:luks_name]
11
+ @vg = options[:vg_name]
12
+ @fs = options[:fs] ||= 'ext4'
13
+ @mountpoint = options[:mountpoint] ||= '/mnt/getch'
14
+ end
15
+
16
+ def format
17
+ format_boot
18
+ format_root
19
+ format_home
20
+ end
21
+
22
+ def keys
23
+ add_boot_key
24
+ add_root_key
25
+ add_home_key
26
+ end
27
+
28
+ def configs
29
+ config_boot
30
+ config_root
31
+ config_home
32
+ config_swap
33
+ end
34
+
35
+ def swap_conf
36
+ config_swap
37
+ end
38
+
39
+ protected
40
+
41
+ def format_boot
42
+ luks = Luks::Boot.new(@boot, @options)
43
+ luks.encrypt
44
+ luks.open
45
+ luks.format
46
+ luks.mount
47
+ end
48
+
49
+ # if boot and root are on the same device, we encrypt root with a key
50
+ def format_root
51
+ if @boot.split(/[0-9]/) == @root.split(/[0-9]/)
52
+ root_with_key
53
+ else
54
+ root_with_pass
55
+ end
56
+ end
57
+
58
+ def format_home
59
+ @home || return
60
+
61
+ home_with_pass
62
+ end
63
+
64
+ def add_boot_key
65
+ luks = Luks::Boot.new(@boot, @options)
66
+ luks.external_key
67
+ end
68
+
69
+ # Alrealy used key if they have same disk
70
+ def add_root_key
71
+ return if @boot.split(/[0-9]/) == @root.split(/[0-9]/)
72
+
73
+ luks = Luks::Root.new(@root, @options)
74
+ luks.external_key
75
+ end
76
+
77
+ def add_home_key
78
+ @home || return
79
+
80
+ luks = Luks::Home.new(@home, @options)
81
+ luks.external_key
82
+ end
83
+
84
+ def config_boot
85
+ return if not @boot or @options[:fs] == 'zfs'
86
+
87
+ Luks::Boot.new(@boot, @options).write_config
88
+ end
89
+
90
+ def config_root
91
+ @root || return
92
+
93
+ Luks::Root.new(@root, @options).write_config
94
+ end
95
+
96
+ def config_home
97
+ @home || return
98
+
99
+ Luks::Home.new(@home, @options).write_config
100
+ end
101
+
102
+ def config_swap
103
+ uuid = @options[:lvm] ? '' : Getch::Helpers.uuid(@swap)
104
+ line = "swap-#{@luks}"
105
+ @options[:lvm] ?
106
+ line << " /dev/#{@vg}/swap" :
107
+ line << " UUID=#{uuid}"
108
+
109
+ line << " /dev/urandom swap,discard,cipher=aes-xts-plain64:sha256,size=512"
110
+ NiTo.echo_a "#{@mountpoint}/etc/crypttab", line
111
+ end
112
+
113
+ private
114
+
115
+ def root_with_key
116
+ luks = Luks::Root.new(@root, @options)
117
+ luks.encrypt_with_key
118
+ luks.open_with_key
119
+ end
120
+
121
+ def root_with_pass
122
+ luks = CryptSetup::Root.new(@root, @options)
123
+ luks.encrypt
124
+ luks.open
125
+ end
126
+
127
+ def home_with_pass
128
+ luks = CryptSetup::Home.new(@home, @options)
129
+ luks.encrypt
130
+ luks.open
131
+ end
132
+ end