getch 0.1.9 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +132 -0
- data/LICENSE +10 -0
- data/README.md +35 -29
- data/bin/getch +8 -6
- data/getch.gemspec +31 -0
- 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 +3 -3
- 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 +144 -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 +113 -74
- 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
data/lib/getch/config/gentoo.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module Config
|
5
|
-
class Gentoo
|
6
|
-
def initialize
|
7
|
-
@systemd_net_dir = "#{MOUNTPOINT}/etc/systemd"
|
8
|
-
end
|
9
|
-
|
10
|
-
def ethernet
|
11
|
-
conf = "#{@systemd_net_dir}/network/20-ethernet.network"
|
12
|
-
datas = [
|
13
|
-
'[Match]',
|
14
|
-
'Name=en*',
|
15
|
-
'Name=eth*',
|
16
|
-
'[Network]',
|
17
|
-
'DHCP=yes',
|
18
|
-
'IPv6PrivacyExtensions=yes',
|
19
|
-
'[DHCP]',
|
20
|
-
'RouteMetric=512',
|
21
|
-
]
|
22
|
-
File.write(conf, datas.join("\n"), mode: 'w')
|
23
|
-
end
|
24
|
-
|
25
|
-
def wifi
|
26
|
-
conf = "#{@systemd_net_dir}/network/20-wireless.network"
|
27
|
-
datas = [
|
28
|
-
'[Match]',
|
29
|
-
'Name=wlp*',
|
30
|
-
'Name=wlan*',
|
31
|
-
'[Network]',
|
32
|
-
'DHCP=yes',
|
33
|
-
'IPv6PrivacyExtensions=yes',
|
34
|
-
'[DHCP]',
|
35
|
-
'RouteMetric=1024',
|
36
|
-
]
|
37
|
-
File.write(conf, datas.join("\n"), mode: 'w')
|
38
|
-
end
|
39
|
-
|
40
|
-
def dns
|
41
|
-
conf = "#{@systemd_net_dir}/resolved.conf.d/dns_over_tls.conf"
|
42
|
-
datas = [
|
43
|
-
'[Resolve]',
|
44
|
-
'DNS=9.9.9.9#dns.quad9.net',
|
45
|
-
'DNSOverTLS=yes',
|
46
|
-
]
|
47
|
-
Helpers.create_dir("#{@systemd_net_dir}/resolved.conf.d")
|
48
|
-
File.write(conf, datas.join("\n"), mode: 'w')
|
49
|
-
|
50
|
-
Getch::Chroot.new('systemctl enable systemd-networkd').run!
|
51
|
-
Getch::Chroot.new('systemctl enable systemd-resolved').run!
|
52
|
-
end
|
53
|
-
|
54
|
-
def shell
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Getch
|
2
|
-
module FileSystem
|
3
|
-
module Clean
|
4
|
-
def self.clean_hdd(disk)
|
5
|
-
return unless disk
|
6
|
-
raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
|
7
|
-
|
8
|
-
puts
|
9
|
-
print "Cleaning data on #{disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? [y,N] "
|
10
|
-
case gets.chomp
|
11
|
-
when /^y|^Y/
|
12
|
-
bloc=`blockdev --getbsz /dev/#{disk}`.chomp
|
13
|
-
Helpers.sys("dd if=/dev/urandom of=/dev/#{disk} bs=#{bloc} status=progress")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.clean_struct(disk)
|
18
|
-
return unless disk
|
19
|
-
raise ArgumentError, "Disk #{disk} is no found." unless File.exist? "/dev/#{disk}"
|
20
|
-
|
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|
|
27
|
-
clean_struct(d)
|
28
|
-
clean_hdd(d)
|
29
|
-
}
|
30
|
-
end
|
31
|
-
# See https://wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing
|
32
|
-
# for SSD
|
33
|
-
def self.sdd
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.external_disk(root_disk, *disks)
|
37
|
-
disks.each do |d|
|
38
|
-
unless d && d != '' && d != nil && d == root_disk
|
39
|
-
hdd(d)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.old_vg(disk, vg)
|
45
|
-
oldvg = `vgdisplay | grep #{vg}`.chomp
|
46
|
-
Helpers.sys("vgremove -f #{vg}") if oldvg != ''
|
47
|
-
Helpers.sys("pvremove -f #{disk}") if oldvg != '' and File.exist? disk
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.old_zpool
|
51
|
-
oldzpool = `zpool status | grep pool:`.gsub(/pool: /, '').delete(' ').split("\n")
|
52
|
-
if oldzpool[0] != '' and $?.success?
|
53
|
-
oldzpool.each { |p| Helpers.sys("zpool destroy #{p}") if p }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module FileSystem
|
5
|
-
class Device
|
6
|
-
def initialize
|
7
|
-
@efi = Helpers.efi?
|
8
|
-
@root_part = 1
|
9
|
-
@user = Getch::OPTIONS[:username]
|
10
|
-
|
11
|
-
@disk = Getch::OPTIONS[:disk]
|
12
|
-
@boot_disk = Getch::OPTIONS[:boot_disk]
|
13
|
-
@cache_disk = Getch::OPTIONS[:cache_disk]
|
14
|
-
@home_disk = Getch::OPTIONS[:home_disk]
|
15
|
-
|
16
|
-
search_boot
|
17
|
-
search_swap
|
18
|
-
search_root
|
19
|
-
search_home
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
def search_boot
|
24
|
-
if @efi
|
25
|
-
if @boot_disk
|
26
|
-
@dev_esp = "/dev/#{@boot_disk}#{@root_part}"
|
27
|
-
else
|
28
|
-
@dev_esp = "/dev/#{@disk}#{@root_part}"
|
29
|
-
@root_part += 1
|
30
|
-
end
|
31
|
-
else
|
32
|
-
if @boot_disk
|
33
|
-
@dev_gpt = "/dev/#{@boot_disk}#{@root_part}"
|
34
|
-
@dev_grub = "/dev/#{@boot_disk}"
|
35
|
-
else
|
36
|
-
@dev_gpt = "/dev/#{@disk}#{@root_part}"
|
37
|
-
@dev_grub = "/dev/#{@disk}"
|
38
|
-
@root_part += 1
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def search_swap
|
44
|
-
if @cache_disk
|
45
|
-
@dev_swap = "/dev/#{@cache_disk}1"
|
46
|
-
else
|
47
|
-
@dev_swap = "/dev/#{@disk}#{@root_part}"
|
48
|
-
@root_part += 1
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def search_root
|
53
|
-
@dev_root = "/dev/#{@disk}#{@root_part}"
|
54
|
-
end
|
55
|
-
|
56
|
-
def search_home
|
57
|
-
if @home_disk
|
58
|
-
@dev_home = "/dev/#{@home_disk}1"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module FileSystem
|
5
|
-
module Ext4
|
6
|
-
class Config < Getch::FileSystem::Ext4::Device
|
7
|
-
def initialize
|
8
|
-
super
|
9
|
-
gen_uuid
|
10
|
-
@root_dir = MOUNTPOINT
|
11
|
-
@init = '/usr/lib/systemd/systemd'
|
12
|
-
end
|
13
|
-
|
14
|
-
def fstab
|
15
|
-
file = "#{@root_dir}/etc/fstab"
|
16
|
-
datas = data_fstab
|
17
|
-
File.write(file, datas.join("\n"))
|
18
|
-
end
|
19
|
-
|
20
|
-
def systemd_boot
|
21
|
-
return unless Helpers.efi?
|
22
|
-
|
23
|
-
esp = '/efi'
|
24
|
-
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
25
|
-
datas_gentoo = [
|
26
|
-
'title Gentoo Linux',
|
27
|
-
'linux /vmlinuz',
|
28
|
-
"options root=PARTUUID=#{@partuuid_root} init=#{@init} rw"
|
29
|
-
]
|
30
|
-
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
31
|
-
end
|
32
|
-
|
33
|
-
def grub
|
34
|
-
return if Helpers.efi?
|
35
|
-
|
36
|
-
file = "#{@root_dir}/etc/default/grub"
|
37
|
-
cmdline = "GRUB_CMDLINE_LINUX=\"resume=PARTUUID=#{@partuuid_swap} root=PARTUUID=#{@partuuid_root} init=#{@init} rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force\"\n"
|
38
|
-
File.write(file, cmdline, mode: 'a')
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def gen_uuid
|
44
|
-
@partuuid_root = Helpers.partuuid(@dev_root)
|
45
|
-
@partuuid_swap = Helpers.partuuid(@dev_swap)
|
46
|
-
@uuid_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
47
|
-
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
48
|
-
@uuid_home = `lsblk -o "UUID" #{@dev_home} | tail -1`.chomp() if @dev_home
|
49
|
-
end
|
50
|
-
|
51
|
-
def data_fstab
|
52
|
-
esp = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
53
|
-
swap = @dev_swap ? "PARTUUID=#{@partuuid_swap} none swap discard 0 0" : ''
|
54
|
-
root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
55
|
-
home = @dev_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
56
|
-
|
57
|
-
[ esp, swap, root, home ]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module FileSystem
|
5
|
-
module Ext4
|
6
|
-
class Deps
|
7
|
-
def initialize
|
8
|
-
if Helpers.efi?
|
9
|
-
install_efi
|
10
|
-
else
|
11
|
-
install_bios
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def install_efi
|
17
|
-
end
|
18
|
-
|
19
|
-
def install_bios
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module FileSystem
|
5
|
-
module Ext4
|
6
|
-
class Format < Getch::FileSystem::Ext4::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("mkswap -f #{@dev_swap}")
|
18
|
-
exec("mkfs.ext4 -F #{@dev_root}")
|
19
|
-
exec("mkfs.ext4 -F #{@dev_home}") if @dev_home
|
20
|
-
@state.format
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def exec(cmd)
|
26
|
-
Getch::Command.new(cmd).run!
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
module FileSystem
|
5
|
-
module Ext4
|
6
|
-
class Mount < Getch::FileSystem::Ext4::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(@dev_swap)
|
17
|
-
@mount.root(@dev_root)
|
18
|
-
@mount.boot(@dev_boot)
|
19
|
-
@mount.esp(@dev_esp)
|
20
|
-
@mount.home(@dev_home)
|
21
|
-
@state.mount
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -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
|