getch 0.0.8 → 0.0.9
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.tar.gz.sig +0 -0
- data/CHANGELOG.md +8 -0
- data/README.md +9 -3
- data/lib/getch.rb +20 -8
- data/lib/getch/command.rb +1 -1
- data/lib/getch/filesystem/ext4.rb +1 -0
- data/lib/getch/filesystem/ext4/config.rb +1 -1
- data/lib/getch/filesystem/ext4/encrypt/config.rb +70 -47
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +26 -4
- data/lib/getch/filesystem/ext4/encrypt/device.rb +5 -4
- data/lib/getch/filesystem/ext4/encrypt/format.rb +10 -4
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +7 -7
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +57 -36
- data/lib/getch/filesystem/lvm.rb +1 -0
- data/lib/getch/filesystem/lvm/config.rb +2 -1
- data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +74 -0
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +63 -0
- data/lib/getch/filesystem/lvm/encrypt/device.rb +22 -0
- data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +92 -0
- data/lib/getch/gentoo.rb +1 -1
- data/lib/getch/gentoo/boot.rb +1 -1
- data/lib/getch/gentoo/chroot.rb +1 -1
- data/lib/getch/gentoo/config.rb +13 -6
- data/lib/getch/gentoo/sources.rb +3 -2
- data/lib/getch/helpers.rb +18 -0
- data/lib/getch/options.rb +5 -5
- data/lib/getch/version.rb +1 -1
- metadata +9 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f332c1aa466828838d7968874705953bba34c2179426f4931a355d5c13963c
|
4
|
+
data.tar.gz: 47fa91c9b9086013db895772f4faece39afe9f4377ad96a53c4b6aee3822f79b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0450bc2fbc6e7b3835802dae660ee878da6890bb2181826057442d3de3c580ff0d68d1348ca1d395c0820ce8d9fa5770fdaaee384e67b2619c0fc37c72190f28
|
7
|
+
data.tar.gz: 961a9019de0dc20e67da6042c2c61d2052cff31299f07c796fec71cb1b9a84e3db92cb1df276a5dd8de896faed53c967871e2d959fc3a317a7d2eccb9ba1622c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
## 0.0.9, release 2020-10-03
|
2
|
+
* Add encryption on ext4 and lvm (BIOS,UEFI)
|
3
|
+
* Correct KEYMAP="yes" with genkernel
|
4
|
+
* Renaming option keyboard with keymap
|
5
|
+
* GPG verification for ebuild
|
6
|
+
|
7
|
+
## 0.0.8, release 2020-09-30
|
1
8
|
* Adding LVM via the option fs, `--fs lvm`.
|
2
9
|
* Systemd-boot use the value of PARTUUID without initramfs.
|
3
10
|
* Include lib logger.
|
11
|
+
* Enhance functions to call program system Emerge, Make, ...
|
4
12
|
|
5
13
|
## 0.0.7, release 2020-09-22
|
6
14
|
* Correct fstab.
|
data/README.md
CHANGED
@@ -5,8 +5,9 @@ A CLI tool to install Gentoo.
|
|
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
6
|
It also require a disk (only one for now) with a minimum of 20G.
|
7
7
|
|
8
|
-
Filesystem supported by Getch are
|
9
|
-
+ ext4
|
8
|
+
BIOS system will use Grub2 and UEFI, systemd-boot. Filesystem supported by Getch are for now:
|
9
|
+
+ ext4
|
10
|
+
+ lvm
|
10
11
|
|
11
12
|
I would also add disk encryption soon.
|
12
13
|
|
@@ -33,7 +34,7 @@ When you boot from an `iso`, you can install `ruby`, `getch` and correct your `P
|
|
33
34
|
## Examples
|
34
35
|
For a french user:
|
35
36
|
|
36
|
-
# getch --username ninja --zoneinfo "Europe/Paris" --language fr_FR --
|
37
|
+
# getch --username ninja --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
|
37
38
|
|
38
39
|
After an install by Getch, take a look on the [wiki](https://github.com/szorfein/getch/wiki).
|
39
40
|
|
@@ -41,6 +42,11 @@ Install Gentoo on LVM:
|
|
41
42
|
|
42
43
|
# getch --format lvm --disk sda
|
43
44
|
|
45
|
+
## Troubleshooting
|
46
|
+
|
47
|
+
#### LVM
|
48
|
+
Unless than your older LVM volume group is named `vg0`, `getch` may fail to partition your disk, you have to clean your device before proceed with `vgremove` and `pvremove`.
|
49
|
+
|
44
50
|
## Issues
|
45
51
|
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
52
|
+ lspci
|
data/lib/getch.rb
CHANGED
@@ -11,7 +11,7 @@ module Getch
|
|
11
11
|
DEFAULT_OPTIONS = {
|
12
12
|
language: 'en_US',
|
13
13
|
zoneinfo: 'US/Eastern',
|
14
|
-
|
14
|
+
keymap: 'us',
|
15
15
|
disk: 'sda',
|
16
16
|
fs: 'ext4',
|
17
17
|
username: nil,
|
@@ -30,16 +30,28 @@ module Getch
|
|
30
30
|
}
|
31
31
|
|
32
32
|
MOUNTPOINT = "/mnt/gentoo".freeze
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
DEFAULT_FS = {
|
34
|
+
true => {
|
35
|
+
ext4: Getch::FileSystem::Ext4::Encrypt,
|
36
|
+
lvm: Getch::FileSystem::Lvm::Encrypt
|
37
|
+
},
|
38
|
+
false => {
|
39
|
+
ext4: Getch::FileSystem::Ext4,
|
40
|
+
lvm: Getch::FileSystem::Lvm
|
41
|
+
}
|
36
42
|
}.freeze
|
37
43
|
|
44
|
+
def self.class_fs
|
45
|
+
encrypt = DEFAULT_OPTIONS[:encrypt]
|
46
|
+
fs = DEFAULT_OPTIONS[:fs].to_sym
|
47
|
+
DEFAULT_FS[encrypt][fs]
|
48
|
+
end
|
49
|
+
|
38
50
|
def self.resume_options(opts)
|
39
51
|
puts "\nBuild Gentoo with the following args:\n"
|
40
52
|
puts "lang: #{DEFAULT_OPTIONS[:language]}"
|
41
53
|
puts "zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
|
42
|
-
puts "
|
54
|
+
puts "keymap: #{DEFAULT_OPTIONS[:keymap]}"
|
43
55
|
puts "disk: #{DEFAULT_OPTIONS[:disk]}"
|
44
56
|
puts "fs: #{DEFAULT_OPTIONS[:fs]}"
|
45
57
|
puts "username: #{DEFAULT_OPTIONS[:username]}"
|
@@ -62,8 +74,8 @@ module Getch
|
|
62
74
|
case gets.chomp
|
63
75
|
when /^y|^Y/
|
64
76
|
log.info("Partition start")
|
65
|
-
|
66
|
-
|
77
|
+
class_fs::Partition.new
|
78
|
+
class_fs::Format.new
|
67
79
|
else
|
68
80
|
exit 1
|
69
81
|
end
|
@@ -84,7 +96,7 @@ module Getch
|
|
84
96
|
resume_options(options)
|
85
97
|
Getch::States.new # Update States
|
86
98
|
format(options.disk, options.fs, options.username)
|
87
|
-
|
99
|
+
class_fs::Mount.new.run
|
88
100
|
init_gentoo(options)
|
89
101
|
end
|
90
102
|
end
|
data/lib/getch/command.rb
CHANGED
@@ -30,7 +30,7 @@ module Getch
|
|
30
30
|
def grub
|
31
31
|
return if Helpers::efi?
|
32
32
|
file = "#{@root_dir}/etc/default/grub"
|
33
|
-
cmdline = "GRUB_CMDLINE_LINUX=\"resume=#{@dev_swap} 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"
|
33
|
+
cmdline = "GRUB_CMDLINE_LINUX=\"resume=#{@dev_swap} root=#{@dev_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"
|
34
34
|
File.write(file, cmdline, mode: 'a')
|
35
35
|
end
|
36
36
|
|
@@ -1,60 +1,83 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Getch
|
2
4
|
module FileSystem
|
3
5
|
module Ext4
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
module Encrypt
|
7
|
+
class Config < Getch::FileSystem::Ext4::Encrypt::Device
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
gen_uuid
|
11
|
+
@root_dir = MOUNTPOINT
|
12
|
+
@init = '/usr/lib/systemd/systemd'
|
13
|
+
move_secret_keys
|
14
|
+
crypttab
|
15
|
+
end
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def fstab
|
18
|
+
file = "#{@root_dir}/etc/fstab"
|
19
|
+
datas = data_fstab
|
20
|
+
File.write(file, datas.join("\n"))
|
21
|
+
end
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def systemd_boot
|
24
|
+
return if ! Helpers::efi?
|
25
|
+
esp = '/boot/efi'
|
26
|
+
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
27
|
+
datas_gentoo = [
|
28
|
+
'title Gentoo Linux',
|
29
|
+
'linux /vmlinuz',
|
30
|
+
'initrd /initramfs',
|
31
|
+
"options crypt_root=UUID=#{@uuid_root} root=/dev/mapper/root init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} rw"
|
32
|
+
]
|
33
|
+
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
34
|
+
end
|
29
35
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
36
|
+
def crypttab
|
37
|
+
home = @dev_home ? "crypthome UUID=#{@uuid_home} /root/secretkeys/crypto_keyfile.bin luks" : ''
|
38
|
+
datas = [
|
39
|
+
"cryptswap UUID=#{@uuid_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=256",
|
40
|
+
home
|
41
|
+
]
|
42
|
+
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
43
|
+
end
|
39
44
|
|
40
|
-
|
45
|
+
def grub
|
46
|
+
return if Helpers::efi?
|
47
|
+
file = "#{@root_dir}/etc/default/grub"
|
48
|
+
cmdline = [
|
49
|
+
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_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 keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
|
50
|
+
"GRUB_ENABLE_CRYPTODISK=y"
|
51
|
+
]
|
52
|
+
File.write(file, cmdline.join("\n"), mode: 'a')
|
53
|
+
end
|
41
54
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
55
|
+
private
|
56
|
+
|
57
|
+
def gen_uuid
|
58
|
+
@partuuid_root = `lsblk -o "PARTUUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
59
|
+
@uuid_swap = `lsblk -o "UUID" #{@dev_swap} | tail -1`.chomp() if @dev_swap
|
60
|
+
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
61
|
+
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
62
|
+
@uuid_root = `lsblk -d -o "UUID" #{@luks_root} | tail -1`.chomp() if @dev_root
|
63
|
+
@uuid_home = `lsblk -d -o "UUID" #{@dev_home} | tail -1`.chomp() if @luks_home
|
64
|
+
end
|
65
|
+
|
66
|
+
def data_fstab
|
67
|
+
boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
|
68
|
+
swap = @dev_swap ? "#{@luks_swap} none swap discard 0 0 " : ''
|
69
|
+
root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
70
|
+
home = @dev_home ? "#{@luks_home} /home/#{@user} ext4 defaults 0 2" : ''
|
50
71
|
|
51
|
-
|
52
|
-
|
53
|
-
swap = @lv_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
|
54
|
-
root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
55
|
-
home = @lv_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
72
|
+
[ boot_efi, swap, root, home ]
|
73
|
+
end
|
56
74
|
|
57
|
-
|
75
|
+
def move_secret_keys
|
76
|
+
return if ! @luks_home
|
77
|
+
puts "Moving secret keys"
|
78
|
+
keys_path = "#{@root_dir}/root/secretkeys"
|
79
|
+
FileUtils.mv("/root/secretkeys", keys_path) if ! Dir.exist?(keys_path)
|
80
|
+
end
|
58
81
|
end
|
59
82
|
end
|
60
83
|
end
|
@@ -12,19 +12,41 @@ module Getch
|
|
12
12
|
install_deps
|
13
13
|
end
|
14
14
|
|
15
|
+
def make
|
16
|
+
genkernel
|
17
|
+
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
18
|
+
end
|
19
|
+
|
15
20
|
private
|
16
21
|
def install_efi
|
17
22
|
end
|
18
23
|
|
24
|
+
def genkernel
|
25
|
+
grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
26
|
+
datas = [
|
27
|
+
'',
|
28
|
+
grub,
|
29
|
+
'INSTALL="yes"',
|
30
|
+
'MENUCONFIG="no"',
|
31
|
+
'CLEAN="yes"',
|
32
|
+
'KEYMAP="yes"',
|
33
|
+
'SAVE_CONFIG="yes"',
|
34
|
+
'MOUNTBOOT="yes"',
|
35
|
+
'MRPROPER="no"',
|
36
|
+
'LUKS="yes"',
|
37
|
+
]
|
38
|
+
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
39
|
+
File.write(file, datas.join("\n"), mode: 'a')
|
40
|
+
end
|
41
|
+
|
19
42
|
def install_bios
|
20
43
|
exec("euse -p sys-boot/grub -E device-mapper")
|
44
|
+
exec("euse -p sys-fs/cryptsetup -E luks1_default")
|
21
45
|
end
|
22
46
|
|
23
47
|
def install_deps
|
24
|
-
exec("euse -
|
25
|
-
Getch::Emerge.new('genkernel cryptsetup
|
26
|
-
exec("genkernel --install --luks --keymap #{DEFAULT_OPTIONS[:keyboard]} --lvm --kernel-config=/usr/src/linux/.config initramfs")
|
27
|
-
exec("systemctl enable lvm2-monitor")
|
48
|
+
exec("euse -E cryptsetup") if ! Helpers::grep?("#{MOUNTPOINT}/etc/portage/make.conf", /cryptsetup/)
|
49
|
+
Getch::Emerge.new('genkernel sys-apps/systemd sys-fs/cryptsetup').pkg!
|
28
50
|
end
|
29
51
|
|
30
52
|
def exec(cmd)
|
@@ -8,10 +8,11 @@ module Getch
|
|
8
8
|
@user = DEFAULT_OPTIONS[:username]
|
9
9
|
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
10
10
|
@dev_root = "/dev/#{@disk}2"
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
11
|
+
@dev_swap = "/dev/#{@disk}3"
|
12
|
+
@dev_home = @user ? "/dev/#{@disk}4" : nil
|
13
|
+
@luks_root = "/dev/mapper/cryptroot"
|
14
|
+
@luks_home = @user ? "/dev/mapper/crypthome" : nil
|
15
|
+
@luks_swap = "/dev/mapper/cryptswap"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -13,12 +13,18 @@ module Getch
|
|
13
13
|
def format
|
14
14
|
return if STATES[:format]
|
15
15
|
puts "Format #{@disk} with #{@fs}"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
exec("mkfs.fat -F32 #{@dev_boot_efi}") if Helpers::efi?
|
17
|
+
exec("mkfs.#{@fs} -F #{@luks_root}")
|
18
|
+
exec("mkswap -f #{@dev_swap}")
|
19
|
+
exec("mkfs.#{@fs} -F #{@luks_home}") if @dev_home
|
20
20
|
@state.format
|
21
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def exec(cmd)
|
26
|
+
Getch::Command.new(cmd).run!
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -16,7 +16,7 @@ module Getch
|
|
16
16
|
|
17
17
|
def run
|
18
18
|
return if STATES[:mount]
|
19
|
-
mount_swap
|
19
|
+
#mount_swap
|
20
20
|
mount_root
|
21
21
|
mount_boot
|
22
22
|
mount_home
|
@@ -27,14 +27,14 @@ module Getch
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def mount_swap
|
30
|
-
return if ! @
|
31
|
-
system("swapon #{@
|
30
|
+
return if ! @dev_swap
|
31
|
+
system("swapon #{@dev_swap}")
|
32
32
|
end
|
33
33
|
|
34
34
|
def mount_root
|
35
|
-
return if ! @
|
35
|
+
return if ! @dev_root
|
36
36
|
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
37
|
-
system("mount #{@
|
37
|
+
system("mount #{@luks_root} #{@root_dir}")
|
38
38
|
end
|
39
39
|
|
40
40
|
def mount_boot_efi
|
@@ -50,10 +50,10 @@ module Getch
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def mount_home
|
53
|
-
return if ! @
|
53
|
+
return if ! @dev_home
|
54
54
|
if @user != nil then
|
55
55
|
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
56
|
-
system("mount #{@
|
56
|
+
system("mount #{@luks_home} #{@home_dir}")
|
57
57
|
end
|
58
58
|
@state.mount
|
59
59
|
end
|
@@ -6,6 +6,7 @@ module Getch
|
|
6
6
|
def initialize
|
7
7
|
super
|
8
8
|
@state = Getch::States.new()
|
9
|
+
@log = Log.new
|
9
10
|
run_partition
|
10
11
|
end
|
11
12
|
|
@@ -13,10 +14,13 @@ module Getch
|
|
13
14
|
return if STATES[:partition ]
|
14
15
|
clear_struct
|
15
16
|
cleaning
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if Helpers::efi?
|
18
|
+
partition_efi
|
19
|
+
encrypt_efi
|
20
|
+
else
|
21
|
+
partition_bios
|
22
|
+
encrypt_bios
|
23
|
+
end
|
20
24
|
@state.partition
|
21
25
|
end
|
22
26
|
|
@@ -39,51 +43,68 @@ module Getch
|
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
47
|
+
def partition_efi
|
48
|
+
# /boot/efi - EFI system partition - 260MB
|
49
|
+
# / - Root
|
50
|
+
# swap - Linux Swap - size of the ram
|
51
|
+
# /home - Home
|
52
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
53
|
+
|
54
|
+
exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
|
55
|
+
exec("sgdisk -n2:0:+15G -t2:8309 /dev/#{@disk}")
|
56
|
+
exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
|
57
|
+
exec("sgdisk -n4:0:0 -t4:8309 /dev/#{@disk}") if @dev_home
|
48
58
|
end
|
49
59
|
|
50
|
-
def
|
51
|
-
|
60
|
+
def encrypt_efi
|
61
|
+
@log.info("Format root")
|
62
|
+
Helpers::sys("cryptsetup luksFormat #{@dev_root}")
|
63
|
+
@log.debug("Opening root")
|
64
|
+
Helpers::sys("cryptsetup open --type luks #{@dev_root} cryptroot")
|
65
|
+
encrypt_home
|
52
66
|
end
|
53
67
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
exec("cryptsetup --use-random luksFormat --type luks1 /dev/#{@disk}2")
|
61
|
-
exec("cryptsetup open --type luks1 /dev/#{@disk}2 crypt-lvm")
|
62
|
-
end
|
68
|
+
def encrypt_bios
|
69
|
+
@log.info("Format root for bios")
|
70
|
+
Helpers::sys("cryptsetup luksFormat --type luks1 #{@dev_root}")
|
71
|
+
@log.debug("Opening root")
|
72
|
+
Helpers::sys("cryptsetup open --type luks1 #{@dev_root} cryptroot")
|
73
|
+
encrypt_home
|
63
74
|
end
|
64
75
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
def encrypt_home
|
77
|
+
if @dev_home then
|
78
|
+
create_secret_keys
|
79
|
+
@log.info("Format home with #{@key_path}")
|
80
|
+
Helpers::sys("cryptsetup luksFormat #{@dev_home} #{@key_path}")
|
81
|
+
@log.debug("Open home with key #{@key_path}")
|
82
|
+
exec("cryptsetup open --type luks -d #{@key_path} #{@dev_home} crypthome")
|
83
|
+
end
|
73
84
|
end
|
74
85
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
86
|
+
def create_secret_keys
|
87
|
+
return if ! @dev_home
|
88
|
+
@log.info("Creating secret keys")
|
89
|
+
keys_dir = "/root/secretkeys"
|
90
|
+
key_name = "crypto_keyfile.bin"
|
91
|
+
@key_path = "#{keys_dir}/#{key_name}"
|
92
|
+
FileUtils.mkdir keys_dir, mode: 0700 if ! Dir.exist?(keys_dir)
|
93
|
+
Getch::Command.new("dd bs=512 count=4 if=/dev/urandom of=#{@key_path}").run!
|
94
|
+
end
|
81
95
|
|
82
|
-
|
96
|
+
def partition_bios
|
83
97
|
# None - Bios Boot Partition - 1MiB
|
84
98
|
# / - Root
|
85
99
|
# swap - Linux Swap - size of the ram
|
86
100
|
# /home - Home
|
101
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
102
|
+
|
103
|
+
exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
|
104
|
+
exec("sgdisk -n2:0:+15G -t2:8309 /dev/#{@disk}")
|
105
|
+
exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
|
106
|
+
exec("sgdisk -n4:0:0 -t4:8309 /dev/#{@disk}") if @dev_home
|
107
|
+
end
|
87
108
|
|
88
109
|
def exec(cmd)
|
89
110
|
Getch::Command.new(cmd).run!
|
data/lib/getch/filesystem/lvm.rb
CHANGED
@@ -50,11 +50,12 @@ module Getch
|
|
50
50
|
|
51
51
|
def data_fstab
|
52
52
|
boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
|
53
|
+
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
53
54
|
swap = @lv_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
|
54
55
|
root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
55
56
|
home = @lv_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
56
57
|
|
57
|
-
[ boot_efi, swap, root, home ]
|
58
|
+
[ boot_efi, boot, swap, root, home ]
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require_relative 'encrypt/device'
|
11
|
+
require_relative 'encrypt/partition'
|
12
|
+
require_relative 'encrypt/format'
|
13
|
+
require_relative 'encrypt/mount'
|
14
|
+
require_relative 'encrypt/config'
|
15
|
+
require_relative 'encrypt/deps'
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Config < Getch::FileSystem::Lvm::Encrypt::Device
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
gen_uuid
|
9
|
+
@root_dir = MOUNTPOINT
|
10
|
+
@init = '/usr/lib/systemd/systemd'
|
11
|
+
crypttab
|
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 if ! Helpers::efi?
|
22
|
+
esp = '/boot/efi'
|
23
|
+
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
24
|
+
datas_gentoo = [
|
25
|
+
'title Gentoo Linux',
|
26
|
+
'linux /vmlinuz',
|
27
|
+
'initrd /initramfs',
|
28
|
+
"options crypt_root=UUID=#{@uuid_dev_root} root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
|
29
|
+
]
|
30
|
+
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
31
|
+
end
|
32
|
+
|
33
|
+
def crypttab
|
34
|
+
datas = [
|
35
|
+
"cryptswap #{@lv_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=256"
|
36
|
+
]
|
37
|
+
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
38
|
+
end
|
39
|
+
|
40
|
+
def grub
|
41
|
+
return if Helpers::efi?
|
42
|
+
file = "#{@root_dir}/etc/default/grub"
|
43
|
+
cmdline = [
|
44
|
+
"GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} 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=#{DEFAULT_OPTIONS[:keymap]}\"",
|
45
|
+
"GRUB_ENABLE_CRYPTODISK=y"
|
46
|
+
]
|
47
|
+
File.write("#{file}", cmdline.join("\n"), mode: 'a')
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def gen_uuid
|
53
|
+
@uuid_swap = `lsblk -o "UUID" #{@lv_swap} | tail -1`.chomp() if @lv_swap
|
54
|
+
@uuid_root = `lsblk -d -o "UUID" #{@lv_root} | tail -1`.chomp() if @lv_root
|
55
|
+
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
56
|
+
@uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
|
57
|
+
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
58
|
+
@uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
|
59
|
+
end
|
60
|
+
|
61
|
+
def data_fstab
|
62
|
+
boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
|
63
|
+
boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
|
64
|
+
swap = @lv_swap ? "/dev/mapper/cryptswap none swap discard 0 0" : ''
|
65
|
+
root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
66
|
+
home = @lv_home ? "UUID=#{@uuid_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
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Deps
|
6
|
+
def initialize
|
7
|
+
if Helpers::efi?
|
8
|
+
install_efi
|
9
|
+
else
|
10
|
+
install_bios
|
11
|
+
end
|
12
|
+
install_deps
|
13
|
+
end
|
14
|
+
|
15
|
+
def make
|
16
|
+
options_make
|
17
|
+
Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def options_make
|
22
|
+
grub = Helpers::efi? ? 'BOOTLOADER="no"' : 'BOOTLOADER="grub2"'
|
23
|
+
datas = [
|
24
|
+
'',
|
25
|
+
grub,
|
26
|
+
'INSTALL="yes"',
|
27
|
+
'MENUCONFIG="no"',
|
28
|
+
'CLEAN="yes"',
|
29
|
+
'KEYMAP="yes"',
|
30
|
+
'SAVE_CONFIG="yes"',
|
31
|
+
'MOUNTBOOT="yes"',
|
32
|
+
'MRPROPER="no"',
|
33
|
+
'LVM="yes"',
|
34
|
+
'LUKS="yes"',
|
35
|
+
]
|
36
|
+
file = "#{MOUNTPOINT}/etc/genkernel.conf"
|
37
|
+
File.write(file, datas.join("\n"), mode: 'a')
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_efi
|
41
|
+
end
|
42
|
+
|
43
|
+
def install_bios
|
44
|
+
exec("euse -p sys-boot/grub -E device-mapper")
|
45
|
+
end
|
46
|
+
|
47
|
+
def install_deps
|
48
|
+
make_conf = "#{MOUNTPOINT}/etc/portage/make.conf"
|
49
|
+
exec("euse -E lvm") if ! Helpers::grep?(make_conf, /lvm/)
|
50
|
+
exec("euse -E cryptsetup") if ! Helpers::grep?(make_conf, /cryptsetup/)
|
51
|
+
Getch::Emerge.new('genkernel systemd sys-fs/cryptsetup lvm2').pkg!
|
52
|
+
Getch::Garden.new('-a lvm').run!
|
53
|
+
exec("systemctl enable lvm2-monitor")
|
54
|
+
end
|
55
|
+
|
56
|
+
def exec(cmd)
|
57
|
+
Helpers::run_chroot(cmd, MOUNTPOINT)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Device
|
6
|
+
def initialize
|
7
|
+
@disk = DEFAULT_OPTIONS[:disk]
|
8
|
+
@user = DEFAULT_OPTIONS[:username]
|
9
|
+
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
10
|
+
@dev_boot = Helpers::efi? ? nil : "/dev/#{@disk}2"
|
11
|
+
@dev_root = Helpers::efi? ? "/dev/#{@disk}2" : "/dev/#{@disk}3"
|
12
|
+
@vg = 'vg0'
|
13
|
+
@lv_root = "/dev/mapper/#{@vg}-root"
|
14
|
+
@lv_swap = "/dev/mapper/#{@vg}-swap"
|
15
|
+
@lv_home = @user ? "/dev/mapper/#{@vg}-home" : nil
|
16
|
+
@luks_root = "/dev/mapper/cryptroot"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Format < Getch::FileSystem::Lvm::Encrypt::Device
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@fs = 'ext4'
|
9
|
+
@state = Getch::States.new()
|
10
|
+
format
|
11
|
+
end
|
12
|
+
|
13
|
+
def format
|
14
|
+
return if STATES[:format]
|
15
|
+
puts "Format #{@disk} with #{@fs}"
|
16
|
+
exec("mkfs.fat -F32 #{@dev_boot_efi}") if @dev_boot_efi
|
17
|
+
exec("mkfs.#{@fs} -F #{@dev_boot}") if @dev_boot
|
18
|
+
#exec("mkswap -f #{@lv_swap}")
|
19
|
+
exec("mkfs.#{@fs} -F #{@lv_root}")
|
20
|
+
exec("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
|
21
|
+
@state.format
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def exec(cmd)
|
26
|
+
Getch::Command.new(cmd).run!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
module Lvm
|
6
|
+
module Encrypt
|
7
|
+
class Mount < Getch::FileSystem::Lvm::Encrypt::Device
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
@root_dir = MOUNTPOINT
|
11
|
+
@boot_dir = "#{@root_dir}/boot"
|
12
|
+
@boot_efi_dir = "#{@root_dir}/boot/efi"
|
13
|
+
@home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
|
14
|
+
@state = Getch::States.new()
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
return if STATES[:mount]
|
19
|
+
mount_swap
|
20
|
+
mount_root
|
21
|
+
mount_boot
|
22
|
+
mount_home
|
23
|
+
mount_boot_efi
|
24
|
+
@state.mount
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def mount_swap
|
30
|
+
return if ! @lv_swap
|
31
|
+
system("swapon #{@lv_swap}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def mount_root
|
35
|
+
return if ! @lv_root
|
36
|
+
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
37
|
+
system("mount #{@lv_root} #{@root_dir}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def mount_boot_efi
|
41
|
+
return if ! @dev_boot_efi
|
42
|
+
FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
|
43
|
+
system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def mount_boot
|
47
|
+
return if ! @dev_boot
|
48
|
+
FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
|
49
|
+
system("mount #{@dev_boot} #{@boot_dir}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def mount_home
|
53
|
+
return if ! @lv_home
|
54
|
+
if @user != nil then
|
55
|
+
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
56
|
+
system("mount #{@lv_home} #{@home_dir}")
|
57
|
+
end
|
58
|
+
@state.mount
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Lvm
|
4
|
+
module Encrypt
|
5
|
+
class Partition < Getch::FileSystem::Lvm::Encrypt::Device
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@state = Getch::States.new()
|
9
|
+
@log = Log.new
|
10
|
+
run_partition
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_partition
|
14
|
+
return if STATES[:partition ]
|
15
|
+
clear_struct
|
16
|
+
cleaning
|
17
|
+
partition
|
18
|
+
encrypt
|
19
|
+
lvm
|
20
|
+
@state.partition
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def clear_struct
|
26
|
+
oldvg = `vgdisplay | grep #{@vg}`.chomp
|
27
|
+
exec("vgremove -f #{@vg}") if oldvg != '' # remove older volume group
|
28
|
+
exec("pvremove -f #{@dev_root}") if oldvg != '' and File.exist? @dev_root # remove older volume group
|
29
|
+
|
30
|
+
exec("sgdisk -Z /dev/#{@disk}")
|
31
|
+
exec("wipefs -a /dev/#{@disk}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def cleaning
|
35
|
+
puts
|
36
|
+
print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
37
|
+
case gets.chomp
|
38
|
+
when /^y|^Y/
|
39
|
+
bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
|
40
|
+
exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
|
41
|
+
else
|
42
|
+
return
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def partition
|
47
|
+
if Helpers::efi?
|
48
|
+
exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
|
49
|
+
exec("sgdisk -n2:0:+0 -t2:8e00 /dev/#{@disk}")
|
50
|
+
else
|
51
|
+
exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
|
52
|
+
exec("sgdisk -n2:0:+128MiB -t2:8300 /dev/#{@disk}")
|
53
|
+
exec("sgdisk -n3:0:+0 -t3:8e00 /dev/#{@disk}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def encrypt
|
58
|
+
@log.info("Format root")
|
59
|
+
Helpers::sys("cryptsetup luksFormat #{@dev_root}")
|
60
|
+
@log.debug("Opening root")
|
61
|
+
Helpers::sys("cryptsetup open --type luks #{@dev_root} cryptroot")
|
62
|
+
end
|
63
|
+
|
64
|
+
def lvm
|
65
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
66
|
+
exec("pvcreate -f #{@luks_root}")
|
67
|
+
exec("vgcreate -f #{@vg} #{@luks_root}")
|
68
|
+
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
69
|
+
exec("lvcreate -y -Wy -Zy -L 15G -n root #{@vg}")
|
70
|
+
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
71
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}") if @user
|
72
|
+
exec("vgchange --available y")
|
73
|
+
end
|
74
|
+
|
75
|
+
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
76
|
+
# Partition_efi
|
77
|
+
# /boot/efi - EFI system partition - 260MB
|
78
|
+
# / - Root
|
79
|
+
|
80
|
+
# Partition_bios
|
81
|
+
# None - Bios Boot Partition - 1MiB
|
82
|
+
# /boot - Boot - 8300
|
83
|
+
# / - Root
|
84
|
+
|
85
|
+
def exec(cmd)
|
86
|
+
Getch::Command.new(cmd).run!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/getch/gentoo.rb
CHANGED
data/lib/getch/gentoo/boot.rb
CHANGED
data/lib/getch/gentoo/chroot.rb
CHANGED
data/lib/getch/gentoo/config.rb
CHANGED
@@ -24,18 +24,25 @@ module Getch
|
|
24
24
|
File.write(@make, data.join("\n"), mode: "a")
|
25
25
|
end
|
26
26
|
|
27
|
+
# Write a repos.conf/gentoo.conf with the gpg verification
|
27
28
|
def repo
|
28
29
|
src = "#{MOUNTPOINT}/usr/share/portage/config/repos.conf"
|
29
30
|
dest = "#{MOUNTPOINT}/etc/portage/repos.conf"
|
30
31
|
FileUtils.mkdir dest, mode: 0644 if ! Dir.exist?(dest)
|
32
|
+
tmp = Tempfile.new('gentoo.conf')
|
31
33
|
line_count = 0
|
32
|
-
|
34
|
+
|
33
35
|
File.open(src).each { |l|
|
34
|
-
File.write(
|
35
|
-
|
36
|
+
File.write(tmp, "sync-allow-hardlinks = yes\n", mode: 'a') if line_count == 2
|
37
|
+
if l.match(/^sync-type = rsync/)
|
38
|
+
File.write(tmp, "sync-type = webrsync\n", mode: 'a')
|
39
|
+
else
|
40
|
+
File.write(tmp, l, mode: 'a')
|
41
|
+
end
|
36
42
|
line_count += 1
|
37
43
|
}
|
38
|
-
|
44
|
+
|
45
|
+
FileUtils.copy_file(tmp, "#{dest}/gentoo.conf", preserve = false)
|
39
46
|
end
|
40
47
|
|
41
48
|
def network
|
@@ -50,7 +57,7 @@ module Getch
|
|
50
57
|
File.write("#{MOUNTPOINT}/etc/locale.conf", "LANG=#{@lang}\n")
|
51
58
|
File.write("#{MOUNTPOINT}/etc/locale.conf", 'LC_COLLATE=C', mode: 'a')
|
52
59
|
File.write("#{MOUNTPOINT}/etc/timezone", "#{options.zoneinfo}")
|
53
|
-
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.
|
60
|
+
File.write("#{MOUNTPOINT}/etc/vconsole.conf", "KEYMAP=#{options.keymap}")
|
54
61
|
end
|
55
62
|
|
56
63
|
def hostname
|
@@ -74,7 +81,7 @@ module Getch
|
|
74
81
|
def control_options(options)
|
75
82
|
search_zone(options.zoneinfo)
|
76
83
|
search_utf8(options.language)
|
77
|
-
search_key(options.
|
84
|
+
search_key(options.keymap)
|
78
85
|
end
|
79
86
|
|
80
87
|
def search_key(keys)
|
data/lib/getch/gentoo/sources.rb
CHANGED
@@ -3,7 +3,7 @@ module Getch
|
|
3
3
|
class Sources
|
4
4
|
def initialize
|
5
5
|
@lsmod = `lsmod`.chomp
|
6
|
-
@filesystem =
|
6
|
+
@filesystem = Getch.class_fs::Deps.new()
|
7
7
|
end
|
8
8
|
|
9
9
|
def build_others
|
@@ -20,7 +20,7 @@ module Getch
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def make
|
23
|
-
if DEFAULT_OPTIONS[:fs] == 'lvm'
|
23
|
+
if DEFAULT_OPTIONS[:fs] == 'lvm' or DEFAULT_OPTIONS[:encrypt]
|
24
24
|
@filesystem.make
|
25
25
|
else
|
26
26
|
just_make
|
@@ -77,6 +77,7 @@ module Getch
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def install_zfs
|
80
|
+
return if ! DEFAULT_OPTIONS[:fs] == 'zfs'
|
80
81
|
garden("-a zfs")
|
81
82
|
only_make # a first 'make' is necessary before emerge zfs
|
82
83
|
Getch::Emerge.new("sys-fs/zfs").pkg!
|
data/lib/getch/helpers.rb
CHANGED
@@ -46,4 +46,22 @@ module Helpers
|
|
46
46
|
\""
|
47
47
|
Getch::Command.new(script).run!
|
48
48
|
end
|
49
|
+
|
50
|
+
def self.grep?(file, regex)
|
51
|
+
is_found = false
|
52
|
+
return is_found if ! File.exist? file
|
53
|
+
File.open(file) do |f|
|
54
|
+
f.each do |line|
|
55
|
+
is_found = true if line.match(regex)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
is_found
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.sys(cmd)
|
62
|
+
system(cmd)
|
63
|
+
unless $?.success?
|
64
|
+
raise "Error with #{cmd}"
|
65
|
+
end
|
66
|
+
end
|
49
67
|
end
|
data/lib/getch/options.rb
CHANGED
@@ -2,12 +2,12 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module Getch
|
4
4
|
class Options
|
5
|
-
attr_reader :language, :zoneinfo, :
|
5
|
+
attr_reader :language, :zoneinfo, :keymap, :disk, :fs, :username, :encrypt, :verbose
|
6
6
|
|
7
7
|
def initialize(argv)
|
8
8
|
@language = DEFAULT_OPTIONS[:language]
|
9
9
|
@zoneinfo = DEFAULT_OPTIONS[:zoneinfo]
|
10
|
-
@
|
10
|
+
@keymap = DEFAULT_OPTIONS[:keymap]
|
11
11
|
@disk = DEFAULT_OPTIONS[:disk]
|
12
12
|
@fs = DEFAULT_OPTIONS[:fs]
|
13
13
|
@username = DEFAULT_OPTIONS[:username]
|
@@ -26,8 +26,8 @@ module Getch
|
|
26
26
|
opts.on("-z", "--zoneinfo ZONE", "Default is US/Eastern") do |zone|
|
27
27
|
@zoneinfo = zone
|
28
28
|
end
|
29
|
-
opts.on("-k", "--
|
30
|
-
@
|
29
|
+
opts.on("-k", "--keymap KEY", "Default is us") do |key|
|
30
|
+
@keymap = key
|
31
31
|
end
|
32
32
|
opts.on("-d", "--disk DISK", "Disk where install Gentoo (sda,sdb)") do |disk|
|
33
33
|
@disk = disk
|
@@ -39,7 +39,7 @@ module Getch
|
|
39
39
|
opts.on("-u", "--username USERNAME", "Initialize /home/username") do |user|
|
40
40
|
@username = user
|
41
41
|
end
|
42
|
-
opts.on("--encrypt", "Encrypt your
|
42
|
+
opts.on("--encrypt", "Encrypt your system with Luks2.") do
|
43
43
|
@encrypt = true
|
44
44
|
end
|
45
45
|
opts.on("--verbose", "Write more messages to the standard output.") do
|
data/lib/getch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
J/zT/q2Ac7BWpSLbv6p9lChBiEnD9j24x463LR5QQjDNS5SsjzRQfFuprsa9Nqf2
|
36
36
|
Tw==
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
38
|
+
date: 2020-10-03 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -73,6 +73,13 @@ files:
|
|
73
73
|
- lib/getch/filesystem/lvm/config.rb
|
74
74
|
- lib/getch/filesystem/lvm/deps.rb
|
75
75
|
- lib/getch/filesystem/lvm/device.rb
|
76
|
+
- lib/getch/filesystem/lvm/encrypt.rb
|
77
|
+
- lib/getch/filesystem/lvm/encrypt/config.rb
|
78
|
+
- lib/getch/filesystem/lvm/encrypt/deps.rb
|
79
|
+
- lib/getch/filesystem/lvm/encrypt/device.rb
|
80
|
+
- lib/getch/filesystem/lvm/encrypt/format.rb
|
81
|
+
- lib/getch/filesystem/lvm/encrypt/mount.rb
|
82
|
+
- lib/getch/filesystem/lvm/encrypt/partition.rb
|
76
83
|
- lib/getch/filesystem/lvm/format.rb
|
77
84
|
- lib/getch/filesystem/lvm/mount.rb
|
78
85
|
- lib/getch/filesystem/lvm/partition.rb
|
metadata.gz.sig
CHANGED
Binary file
|