getch 0.1.3 → 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 +75 -35
- data/assets/network-stack.conf +63 -0
- data/assets/system.conf +38 -0
- data/bin/getch +14 -4
- data/lib/clean.rb +149 -0
- data/lib/cmdline.rb +128 -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 +94 -124
- 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 +11 -0
- data/lib/getch/config.rb +19 -53
- data/lib/getch/device.rb +67 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +11 -68
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +17 -25
- data/lib/getch/filesystem/ext4/encrypt/device.rb +13 -5
- data/lib/getch/filesystem/ext4/encrypt/format.rb +8 -15
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +9 -13
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +10 -82
- data/lib/getch/filesystem/ext4/encrypt/void.rb +63 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +4 -0
- 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/ext4/hybrid/void.rb +62 -0
- 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} +8 -3
- data/lib/getch/filesystem/ext4/minimal/config.rb +25 -0
- data/lib/getch/filesystem/ext4/{device.rb → minimal/deps.rb} +4 -3
- 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 +9 -6
- data/lib/getch/filesystem/zfs/encrypt/config.rb +12 -57
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +7 -86
- data/lib/getch/filesystem/zfs/encrypt/device.rb +9 -45
- data/lib/getch/filesystem/zfs/encrypt/format.rb +8 -90
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +16 -34
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +8 -50
- data/lib/getch/filesystem/zfs/encrypt.rb +4 -0
- 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 +3 -6
- data/lib/getch/filesystem.rb +2 -6
- data/lib/getch/gentoo/bootloader.rb +47 -0
- 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 +82 -52
- 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 +11 -12
- data/lib/getch/gentoo/use_flag.rb +74 -52
- data/lib/getch/gentoo.rb +11 -63
- data/lib/getch/guard.rb +71 -0
- data/lib/getch/helpers.rb +128 -48
- data/lib/getch/log.rb +91 -26
- data/lib/getch/options.rb +79 -40
- data/lib/getch/states.rb +37 -10
- 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/tarball.rb +89 -0
- data/lib/getch/void/terraform.rb +28 -0
- data/lib/getch/void/update.rb +33 -0
- data/lib/getch/void.rb +15 -0
- data/lib/getch.rb +104 -92
- 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 +96 -45
- metadata.gz.sig +0 -0
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -90
- data/Rakefile +0 -21
- data/bin/setup.sh +0 -90
- data/getch.gemspec +0 -25
- data/lib/getch/filesystem/clean.rb +0 -51
- data/lib/getch/filesystem/device.rb +0 -61
- data/lib/getch/filesystem/ext4/config.rb +0 -58
- data/lib/getch/filesystem/ext4/deps.rb +0 -22
- data/lib/getch/filesystem/ext4/format.rb +0 -28
- data/lib/getch/filesystem/ext4/mount.rb +0 -23
- data/lib/getch/filesystem/ext4/partition.rb +0 -52
- data/lib/getch/filesystem/lvm/config.rb +0 -59
- data/lib/getch/filesystem/lvm/deps.rb +0 -42
- data/lib/getch/filesystem/lvm/device.rb +0 -43
- data/lib/getch/filesystem/lvm/encrypt/config.rb +0 -71
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +0 -46
- data/lib/getch/filesystem/lvm/encrypt/device.rb +0 -46
- data/lib/getch/filesystem/lvm/encrypt/format.rb +0 -32
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +0 -25
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +0 -80
- data/lib/getch/filesystem/lvm/encrypt.rb +0 -15
- data/lib/getch/filesystem/lvm/format.rb +0 -29
- data/lib/getch/filesystem/lvm/mount.rb +0 -23
- data/lib/getch/filesystem/lvm/partition.rb +0 -69
- data/lib/getch/filesystem/mount.rb +0 -56
- data/lib/getch/filesystem/partition.rb +0 -77
- data/lib/getch/filesystem/zfs/config.rb +0 -57
- data/lib/getch/filesystem/zfs/deps.rb +0 -95
- data/lib/getch/filesystem/zfs/device.rb +0 -58
- data/lib/getch/filesystem/zfs/format.rb +0 -114
- data/lib/getch/filesystem/zfs/mount.rb +0 -48
- data/lib/getch/filesystem/zfs/partition.rb +0 -64
- data/lib/getch/gentoo/boot.rb +0 -109
- data/lib/getch/gentoo/chroot.rb +0 -77
- data/lib/getch/gentoo/config.rb +0 -129
- data/lib/getch/gentoo/stage.rb +0 -74
|
@@ -1,27 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mkfs'
|
|
4
|
+
|
|
1
5
|
module Getch
|
|
2
6
|
module FileSystem
|
|
3
7
|
module Ext4
|
|
4
8
|
module Encrypt
|
|
5
|
-
class Format
|
|
9
|
+
class Format
|
|
6
10
|
def initialize
|
|
7
|
-
|
|
8
|
-
@state = Getch::States.new()
|
|
9
|
-
format
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def format
|
|
13
|
-
return if STATES[:format]
|
|
14
|
-
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
|
15
|
-
exec("mkfs.ext4 -F #{@luks_root}")
|
|
16
|
-
exec("mkswap -f #{@dev_swap}")
|
|
17
|
-
exec("mkfs.ext4 -F #{@luks_home}") if @dev_home
|
|
18
|
-
@state.format
|
|
11
|
+
x
|
|
19
12
|
end
|
|
20
13
|
|
|
21
14
|
private
|
|
22
15
|
|
|
23
|
-
def
|
|
24
|
-
|
|
16
|
+
def x
|
|
17
|
+
Mkfs::Encrypt.new(DEVS, OPTIONS)
|
|
25
18
|
end
|
|
26
19
|
end
|
|
27
20
|
end
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mountfs'
|
|
2
4
|
|
|
3
5
|
module Getch
|
|
4
6
|
module FileSystem
|
|
5
7
|
module Ext4
|
|
6
8
|
module Encrypt
|
|
7
|
-
class Mount
|
|
9
|
+
class Mount
|
|
8
10
|
def initialize
|
|
9
|
-
|
|
10
|
-
@mount = Getch::FileSystem::Mount.new
|
|
11
|
-
@state = Getch::States.new()
|
|
11
|
+
x
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@mount.boot(@dev_boot)
|
|
19
|
-
@mount.esp(@dev_esp)
|
|
20
|
-
@mount.home(@luks_home)
|
|
21
|
-
@state.mount
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def x
|
|
17
|
+
MountFs::Encrypt.new(DEVS, OPTIONS)
|
|
22
18
|
end
|
|
23
19
|
end
|
|
24
20
|
end
|
|
@@ -1,94 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sgdisk'
|
|
4
|
+
require 'cryptsetup'
|
|
5
|
+
|
|
1
6
|
module Getch
|
|
2
7
|
module FileSystem
|
|
3
8
|
module Ext4
|
|
4
9
|
module Encrypt
|
|
5
|
-
class Partition
|
|
10
|
+
class Partition
|
|
6
11
|
def initialize
|
|
7
|
-
|
|
8
|
-
@state = Getch::States.new
|
|
9
|
-
@partition = Getch::FileSystem::Partition.new
|
|
10
|
-
@clean = Getch::FileSystem::Clean
|
|
11
|
-
@log = Log.new
|
|
12
|
-
run_partition
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def run_partition
|
|
16
|
-
return if STATES[:partition ]
|
|
17
|
-
@clean.struct(@disk, @cache_disk, @home_disk)
|
|
18
|
-
@clean.hdd(@disk, @cache_disk, @home_disk)
|
|
19
|
-
if Helpers::efi?
|
|
20
|
-
partition_efi
|
|
21
|
-
encrypt_efi
|
|
22
|
-
else
|
|
23
|
-
partition_bios
|
|
24
|
-
encrypt_bios
|
|
25
|
-
end
|
|
26
|
-
@state.partition
|
|
12
|
+
x
|
|
27
13
|
end
|
|
28
14
|
|
|
29
15
|
private
|
|
30
16
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# swap - Linux Swap - size of the ram
|
|
35
|
-
# / - Root
|
|
36
|
-
# /home - Home
|
|
37
|
-
@partition.efi(@dev_esp)
|
|
38
|
-
@partition.swap(@dev_swap)
|
|
39
|
-
@partition.root(@dev_root, "8309")
|
|
40
|
-
@partition.home(@dev_home, "8309") if @dev_home
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def encrypt_efi
|
|
44
|
-
@log.info("Format root")
|
|
45
|
-
Helpers::sys("cryptsetup luksFormat #{@dev_root}")
|
|
46
|
-
@log.debug("Opening root")
|
|
47
|
-
Helpers::sys("cryptsetup open --type luks #{@dev_root} cryptroot")
|
|
48
|
-
encrypt_home
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def encrypt_bios
|
|
52
|
-
@log.info("Format root for bios")
|
|
53
|
-
Helpers::sys("cryptsetup luksFormat --type luks1 #{@dev_root}")
|
|
54
|
-
@log.debug("Opening root")
|
|
55
|
-
Helpers::sys("cryptsetup open --type luks1 #{@dev_root} cryptroot")
|
|
56
|
-
encrypt_home
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def encrypt_home
|
|
60
|
-
if @dev_home then
|
|
61
|
-
create_secret_keys
|
|
62
|
-
@log.info("Format home with #{@key_path}")
|
|
63
|
-
Helpers::sys("cryptsetup luksFormat #{@dev_home} #{@key_path}")
|
|
64
|
-
@log.debug("Open home with key #{@key_path}")
|
|
65
|
-
exec("cryptsetup open --type luks -d #{@key_path} #{@dev_home} crypthome")
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def create_secret_keys
|
|
70
|
-
return if ! @dev_home
|
|
71
|
-
@log.info("Creating secret keys")
|
|
72
|
-
keys_dir = "/root/secretkeys"
|
|
73
|
-
key_name = "crypto_keyfile.bin"
|
|
74
|
-
@key_path = "#{keys_dir}/#{key_name}"
|
|
75
|
-
FileUtils.mkdir keys_dir, mode: 0700 if ! Dir.exist?(keys_dir)
|
|
76
|
-
exec("dd bs=512 count=4 if=/dev/urandom of=#{@key_path}")
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def partition_bios
|
|
80
|
-
# None - Bios Boot Partition - 1MiB
|
|
81
|
-
# swap - Linux Swap - size of the ram
|
|
82
|
-
# / - Root
|
|
83
|
-
# /home - Home
|
|
84
|
-
@partition.gpt(@dev_gpt)
|
|
85
|
-
@partition.swap(@dev_swap)
|
|
86
|
-
@partition.root(@dev_root, "8309")
|
|
87
|
-
@partition.home(@dev_home, "8309") if @dev_home
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def exec(cmd)
|
|
91
|
-
Getch::Command.new(cmd).run!
|
|
17
|
+
def x
|
|
18
|
+
Sgdisk::Encrypt.new(DEVS)
|
|
19
|
+
CryptSetup.new(DEVS, OPTIONS).format
|
|
92
20
|
end
|
|
93
21
|
end
|
|
94
22
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Ext4
|
|
6
|
+
module Encrypt
|
|
7
|
+
class Void < Device
|
|
8
|
+
include Helpers::Void
|
|
9
|
+
|
|
10
|
+
attr_reader :boot_disk
|
|
11
|
+
|
|
12
|
+
# Create key to avoid enter password twice
|
|
13
|
+
def create_key
|
|
14
|
+
add_key('volume.key', @dev_root)
|
|
15
|
+
add_key('home.key', @dev_home) if @home_disk
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Key need to be added in dracut.conf.d and crypttab
|
|
19
|
+
def add_key(name, dev)
|
|
20
|
+
command "dd bs=1 count=64 if=/dev/urandom of=/boot/#{name}"
|
|
21
|
+
puts " => Creating a key for #{dev}, password required:"
|
|
22
|
+
chroot "cryptsetup luksAddKey #{dev} /boot/#{name}"
|
|
23
|
+
command "chmod 000 /boot/#{name}"
|
|
24
|
+
#command "chmod -R g-rwx,o-rwx /boot"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def crypttab
|
|
28
|
+
conf = "#{MOUNTPOINT}/etc/crypttab"
|
|
29
|
+
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
|
30
|
+
line_crypttab('cryptswap', @dev_swap, '/dev/urandom', 'swap,discard,cipher=aes-xts-plain64:sha256,size=512') if @dev_swap
|
|
31
|
+
line_crypttab('cryptroot', @dev_root, '/boot/volume.key', 'luks')
|
|
32
|
+
line_crypttab('crypthome', @dev_home, '/boot/home.key', 'luks') if @home_disk
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def finish
|
|
36
|
+
puts '+ Enter in your system: chroot /mnt /bin/bash'
|
|
37
|
+
puts '+ Reboot with: shutdown -r now'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def b_uuid(dev)
|
|
43
|
+
device = dev.delete_prefix('/dev/')
|
|
44
|
+
Dir.glob('/dev/disk/by-uuid/*').each do |f|
|
|
45
|
+
link = File.readlink(f)
|
|
46
|
+
return f.delete_prefix('/dev/disk/by-uuid/') if link.match(/#{device}$/)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# line_crypttab("cryptswap", "sda2", "/dev/urandom", "luks")
|
|
51
|
+
def line_crypttab(mapname, dev, point, rest)
|
|
52
|
+
conf = "#{MOUNTPOINT}/etc/crypttab"
|
|
53
|
+
device = s_uuid(dev)
|
|
54
|
+
raise "No partuuid for #{dev} #{device}" unless device
|
|
55
|
+
raise "Bad partuuid for #{dev} #{device}" if device.kind_of? Array
|
|
56
|
+
|
|
57
|
+
add_line(conf, "#{mapname} PARTUUID=#{device} #{point} #{rest}")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fstab'
|
|
4
|
+
require 'dracut'
|
|
5
|
+
require 'cryptsetup'
|
|
6
|
+
|
|
7
|
+
module Getch
|
|
8
|
+
module FileSystem
|
|
9
|
+
module Ext4
|
|
10
|
+
module Hybrid
|
|
11
|
+
class Config
|
|
12
|
+
def initialize
|
|
13
|
+
x
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def x
|
|
19
|
+
Fstab::Hybrid.new(DEVS, OPTIONS).generate
|
|
20
|
+
Dracut::Hybrid.new(DEVS, OPTIONS).generate
|
|
21
|
+
CryptSetup.new(DEVS, OPTIONS).configs
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Ext4
|
|
6
|
+
module Hybrid
|
|
7
|
+
class Deps
|
|
8
|
+
def initialize
|
|
9
|
+
x
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
def x
|
|
15
|
+
install
|
|
16
|
+
service
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def install
|
|
20
|
+
case OPTIONS[:os]
|
|
21
|
+
when 'gentoo' then Install.new('sys-fs/cryptsetup sys-fs/lvm2')
|
|
22
|
+
when 'void' then Install.new('cryptsetup lvm2')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def service
|
|
27
|
+
systemd
|
|
28
|
+
openrc
|
|
29
|
+
runit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def systemd
|
|
33
|
+
Helpers.systemd? || return
|
|
34
|
+
|
|
35
|
+
exec('systemctl enable lvm2-monitor')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def openrc
|
|
39
|
+
Helpers.openrc? || return
|
|
40
|
+
|
|
41
|
+
exec('rc-update add lvm boot')
|
|
42
|
+
exec('rc-update add dmcrypt boot')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def runit
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def exec(cmd)
|
|
49
|
+
Getch::Chroot.new(cmd)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'devs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Hybrid
|
|
9
|
+
class Device
|
|
10
|
+
def initialize
|
|
11
|
+
@args = { start: true, boot: true, root: true }
|
|
12
|
+
x
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def x
|
|
18
|
+
Devs::Settings.new(@args, OPTIONS)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mkfs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Hybrid
|
|
9
|
+
class Format
|
|
10
|
+
def initialize
|
|
11
|
+
x
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def x
|
|
17
|
+
Mkfs::Hybrid.new(DEVS, OPTIONS)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mountfs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Hybrid
|
|
9
|
+
class Mount
|
|
10
|
+
def initialize
|
|
11
|
+
x
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def x
|
|
15
|
+
MountFs::Hybrid.new(DEVS, OPTIONS)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sgdisk'
|
|
4
|
+
require 'cryptsetup'
|
|
5
|
+
require 'lvm2'
|
|
6
|
+
|
|
7
|
+
module Getch
|
|
8
|
+
module FileSystem
|
|
9
|
+
module Ext4
|
|
10
|
+
module Hybrid
|
|
11
|
+
class Partition
|
|
12
|
+
def initialize
|
|
13
|
+
x
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def x
|
|
19
|
+
Sgdisk::Encrypt.new(DEVS)
|
|
20
|
+
CryptSetup.new(DEVS, OPTIONS).format
|
|
21
|
+
Lvm2::Hybrid.new(DEVS, OPTIONS).x
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Lvm
|
|
6
|
+
module Encrypt
|
|
7
|
+
class Void < Device
|
|
8
|
+
include Helpers::Void
|
|
9
|
+
|
|
10
|
+
attr_reader :boot_disk
|
|
11
|
+
|
|
12
|
+
# Create key to avoid enter password twice
|
|
13
|
+
def create_key
|
|
14
|
+
add_key('volume.key', @dev_root)
|
|
15
|
+
add_key('home.key', @dev_home) if @home_disk
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Key need to be added in dracut.conf.d and crypttab
|
|
19
|
+
def add_key(name, dev)
|
|
20
|
+
command "dd bs=1 count=64 if=/dev/urandom of=/boot/#{name}"
|
|
21
|
+
puts " => Creating a key for #{dev}, password required:"
|
|
22
|
+
chroot "cryptsetup luksAddKey #{dev} /boot/#{name}"
|
|
23
|
+
command "chmod 000 /boot/#{name}"
|
|
24
|
+
#command "chmod -R g-rwx,o-rwx /boot"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def crypttab
|
|
28
|
+
conf = "#{MOUNTPOINT}/etc/crypttab"
|
|
29
|
+
File.write(conf, "\n", mode: 'w', chmod: 0644)
|
|
30
|
+
add_line(conf, "cryptswap #{@lv_swap} /dev/urandom swap,discard,cipher=aes-xts-plain64:sha256,size=512")
|
|
31
|
+
line_crypttab(@vg, @dev_root, '/boot/volume.key', 'luks')
|
|
32
|
+
line_crypttab("crypthome", @dev_home, "/boot/home.key", "luks") if @home_disk
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def finish
|
|
36
|
+
puts '+ Enter in your system: chroot /mnt /bin/bash'
|
|
37
|
+
puts '+ Reboot with: shutdown -r now'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def b_uuid(dev)
|
|
43
|
+
device = dev.delete_prefix('/dev/')
|
|
44
|
+
Dir.glob('/dev/disk/by-uuid/*').each { |f|
|
|
45
|
+
link = File.readlink(f)
|
|
46
|
+
return f.delete_prefix('/dev/disk/by-uuid/') if link.match(/#{device}$/)
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# line_crypttab("cryptswap", "sda2", "/dev/urandom", "luks")
|
|
51
|
+
def line_crypttab(mapname, dev, point, rest)
|
|
52
|
+
conf = "#{MOUNTPOINT}/etc/crypttab"
|
|
53
|
+
device = s_uuid(dev)
|
|
54
|
+
raise "No partuuid for #{dev} #{device}" unless device
|
|
55
|
+
raise "Bad partuuid for #{dev} #{device}" if device.kind_of? Array
|
|
56
|
+
add_line(conf, "#{mapname} PARTUUID=#{device} #{point} #{rest}")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Ext4
|
|
6
|
+
module Hybrid
|
|
7
|
+
def self.end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require_relative 'hybrid/device'
|
|
15
|
+
require_relative 'hybrid/partition'
|
|
16
|
+
require_relative 'hybrid/format'
|
|
17
|
+
require_relative 'hybrid/mount'
|
|
18
|
+
require_relative 'hybrid/deps'
|
|
19
|
+
require_relative 'hybrid/config'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fstab'
|
|
4
|
+
require 'dracut'
|
|
5
|
+
|
|
6
|
+
module Getch
|
|
7
|
+
module FileSystem
|
|
8
|
+
module Ext4
|
|
9
|
+
module Lvm
|
|
10
|
+
class Config
|
|
11
|
+
def initialize
|
|
12
|
+
x
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def x
|
|
18
|
+
Fstab::Lvm.new(DEVS, OPTIONS).generate
|
|
19
|
+
Dracut::Lvm.new(DEVS, OPTIONS).generate
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Getch
|
|
4
|
+
module FileSystem
|
|
5
|
+
module Ext4
|
|
6
|
+
module Lvm
|
|
7
|
+
class Deps
|
|
8
|
+
def initialize
|
|
9
|
+
x
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
def x
|
|
15
|
+
install
|
|
16
|
+
service
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def install
|
|
22
|
+
case OPTIONS[:os]
|
|
23
|
+
when 'gentoo' then Install.new('sys-fs/lvm2')
|
|
24
|
+
when 'void' then Install.new('lvm2')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def service
|
|
29
|
+
systemd
|
|
30
|
+
openrc
|
|
31
|
+
runit
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def systemd
|
|
35
|
+
Helpers.systemd? || return
|
|
36
|
+
|
|
37
|
+
exec('systemctl enable lvm2-monitor')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def openrc
|
|
41
|
+
Helpers.openrc? || return
|
|
42
|
+
|
|
43
|
+
exec('rc-update add lvm boot')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def runit
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def exec(cmd)
|
|
50
|
+
Getch::Chroot.new(cmd)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'devs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Lvm
|
|
9
|
+
class Device
|
|
10
|
+
def initialize
|
|
11
|
+
@args = { start: true, root: true }
|
|
12
|
+
@vg = OPTIONS[:vg_name] ||= 'vg0'
|
|
13
|
+
@lv_root = "/dev/#{@vg}/root"
|
|
14
|
+
@lv_swap = "/dev/#{@vg}/swap"
|
|
15
|
+
@lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
|
|
16
|
+
x
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def x
|
|
22
|
+
Devs::Settings.new(@args, OPTIONS)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mkfs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Lvm
|
|
9
|
+
class Format
|
|
10
|
+
def initialize
|
|
11
|
+
x
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def x
|
|
15
|
+
Mkfs::Lvm.new(DEVS, OPTIONS)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mountfs'
|
|
4
|
+
|
|
5
|
+
module Getch
|
|
6
|
+
module FileSystem
|
|
7
|
+
module Ext4
|
|
8
|
+
module Lvm
|
|
9
|
+
class Mount
|
|
10
|
+
def initialize
|
|
11
|
+
x
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def x
|
|
15
|
+
MountFs::Lvm.new(DEVS, OPTIONS)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|