getch 0.1.9 → 0.3.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +35 -29
- data/bin/getch +8 -6
- data/lib/clean.rb +149 -0
- data/lib/cryptsetup.rb +132 -0
- data/lib/devs.rb +199 -0
- data/lib/dracut/encrypt.rb +36 -0
- data/lib/dracut/hybrid.rb +15 -0
- data/lib/dracut/lvm.rb +14 -0
- data/lib/dracut/minimal.rb +11 -0
- data/lib/dracut/root.rb +45 -0
- data/lib/dracut/zfs.rb +35 -0
- data/lib/dracut.rb +11 -0
- data/lib/fstab/encrypt.rb +44 -0
- data/lib/fstab/hybrid.rb +34 -0
- data/lib/fstab/lvm.rb +25 -0
- data/lib/fstab/minimal.rb +6 -0
- data/lib/fstab/root.rb +93 -0
- data/lib/fstab/zfs.rb +23 -0
- data/lib/fstab.rb +11 -0
- data/lib/getch/assembly.rb +150 -0
- data/lib/getch/command.rb +88 -128
- data/lib/getch/config/account.rb +39 -0
- data/lib/getch/config/dhcp.rb +104 -0
- data/lib/getch/config/grub.rb +42 -0
- data/lib/getch/config/iwd.rb +60 -0
- data/lib/getch/config/keymap.rb +78 -0
- data/lib/getch/config/locale.rb +96 -0
- data/lib/getch/config/portage.rb +90 -0
- data/lib/getch/config/pre_network.rb +37 -0
- data/lib/getch/config/timezone.rb +52 -0
- data/lib/getch/config/void.rb +0 -36
- data/lib/getch/config.rb +16 -37
- data/lib/getch/device.rb +67 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +9 -71
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +15 -25
- data/lib/getch/filesystem/ext4/encrypt/device.rb +11 -5
- data/lib/getch/filesystem/ext4/encrypt/format.rb +6 -15
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +7 -11
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -76
- data/lib/getch/filesystem/ext4/encrypt/void.rb +0 -38
- data/lib/getch/filesystem/ext4/encrypt.rb +2 -1
- data/lib/getch/filesystem/ext4/hybrid/config.rb +27 -0
- data/lib/getch/filesystem/ext4/hybrid/deps.rb +55 -0
- data/lib/getch/filesystem/ext4/hybrid/device.rb +24 -0
- data/lib/getch/filesystem/ext4/hybrid/format.rb +23 -0
- data/lib/getch/filesystem/ext4/hybrid/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/hybrid/partition.rb +27 -0
- data/lib/getch/filesystem/{lvm/encrypt → ext4/hybrid}/void.rb +0 -39
- data/lib/getch/filesystem/ext4/hybrid.rb +19 -0
- data/lib/getch/filesystem/ext4/lvm/config.rb +25 -0
- data/lib/getch/filesystem/ext4/lvm/deps.rb +56 -0
- data/lib/getch/filesystem/ext4/lvm/device.rb +28 -0
- data/lib/getch/filesystem/ext4/lvm/format.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/lvm/partition.rb +28 -0
- data/lib/getch/filesystem/{lvm.rb → ext4/lvm.rb} +6 -4
- data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
- data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +3 -1
- data/lib/getch/filesystem/ext4/minimal/device.rb +22 -0
- data/lib/getch/filesystem/ext4/minimal/format.rb +23 -0
- data/lib/getch/filesystem/ext4/minimal/mount.rb +21 -0
- data/lib/getch/filesystem/ext4/minimal/partition.rb +28 -0
- data/lib/getch/filesystem/ext4/minimal.rb +19 -0
- data/lib/getch/filesystem/ext4.rb +7 -7
- data/lib/getch/filesystem/zfs/encrypt/config.rb +10 -39
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +4 -55
- data/lib/getch/filesystem/zfs/encrypt/device.rb +7 -51
- data/lib/getch/filesystem/zfs/encrypt/format.rb +6 -90
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -35
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +6 -54
- data/lib/getch/filesystem/zfs/encrypt.rb +2 -1
- data/lib/getch/filesystem/zfs/minimal/config.rb +37 -0
- data/lib/getch/filesystem/zfs/minimal/deps.rb +126 -0
- data/lib/getch/filesystem/zfs/minimal/device.rb +24 -0
- data/lib/getch/filesystem/zfs/minimal/format.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/mount.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal/partition.rb +23 -0
- data/lib/getch/filesystem/zfs/minimal.rb +19 -0
- data/lib/getch/filesystem/zfs.rb +1 -7
- data/lib/getch/filesystem.rb +0 -6
- data/lib/getch/gentoo/bootloader.rb +23 -44
- data/lib/getch/gentoo/finalize.rb +25 -0
- data/lib/getch/gentoo/post_config.rb +75 -0
- data/lib/getch/gentoo/pre_config.rb +37 -0
- data/lib/getch/gentoo/services.rb +18 -0
- data/lib/getch/gentoo/sources.rb +39 -33
- data/lib/getch/gentoo/tarball.rb +91 -0
- data/lib/getch/gentoo/terraform.rb +34 -0
- data/lib/getch/gentoo/update.rb +54 -0
- data/lib/getch/gentoo/use.rb +9 -6
- data/lib/getch/gentoo/use_flag.rb +17 -20
- data/lib/getch/gentoo.rb +9 -75
- data/lib/getch/guard.rb +2 -2
- data/lib/getch/helpers.rb +63 -115
- data/lib/getch/log.rb +87 -25
- data/lib/getch/options.rb +41 -11
- data/lib/getch/states.rb +28 -8
- data/lib/getch/tree.rb +56 -0
- data/lib/getch/version.rb +1 -1
- data/lib/getch/void/bootloader.rb +18 -0
- data/lib/getch/void/finalize.rb +31 -0
- data/lib/getch/void/post_config.rb +19 -0
- data/lib/getch/void/pre_config.rb +18 -0
- data/lib/getch/void/services.rb +18 -0
- data/lib/getch/void/{stage.rb → tarball.rb} +34 -14
- data/lib/getch/void/terraform.rb +28 -0
- data/lib/getch/void/update.rb +33 -0
- data/lib/getch/void.rb +9 -59
- data/lib/getch.rb +58 -90
- data/lib/luks.rb +239 -0
- data/lib/lvm2.rb +112 -0
- data/lib/mkfs/zfs.rb +167 -0
- data/lib/mkfs.rb +140 -0
- data/lib/mountfs.rb +154 -0
- data/lib/nito.rb +131 -0
- data/lib/sgdisk.rb +160 -0
- data.tar.gz.sig +0 -0
- metadata +83 -47
- metadata.gz.sig +0 -0
- data/lib/getch/config/gentoo.rb +0 -58
- data/lib/getch/filesystem/clean.rb +0 -58
- data/lib/getch/filesystem/device.rb +0 -63
- data/lib/getch/filesystem/ext4/config.rb +0 -62
- data/lib/getch/filesystem/ext4/deps.rb +0 -24
- data/lib/getch/filesystem/ext4/format.rb +0 -31
- data/lib/getch/filesystem/ext4/mount.rb +0 -26
- data/lib/getch/filesystem/ext4/partition.rb +0 -55
- data/lib/getch/filesystem/ext4/void.rb +0 -44
- data/lib/getch/filesystem/lvm/config.rb +0 -44
- data/lib/getch/filesystem/lvm/deps.rb +0 -44
- data/lib/getch/filesystem/lvm/device.rb +0 -45
- data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -74
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -49
- data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -48
- data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -35
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -27
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -84
- data/lib/getch/filesystem/lvm/encrypt.rb +0 -18
- data/lib/getch/filesystem/lvm/format.rb +0 -32
- data/lib/getch/filesystem/lvm/mount.rb +0 -26
- data/lib/getch/filesystem/lvm/partition.rb +0 -72
- data/lib/getch/filesystem/lvm/void.rb +0 -46
- data/lib/getch/filesystem/mount.rb +0 -63
- data/lib/getch/filesystem/partition.rb +0 -85
- data/lib/getch/filesystem/zfs/config.rb +0 -43
- data/lib/getch/filesystem/zfs/deps.rb +0 -67
- data/lib/getch/filesystem/zfs/device.rb +0 -66
- data/lib/getch/filesystem/zfs/encrypt/void.rb +0 -97
- data/lib/getch/filesystem/zfs/format.rb +0 -117
- data/lib/getch/filesystem/zfs/mount.rb +0 -47
- data/lib/getch/filesystem/zfs/partition.rb +0 -69
- data/lib/getch/filesystem/zfs/void.rb +0 -81
- data/lib/getch/gentoo/boot.rb +0 -64
- data/lib/getch/gentoo/chroot.rb +0 -75
- data/lib/getch/gentoo/config.rb +0 -167
- data/lib/getch/gentoo/stage.rb +0 -73
- data/lib/getch/void/boot.rb +0 -84
- data/lib/getch/void/chroot.rb +0 -56
- data/lib/getch/void/config.rb +0 -90
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Ext4
|
|
6
|
-
class Partition < Getch::FileSystem::Ext4::Device
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
9
|
-
@state = Getch::States.new
|
|
10
|
-
@clean = Getch::FileSystem::Clean
|
|
11
|
-
@partition = Getch::FileSystem::Partition.new
|
|
12
|
-
run_partition
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def run_partition
|
|
16
|
-
return if STATES[:partition ]
|
|
17
|
-
|
|
18
|
-
@clean.hdd(@disk)
|
|
19
|
-
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
|
20
|
-
if Helpers.efi?
|
|
21
|
-
partition_efi
|
|
22
|
-
else
|
|
23
|
-
partition_bios
|
|
24
|
-
end
|
|
25
|
-
@state.partition
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
|
31
|
-
def partition_efi
|
|
32
|
-
# /efi - EFI system partition - 260MB
|
|
33
|
-
# swap - Linux Swap - size of the ram
|
|
34
|
-
# / - Root
|
|
35
|
-
# /home - Home
|
|
36
|
-
@partition.efi(@dev_esp)
|
|
37
|
-
@partition.swap(@dev_swap)
|
|
38
|
-
@partition.root(@dev_root, '8304')
|
|
39
|
-
@partition.home(@dev_home, '8302') if @dev_home
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def partition_bios
|
|
43
|
-
# None - Bios Boot Partition - 1MiB
|
|
44
|
-
# / - Root
|
|
45
|
-
# swap - Linux Swap - size of the ram
|
|
46
|
-
# /home - Home
|
|
47
|
-
@partition.gpt(@dev_gpt)
|
|
48
|
-
@partition.swap(@dev_swap)
|
|
49
|
-
@partition.root(@dev_root, '8304')
|
|
50
|
-
@partition.home(@dev_home, '8302') if @dev_home
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Ext4
|
|
6
|
-
class Void < Device
|
|
7
|
-
include Helpers::Void
|
|
8
|
-
|
|
9
|
-
attr_reader :boot_disk
|
|
10
|
-
|
|
11
|
-
def fstab
|
|
12
|
-
conf = "#{MOUNTPOINT}/etc/fstab"
|
|
13
|
-
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
|
14
|
-
line_fstab(@dev_esp, '/efi vfat noauto,rw,relatime 0 0') if @dev_esp
|
|
15
|
-
line_fstab(@dev_swap, 'swap swap rw,noatime,discard 0 0') if @dev_swap
|
|
16
|
-
line_fstab(@dev_root, '/ ext4 rw,relatime 0 1')
|
|
17
|
-
add_line(conf, 'tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def config_dracut
|
|
21
|
-
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/ext4.conf"
|
|
22
|
-
# dracut: value+= should be surrounding by white space
|
|
23
|
-
content = [
|
|
24
|
-
"hostonly=\"yes\"",
|
|
25
|
-
"omit_dracutmodules+=\" btrfs lvm \"",
|
|
26
|
-
""
|
|
27
|
-
]
|
|
28
|
-
File.write(conf, content.join("\n"), mode: 'w', chmod: 0644)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def kernel_cmdline_dracut
|
|
32
|
-
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
33
|
-
c="kernel_cmdline=\"root=#{@dev_root} rootfstype=ext4 rootflags=rw,relatime\""
|
|
34
|
-
File.write(conf, "#{c}\n", mode: 'w', chmod: 0644)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def finish
|
|
38
|
-
puts '+ Enter in your system: chroot /mnt /bin/bash'
|
|
39
|
-
puts '+ Reboot with: shutdown -r now'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
class Config < Getch::FileSystem::Lvm::Device
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
9
|
-
gen_uuid
|
|
10
|
-
@init = '/usr/lib/systemd/systemd'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def fstab
|
|
14
|
-
file = "#{MOUNTPOINT}/etc/fstab"
|
|
15
|
-
datas = data_fstab
|
|
16
|
-
File.write(file, datas.join("\n"))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def cmdline
|
|
20
|
-
conf = "#{MOUNTPOINT}/etc/dracut.conf.d/cmdline.conf"
|
|
21
|
-
line = "resume=#{@lv_swap} rd.lvm.vg=#{@vg} init=#{@init}"
|
|
22
|
-
File.write conf, "kernel_cmdline=\"#{line}\"\n"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def gen_uuid
|
|
28
|
-
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
|
29
|
-
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def data_fstab
|
|
33
|
-
efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
|
34
|
-
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
|
35
|
-
swap = "#{@lv_swap} none swap discard 0 0"
|
|
36
|
-
root = "#{@lv_root} / ext4 defaults 0 1"
|
|
37
|
-
home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
|
|
38
|
-
|
|
39
|
-
[ efi, boot, swap, root, home ]
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
class Deps
|
|
7
|
-
def make
|
|
8
|
-
install_bios unless Helpers.efi?
|
|
9
|
-
install_deps
|
|
10
|
-
options_make
|
|
11
|
-
Getch::Make.new('genkernel --kernel-config=/usr/src/linux/.config all').run!
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
def options_make
|
|
16
|
-
grub = Helpers.efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
|
17
|
-
datas = [
|
|
18
|
-
'',
|
|
19
|
-
grub,
|
|
20
|
-
'INSTALL="yes"',
|
|
21
|
-
'MENUCONFIG="no"',
|
|
22
|
-
'CLEAN="yes"',
|
|
23
|
-
'SAVE_CONFIG="yes"',
|
|
24
|
-
'MOUNTBOOT="yes"',
|
|
25
|
-
'MRPROPER="no"',
|
|
26
|
-
'LVM="yes"',
|
|
27
|
-
]
|
|
28
|
-
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
|
29
|
-
File.write(file, datas.join("\n"), mode: 'a')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def install_deps
|
|
33
|
-
Getch::Bask.new('-a lvm').run!
|
|
34
|
-
Getch::Emerge.new('sys-fs/lvm2 genkernel').pkg!
|
|
35
|
-
exec('systemctl enable lvm2-monitor')
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def exec(cmd)
|
|
39
|
-
Getch::Chroot.new(cmd).run!
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
class Device < Getch::FileSystem::Device
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
9
|
-
@vg = 'vg0'
|
|
10
|
-
@lv_root = "/dev/#{@vg}/root"
|
|
11
|
-
@lv_swap = "/dev/#{@vg}/swap"
|
|
12
|
-
@lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
def search_boot
|
|
18
|
-
if @efi
|
|
19
|
-
if @boot_disk
|
|
20
|
-
@dev_esp = "/dev/#{@boot_disk}1"
|
|
21
|
-
else
|
|
22
|
-
@dev_esp = "/dev/#{@disk}1"
|
|
23
|
-
@root_part += 1
|
|
24
|
-
end
|
|
25
|
-
else
|
|
26
|
-
if @boot_disk
|
|
27
|
-
@dev_gpt = "/dev/#{@boot_disk}1"
|
|
28
|
-
@dev_boot = "/dev/#{@boot_disk}2"
|
|
29
|
-
@dev_grub = "/dev/#{@boot_disk}"
|
|
30
|
-
else
|
|
31
|
-
@dev_gpt = "/dev/#{@disk}1"
|
|
32
|
-
@dev_boot = "/dev/#{@disk}2"
|
|
33
|
-
@dev_grub = "/dev/#{@disk}"
|
|
34
|
-
@root_part += 2
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# The swap is a part of the LVM volume, so we clean the func
|
|
40
|
-
def search_swap
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Config < Getch::FileSystem::Lvm::Encrypt::Device
|
|
8
|
-
def initialize
|
|
9
|
-
super
|
|
10
|
-
gen_uuid
|
|
11
|
-
@init = '/usr/lib/systemd/systemd'
|
|
12
|
-
crypttab
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def fstab
|
|
16
|
-
file = "#{MOUNTPOINT}/etc/fstab"
|
|
17
|
-
datas = data_fstab
|
|
18
|
-
File.write file, datas.join("\n")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def systemd_boot
|
|
22
|
-
return unless Helpers.efi?
|
|
23
|
-
|
|
24
|
-
esp = '/efi'
|
|
25
|
-
dir = "#{MOUNTPOINT}/#{esp}/loader/entries/"
|
|
26
|
-
datas_gentoo = [
|
|
27
|
-
'title Gentoo Linux',
|
|
28
|
-
'linux /vmlinuz',
|
|
29
|
-
'initrd /initramfs',
|
|
30
|
-
"options crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} keymap=#{Getch::OPTIONS[:keymap]} dolvm rw"
|
|
31
|
-
]
|
|
32
|
-
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def crypttab
|
|
36
|
-
datas = [
|
|
37
|
-
"cryptswap #{@lv_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=512"
|
|
38
|
-
]
|
|
39
|
-
File.write("#{MOUNTPOINT}/etc/crypttab", datas.join("\n"))
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def grub
|
|
43
|
-
return if Helpers.efi?
|
|
44
|
-
|
|
45
|
-
file = "#{MOUNTPOINT}/etc/default/grub"
|
|
46
|
-
cmdline = [
|
|
47
|
-
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} dolvm rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force keymap=#{Getch::OPTIONS[:keymap]}\"",
|
|
48
|
-
"GRUB_ENABLE_CRYPTODISK=y"
|
|
49
|
-
]
|
|
50
|
-
File.write(file, cmdline.join("\n"), mode: 'a')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
def gen_uuid
|
|
56
|
-
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
|
57
|
-
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
|
58
|
-
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def data_fstab
|
|
62
|
-
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
|
63
|
-
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
|
64
|
-
swap = "/dev/mapper/cryptswap none swap discard 0 0"
|
|
65
|
-
root = "#{@lv_root} / ext4 defaults 0 1"
|
|
66
|
-
home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
|
|
67
|
-
|
|
68
|
-
[ boot_efi, boot, swap, root, home ]
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Deps
|
|
8
|
-
def make
|
|
9
|
-
install_deps
|
|
10
|
-
options_make
|
|
11
|
-
Getch::Make.new('genkernel --kernel-config=/usr/src/linux/.config all').run!
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def options_make
|
|
17
|
-
grub = Helpers.efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
|
18
|
-
datas = [
|
|
19
|
-
'',
|
|
20
|
-
grub,
|
|
21
|
-
'INSTALL="yes"',
|
|
22
|
-
'MENUCONFIG="no"',
|
|
23
|
-
'CLEAN="yes"',
|
|
24
|
-
'KEYMAP="yes"',
|
|
25
|
-
'SAVE_CONFIG="yes"',
|
|
26
|
-
'MOUNTBOOT="yes"',
|
|
27
|
-
'MRPROPER="no"',
|
|
28
|
-
'LVM="yes"',
|
|
29
|
-
'LUKS="yes"',
|
|
30
|
-
]
|
|
31
|
-
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
|
32
|
-
File.write(file, datas.join("\n"), mode: 'a')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def install_deps
|
|
36
|
-
# lvm2, cryptsetup alrealy installed
|
|
37
|
-
Getch::Bask.new('-a lvm').run!
|
|
38
|
-
Getch::Emerge.new('genkernel').pkg!
|
|
39
|
-
exec('systemctl enable lvm2-monitor')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def exec(cmd)
|
|
43
|
-
Getch::Chroot.new(cmd).run!
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Device < Getch::FileSystem::Device
|
|
8
|
-
def initialize
|
|
9
|
-
super
|
|
10
|
-
@vg = 'vg0'
|
|
11
|
-
@lv_root = "/dev/#{@vg}/root"
|
|
12
|
-
@lv_swap = "/dev/#{@vg}/swap"
|
|
13
|
-
@lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
|
|
14
|
-
@luks_root = '/dev/mapper/cryptroot'
|
|
15
|
-
@luks_home = @home_disk ? '/dev/mapper/crypthome' : nil
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def search_boot
|
|
21
|
-
if @efi
|
|
22
|
-
if @boot_disk
|
|
23
|
-
@dev_esp = "/dev/#{@boot_disk}1"
|
|
24
|
-
else
|
|
25
|
-
@dev_esp = "/dev/#{@disk}1"
|
|
26
|
-
@root_part += 1
|
|
27
|
-
end
|
|
28
|
-
else
|
|
29
|
-
if @boot_disk
|
|
30
|
-
@dev_gpt = "/dev/#{@boot_disk}1"
|
|
31
|
-
@dev_boot = "/dev/#{@boot_disk}2"
|
|
32
|
-
@dev_grub = "/dev/#{@boot_disk}"
|
|
33
|
-
else
|
|
34
|
-
@dev_gpt = "/dev/#{@disk}1"
|
|
35
|
-
@dev_boot = "/dev/#{@disk}2"
|
|
36
|
-
@dev_grub = "/dev/#{@disk}"
|
|
37
|
-
@root_part += 2
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def search_swap
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Format < Device
|
|
8
|
-
def initialize
|
|
9
|
-
super
|
|
10
|
-
@fs = 'ext4'
|
|
11
|
-
@state = Getch::States.new()
|
|
12
|
-
format
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def format
|
|
16
|
-
return if STATES[:format]
|
|
17
|
-
|
|
18
|
-
puts "Format #{@disk}"
|
|
19
|
-
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
|
20
|
-
exec("mkfs.#{@fs} -F #{@dev_boot}") if @dev_boot
|
|
21
|
-
exec("mkfs.#{@fs} -F #{@lv_root}")
|
|
22
|
-
exec("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
|
|
23
|
-
@state.format
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def exec(cmd)
|
|
29
|
-
Getch::Command.new(cmd).run!
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Mount < Device
|
|
8
|
-
def initialize
|
|
9
|
-
super
|
|
10
|
-
@mount = Getch::FileSystem::Mount.new
|
|
11
|
-
@state = Getch::States.new
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run
|
|
15
|
-
return if STATES[:mount]
|
|
16
|
-
|
|
17
|
-
@mount.root(@lv_root)
|
|
18
|
-
@mount.boot(@dev_boot)
|
|
19
|
-
@mount.esp(@dev_esp)
|
|
20
|
-
@mount.home(@lv_home)
|
|
21
|
-
@state.mount
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
class Partition < Device
|
|
8
|
-
include Helpers::Cryptsetup
|
|
9
|
-
|
|
10
|
-
def initialize
|
|
11
|
-
super
|
|
12
|
-
@state = Getch::States.new()
|
|
13
|
-
@clean = Getch::FileSystem::Clean
|
|
14
|
-
@partition = Getch::FileSystem::Partition.new
|
|
15
|
-
@log = Log.new
|
|
16
|
-
run_partition
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def run_partition
|
|
20
|
-
return if STATES[:partition ]
|
|
21
|
-
@clean.old_vg(@dev_root, @vg)
|
|
22
|
-
@clean.hdd(@disk)
|
|
23
|
-
@clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
|
|
24
|
-
|
|
25
|
-
partition
|
|
26
|
-
encrypting
|
|
27
|
-
lvm
|
|
28
|
-
@state.partition
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def partition
|
|
34
|
-
if Helpers.efi?
|
|
35
|
-
@partition.efi(@dev_esp)
|
|
36
|
-
@partition.root(@dev_root, '8e00')
|
|
37
|
-
else
|
|
38
|
-
@partition.gpt(@dev_gpt)
|
|
39
|
-
@partition.boot(@dev_boot)
|
|
40
|
-
@partition.root(@dev_root, '8e00')
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def encrypting
|
|
45
|
-
@log.info('Cryptsetup')
|
|
46
|
-
encrypt(@dev_root)
|
|
47
|
-
open_crypt(@dev_root, 'cryptroot')
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def lvm
|
|
51
|
-
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
|
52
|
-
exec("pvcreate -f #{@luks_root}")
|
|
53
|
-
exec("vgcreate -f #{@vg} #{@luks_root}")
|
|
54
|
-
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
|
55
|
-
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
|
56
|
-
|
|
57
|
-
if @user
|
|
58
|
-
exec("lvcreate -y -Wy -Zy -L 18G -n root #{@vg}")
|
|
59
|
-
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}")
|
|
60
|
-
else
|
|
61
|
-
exec("lvcreate -y -Wy -Zy -l 100%FREE -n root #{@vg}")
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
exec('vgchange --available y')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
|
68
|
-
# Partition_efi
|
|
69
|
-
# /efi - EFI system partition - 260MB
|
|
70
|
-
# / - Root
|
|
71
|
-
|
|
72
|
-
# Partition_bios
|
|
73
|
-
# None - Bios Boot Partition - 1MiB
|
|
74
|
-
# /boot - Boot - 8300
|
|
75
|
-
# / - Root
|
|
76
|
-
|
|
77
|
-
def exec(cmd)
|
|
78
|
-
Getch::Command.new(cmd).run!
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
module Encrypt
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
require_relative 'encrypt/device'
|
|
13
|
-
require_relative 'encrypt/partition'
|
|
14
|
-
require_relative 'encrypt/format'
|
|
15
|
-
require_relative 'encrypt/mount'
|
|
16
|
-
require_relative 'encrypt/config'
|
|
17
|
-
require_relative 'encrypt/deps'
|
|
18
|
-
require_relative 'encrypt/void'
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
class Format < Getch::FileSystem::Lvm::Device
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
9
|
-
@state = Getch::States.new
|
|
10
|
-
format
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def format
|
|
14
|
-
return if STATES[:format]
|
|
15
|
-
|
|
16
|
-
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
|
17
|
-
exec("mkfs.ext4 -F #{@dev_boot}") if @dev_boot
|
|
18
|
-
exec("mkswap -f #{@lv_swap}")
|
|
19
|
-
exec("mkfs.ext4 -F #{@lv_root}")
|
|
20
|
-
exec("mkfs.ext4 -F #{@lv_home}") if @lv_home
|
|
21
|
-
@state.format
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def exec(cmd)
|
|
27
|
-
Getch::Command.new(cmd).run!
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Getch
|
|
4
|
-
module FileSystem
|
|
5
|
-
module Lvm
|
|
6
|
-
class Mount < Getch::FileSystem::Lvm::Device
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
9
|
-
@mount = Getch::FileSystem::Mount.new
|
|
10
|
-
@state = Getch::States.new
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def run
|
|
14
|
-
return if STATES[:mount]
|
|
15
|
-
|
|
16
|
-
@mount.swap(@lv_swap)
|
|
17
|
-
@mount.root(@lv_root)
|
|
18
|
-
@mount.boot(@dev_boot)
|
|
19
|
-
@mount.esp(@dev_esp)
|
|
20
|
-
@mount.home(@lv_home)
|
|
21
|
-
@state.mount
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|