getch 0.1.0 → 0.1.1
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.tar.gz.sig +0 -0
- data/CHANGELOG.md +9 -0
- data/README.md +18 -4
- data/lib/getch.rb +14 -7
- data/lib/getch/command.rb +18 -4
- data/lib/getch/filesystem.rb +5 -0
- data/lib/getch/filesystem/clean.rb +51 -0
- data/lib/getch/filesystem/device.rb +55 -0
- data/lib/getch/filesystem/ext4/config.rb +8 -9
- data/lib/getch/filesystem/ext4/device.rb +2 -7
- data/lib/getch/filesystem/ext4/encrypt/config.rb +9 -9
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +1 -1
- data/lib/getch/filesystem/ext4/encrypt/device.rb +3 -8
- data/lib/getch/filesystem/ext4/encrypt/format.rb +3 -5
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +6 -43
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +19 -38
- data/lib/getch/filesystem/ext4/format.rb +3 -5
- data/lib/getch/filesystem/ext4/mount.rb +7 -46
- data/lib/getch/filesystem/ext4/partition.rb +16 -39
- data/lib/getch/filesystem/lvm/config.rb +5 -5
- data/lib/getch/filesystem/lvm/deps.rb +3 -2
- data/lib/getch/filesystem/lvm/device.rb +23 -7
- data/lib/getch/filesystem/lvm/encrypt/config.rb +3 -3
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +1 -1
- data/lib/getch/filesystem/lvm/encrypt/device.rb +23 -7
- data/lib/getch/filesystem/lvm/encrypt/format.rb +3 -3
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +7 -46
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +19 -31
- data/lib/getch/filesystem/lvm/format.rb +11 -7
- data/lib/getch/filesystem/lvm/mount.rb +7 -46
- data/lib/getch/filesystem/lvm/partition.rb +19 -31
- data/lib/getch/filesystem/mount.rb +56 -0
- data/lib/getch/filesystem/partition.rb +77 -0
- data/lib/getch/filesystem/zfs/config.rb +4 -5
- data/lib/getch/filesystem/zfs/deps.rb +3 -6
- data/lib/getch/filesystem/zfs/device.rb +30 -9
- data/lib/getch/filesystem/zfs/encrypt/config.rb +7 -7
- data/lib/getch/filesystem/zfs/encrypt/deps.rb +2 -6
- data/lib/getch/filesystem/zfs/encrypt/device.rb +30 -9
- data/lib/getch/filesystem/zfs/encrypt/format.rb +84 -1
- data/lib/getch/filesystem/zfs/encrypt/mount.rb +4 -20
- data/lib/getch/filesystem/zfs/encrypt/partition.rb +15 -111
- data/lib/getch/filesystem/zfs/format.rb +84 -2
- data/lib/getch/filesystem/zfs/mount.rb +5 -24
- data/lib/getch/filesystem/zfs/partition.rb +15 -108
- data/lib/getch/gentoo.rb +2 -1
- data/lib/getch/gentoo/boot.rb +2 -2
- data/lib/getch/gentoo/chroot.rb +10 -24
- data/lib/getch/gentoo/config.rb +22 -2
- data/lib/getch/gentoo/sources.rb +11 -11
- data/lib/getch/helpers.rb +13 -0
- data/lib/getch/options.rb +20 -5
- data/lib/getch/version.rb +1 -1
- metadata +6 -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: 80a9841959ac12d1fccf5a4dc5834001e802b36dd1798e297db0cd85f772be03
|
4
|
+
data.tar.gz: 4bcdc9927577f8de4ba1d992e055d00cc11fe42f8aa8a66b52fff06f2c93ca95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837136b17e66962df98d4e982a4fc10bcd3aefd58fdcf72014079d639d605c1f41b7e9663e1d8e95dba8e78705e448b06a86c36158b8b2590d34febbfdfcd541
|
7
|
+
data.tar.gz: cb9b794f65827c4c7facc6441bd17ebb01409c3d07fc1fc68ca9e7ee6f741b4571cc19e62634069e3eeb4c45ca055c4eb0c2babc58cad033d1e32996c53e0b76
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
* Change mountpoint for the esp at /efi rather than /boot/efi
|
2
|
+
* Replace Garden by Bask https://github.com/szorfein/bask
|
3
|
+
* Correct option --username USERNAME, do not create a new partition.
|
4
|
+
* New set of options --separate-{boot,cache,home} to install them on another disk
|
5
|
+
* Refactor codes
|
6
|
+
* Add cpu name to COMMON_FLAGS
|
7
|
+
* Add cpuflags with app-portage/cpuid2cpuflags
|
8
|
+
+ Use the whole disk space available for / when option --username is unset
|
9
|
+
|
1
10
|
## 0.1.0, release 2020-10-15
|
2
11
|
* Add the (Zeta) filesystem ZFS
|
3
12
|
* `emerge --depclean` to save space.
|
data/README.md
CHANGED
@@ -5,14 +5,16 @@ 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
|
-
BIOS system will use Grub2 and
|
9
|
-
+
|
10
|
-
+
|
8
|
+
BIOS system will use `Grub2` and `systemd-boot` for UEFI. Filesystem supported by Getch are for now:
|
9
|
+
+ Ext4
|
10
|
+
+ LVM
|
11
|
+
+ ZFS
|
11
12
|
|
12
13
|
Encryption is also supported.
|
13
14
|
|
14
15
|
The ISO images i was able to test and that works:
|
15
16
|
+ [Archlinux](https://www.archlinux.org/download/)
|
17
|
+
+ [Archaeidae](https://github.com/szorfein/archaeidae): Custom Archiso that includes ZFS support.
|
16
18
|
|
17
19
|
## Install
|
18
20
|
Getch is cryptographically signed, so add my public key (if you haven’t already) as a trusted certificate.
|
@@ -28,7 +30,7 @@ When you boot from an `iso`, you can install `ruby`, `getch` and correct your `P
|
|
28
30
|
# source ~/.zshrc # or ~/.bashrc
|
29
31
|
|
30
32
|
## Usage
|
31
|
-
Just ensure than the script is run with a root account
|
33
|
+
Just ensure than the script is run with a root account.
|
32
34
|
|
33
35
|
# getch -h
|
34
36
|
|
@@ -51,6 +53,10 @@ Encrypt with ext4 and create a home directory /home/ninja
|
|
51
53
|
|
52
54
|
# getch --format ext4 --encrypt --username ninja
|
53
55
|
|
56
|
+
With ZFS:
|
57
|
+
|
58
|
+
# getch --format zfs
|
59
|
+
|
54
60
|
## Troubleshooting
|
55
61
|
|
56
62
|
#### LVM
|
@@ -60,6 +66,14 @@ Unless your old LVM volume group is also named `vg0`, `getch` may fail to partit
|
|
60
66
|
To decrypt your disk on BIOS system, you have to enter your password two times. One time for Grub and another time for the initramfs (Genkernel). [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
|
61
67
|
Also with GRUB, only a `us` keymap is working.
|
62
68
|
|
69
|
+
#### With ZFS
|
70
|
+
When you boot, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just reboot on your ISO:
|
71
|
+
|
72
|
+
# zpool import -N -R /mnt zpool
|
73
|
+
# zpool export -a
|
74
|
+
|
75
|
+
And it's all.
|
76
|
+
|
63
77
|
## Issues
|
64
78
|
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:
|
65
79
|
+ lspci
|
data/lib/getch.rb
CHANGED
@@ -15,6 +15,9 @@ module Getch
|
|
15
15
|
disk: 'sda',
|
16
16
|
fs: 'ext4',
|
17
17
|
username: nil,
|
18
|
+
boot_disk: nil,
|
19
|
+
cache_disk: nil,
|
20
|
+
home_disk: nil,
|
18
21
|
encrypt: false,
|
19
22
|
verbose: false
|
20
23
|
}
|
@@ -51,13 +54,17 @@ module Getch
|
|
51
54
|
|
52
55
|
def self.resume_options(opts)
|
53
56
|
puts "\nBuild Gentoo with the following args:\n"
|
54
|
-
puts "
|
55
|
-
puts "
|
56
|
-
puts "
|
57
|
-
puts "
|
58
|
-
puts "
|
59
|
-
puts "
|
60
|
-
puts "
|
57
|
+
puts "Lang: #{DEFAULT_OPTIONS[:language]}"
|
58
|
+
puts "Zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
|
59
|
+
puts "Keymap: #{DEFAULT_OPTIONS[:keymap]}"
|
60
|
+
puts "Disk: #{DEFAULT_OPTIONS[:disk]}"
|
61
|
+
puts "Filesystem: #{DEFAULT_OPTIONS[:fs]}"
|
62
|
+
puts "Username: #{DEFAULT_OPTIONS[:username]}"
|
63
|
+
puts "Encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
|
64
|
+
puts
|
65
|
+
puts "separate-boot disk: #{DEFAULT_OPTIONS[:boot_disk]}"
|
66
|
+
puts "separate-cache disk: #{DEFAULT_OPTIONS[:cache_disk]}"
|
67
|
+
puts "separate-home disk: #{DEFAULT_OPTIONS[:home_disk]}"
|
61
68
|
puts
|
62
69
|
print "Continue? (n,y) "
|
63
70
|
case gets.chomp
|
data/lib/getch/command.rb
CHANGED
@@ -127,19 +127,21 @@ module Getch
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
class
|
130
|
+
class Bask
|
131
131
|
def initialize(cmd)
|
132
132
|
@gentoo = MOUNTPOINT
|
133
133
|
@cmd = cmd
|
134
134
|
@log = Getch::Log.new
|
135
|
+
@version = "0.4"
|
135
136
|
end
|
136
137
|
|
137
138
|
def run!
|
138
|
-
|
139
|
+
download_bask if ! Dir.exist? "#{MOUNTPOINT}/root/bask-#{@version}"
|
140
|
+
@log.info "Running Bask: #{@cmd}"
|
139
141
|
cmd = "chroot #{@gentoo} /bin/bash -c \"source /etc/profile \
|
140
142
|
&& env-update \
|
141
|
-
&& cd /root/
|
142
|
-
&& ./
|
143
|
+
&& cd /root/bask-#{@version} \
|
144
|
+
&& ./bask.sh #{@cmd} -k /usr/src/linux\""
|
143
145
|
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
144
146
|
while line = stdout_err.gets
|
145
147
|
puts line
|
@@ -152,6 +154,18 @@ module Getch
|
|
152
154
|
end
|
153
155
|
end
|
154
156
|
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def download_bask
|
161
|
+
@log.info "Installing Bask..."
|
162
|
+
url = "https://github.com/szorfein/bask/archive/v#{@version}.tar.gz"
|
163
|
+
file = "bask-#{@version}.tar.gz"
|
164
|
+
|
165
|
+
Dir.chdir("#{MOUNTPOINT}/root")
|
166
|
+
Helpers::get_file_online(url, file)
|
167
|
+
Getch::Command.new("tar xzf #{file}").run!
|
168
|
+
end
|
155
169
|
end
|
156
170
|
|
157
171
|
class Chroot < Command
|
data/lib/getch/filesystem.rb
CHANGED
@@ -3,6 +3,11 @@ module Getch
|
|
3
3
|
end
|
4
4
|
end
|
5
5
|
|
6
|
+
require_relative 'filesystem/device'
|
7
|
+
require_relative 'filesystem/clean'
|
8
|
+
require_relative 'filesystem/partition'
|
9
|
+
require_relative 'filesystem/mount'
|
10
|
+
|
6
11
|
require_relative 'filesystem/ext4'
|
7
12
|
require_relative 'filesystem/lvm'
|
8
13
|
require_relative 'filesystem/zfs'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
module Clean
|
4
|
+
def self.clean_hdd(disk)
|
5
|
+
return if ! disk
|
6
|
+
raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
|
7
|
+
puts
|
8
|
+
print "Cleaning data on #{disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? [y,N] "
|
9
|
+
case gets.chomp
|
10
|
+
when /^y|^Y/
|
11
|
+
bloc=`blockdev --getbsz /dev/#{disk}`.chomp
|
12
|
+
Helpers::sys("dd if=/dev/urandom of=/dev/#{disk} bs=#{bloc} status=progress")
|
13
|
+
else
|
14
|
+
return
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.clean_struct(disk)
|
19
|
+
return if ! disk
|
20
|
+
raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
|
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| clean_hdd(d) }
|
27
|
+
end
|
28
|
+
# See https://wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing
|
29
|
+
# for SSD
|
30
|
+
def self.sdd
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.struct(*disks)
|
34
|
+
disks.each { |d| clean_struct(d) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.old_vg(disk, vg)
|
38
|
+
oldvg = `vgdisplay | grep #{vg}`.chomp
|
39
|
+
Helpers::sys("vgremove -f #{vg}") if oldvg != ''
|
40
|
+
Helpers::sys("pvremove -f #{disk}") if oldvg != '' and File.exist? disk
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.old_zpool
|
44
|
+
oldzpool = `zpool status | grep pool:`.gsub(/pool: /, '').delete(' ').split("\n")
|
45
|
+
if oldzpool[0] != "" and $?.success?
|
46
|
+
oldzpool.each { |p| Helpers::sys("zpool destroy #{p}") if p }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
class Device
|
4
|
+
def initialize
|
5
|
+
@efi = Helpers::efi?
|
6
|
+
@root_part = 1
|
7
|
+
@user = DEFAULT_OPTIONS[:username]
|
8
|
+
|
9
|
+
@disk = DEFAULT_OPTIONS[:disk]
|
10
|
+
@boot_disk = DEFAULT_OPTIONS[:boot_disk]
|
11
|
+
@cache_disk = DEFAULT_OPTIONS[:cache_disk]
|
12
|
+
@home_disk = DEFAULT_OPTIONS[:home_disk]
|
13
|
+
|
14
|
+
search_boot
|
15
|
+
search_swap
|
16
|
+
search_root
|
17
|
+
search_home
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def search_boot
|
22
|
+
if @boot_disk
|
23
|
+
@dev_gpt = @efi ? nil : "/dev/#{@boot_disk}1"
|
24
|
+
@dev_esp = @efi ? "/dev/#{@boot_disk}1" : nil
|
25
|
+
else
|
26
|
+
@dev_gpt = @efi ? nil : "/dev/#{@disk}#{@root_part}"
|
27
|
+
@dev_esp = @efi ? "/dev/#{@disk}#{@root_part}" : nil
|
28
|
+
@boot_disk = @disk # used by grub
|
29
|
+
@root_part += 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_swap
|
34
|
+
if @cache_disk
|
35
|
+
@dev_swap = "/dev/#{@cache_disk}1"
|
36
|
+
else
|
37
|
+
@dev_swap = "/dev/#{@disk}#{@root_part}"
|
38
|
+
@root_part += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def search_root
|
43
|
+
@dev_root = "/dev/#{@disk}#{@root_part}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def search_home
|
47
|
+
if @home_disk
|
48
|
+
@dev_home = "/dev/#{@home_disk}1"
|
49
|
+
else
|
50
|
+
@dev_home = nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -17,7 +17,7 @@ module Getch
|
|
17
17
|
|
18
18
|
def systemd_boot
|
19
19
|
return if ! Helpers::efi?
|
20
|
-
esp = '/
|
20
|
+
esp = '/efi'
|
21
21
|
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
22
22
|
datas_gentoo = [
|
23
23
|
'title Gentoo Linux',
|
@@ -30,28 +30,27 @@ 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=#{@
|
33
|
+
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"
|
34
34
|
File.write(file, cmdline, mode: 'a')
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def gen_uuid
|
40
|
-
@partuuid_root =
|
41
|
-
@
|
40
|
+
@partuuid_root = Helpers::partuuid(@dev_root)
|
41
|
+
@partuuid_swap = Helpers::partuuid(@dev_swap)
|
42
42
|
@uuid_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
43
|
-
@
|
44
|
-
@uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
|
43
|
+
@uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
|
45
44
|
@uuid_home = `lsblk -o "UUID" #{@dev_home} | tail -1`.chomp() if @dev_home
|
46
45
|
end
|
47
46
|
|
48
47
|
def data_fstab
|
49
|
-
|
50
|
-
swap = @dev_swap ? "
|
48
|
+
esp = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
49
|
+
swap = @dev_swap ? "PARTUUID=#{@partuuid_swap} none swap discard 0 0" : ''
|
51
50
|
root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
52
51
|
home = @dev_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
|
53
52
|
|
54
|
-
[
|
53
|
+
[ esp, swap, root, home ]
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
@@ -1,14 +1,9 @@
|
|
1
1
|
module Getch
|
2
2
|
module FileSystem
|
3
3
|
module Ext4
|
4
|
-
class Device
|
4
|
+
class Device < Getch::FileSystem::Device
|
5
5
|
def initialize
|
6
|
-
|
7
|
-
@user = DEFAULT_OPTIONS[:username]
|
8
|
-
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
9
|
-
@dev_root = "/dev/#{@disk}2"
|
10
|
-
@dev_swap = "/dev/#{@disk}3"
|
11
|
-
@dev_home = @user ? "/dev/#{@disk}4" : nil
|
6
|
+
super
|
12
7
|
end
|
13
8
|
end
|
14
9
|
end
|
@@ -22,21 +22,21 @@ module Getch
|
|
22
22
|
|
23
23
|
def systemd_boot
|
24
24
|
return if ! Helpers::efi?
|
25
|
-
esp = '/
|
25
|
+
esp = '/efi'
|
26
26
|
dir = "#{@root_dir}/#{esp}/loader/entries/"
|
27
27
|
datas_gentoo = [
|
28
28
|
'title Gentoo Linux',
|
29
29
|
'linux /vmlinuz',
|
30
30
|
'initrd /initramfs',
|
31
|
-
"options crypt_root=
|
31
|
+
"options crypt_root=PARTUUID=#{@partuuid_root} root=/dev/mapper/root init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} rw"
|
32
32
|
]
|
33
33
|
File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
|
34
34
|
end
|
35
35
|
|
36
36
|
def crypttab
|
37
|
-
home = @
|
37
|
+
home = @home_disk ? "crypthome UUID=#{@uuid_home} /root/secretkeys/crypto_keyfile.bin luks" : ''
|
38
38
|
datas = [
|
39
|
-
"cryptswap
|
39
|
+
"cryptswap PARTUUID=#{@partuuid_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=256",
|
40
40
|
home
|
41
41
|
]
|
42
42
|
File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
|
@@ -46,7 +46,7 @@ module Getch
|
|
46
46
|
return if Helpers::efi?
|
47
47
|
file = "#{@root_dir}/etc/default/grub"
|
48
48
|
cmdline = [
|
49
|
-
"GRUB_CMDLINE_LINUX=\"crypt_root=
|
49
|
+
"GRUB_CMDLINE_LINUX=\"crypt_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 keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
|
50
50
|
"GRUB_ENABLE_CRYPTODISK=y"
|
51
51
|
]
|
52
52
|
File.write(file, cmdline.join("\n"), mode: 'a')
|
@@ -55,16 +55,16 @@ module Getch
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def gen_uuid
|
58
|
-
@partuuid_root =
|
59
|
-
@
|
58
|
+
@partuuid_root = Helpers::partuuid(@dev_root)
|
59
|
+
@partuuid_swap = Helpers::partuuid(@dev_swap)
|
60
60
|
@uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
|
61
|
-
@
|
61
|
+
@uuid_esp = Helpers::uuid(@dev_esp) if @dev_esp
|
62
62
|
@uuid_root = `lsblk -d -o "UUID" #{@luks_root} | tail -1`.chomp() if @dev_root
|
63
63
|
@uuid_home = `lsblk -d -o "UUID" #{@dev_home} | tail -1`.chomp() if @luks_home
|
64
64
|
end
|
65
65
|
|
66
66
|
def data_fstab
|
67
|
-
boot_efi = @
|
67
|
+
boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
|
68
68
|
swap = @dev_swap ? "#{@luks_swap} none swap discard 0 0 " : ''
|
69
69
|
root = @dev_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
|
70
70
|
home = @dev_home ? "#{@luks_home} /home/#{@user} ext4 defaults 0 2" : ''
|
@@ -2,16 +2,11 @@ module Getch
|
|
2
2
|
module FileSystem
|
3
3
|
module Ext4
|
4
4
|
module Encrypt
|
5
|
-
class Device
|
5
|
+
class Device < Getch::FileSystem::Device
|
6
6
|
def initialize
|
7
|
-
|
8
|
-
@user = DEFAULT_OPTIONS[:username]
|
9
|
-
@dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
|
10
|
-
@dev_root = "/dev/#{@disk}2"
|
11
|
-
@dev_swap = "/dev/#{@disk}3"
|
12
|
-
@dev_home = @user ? "/dev/#{@disk}4" : nil
|
7
|
+
super
|
13
8
|
@luks_root = "/dev/mapper/cryptroot"
|
14
|
-
@luks_home = @
|
9
|
+
@luks_home = @home_disk ? "/dev/mapper/crypthome" : nil
|
15
10
|
@luks_swap = "/dev/mapper/cryptswap"
|
16
11
|
end
|
17
12
|
end
|
@@ -5,18 +5,16 @@ module Getch
|
|
5
5
|
class Format < Getch::FileSystem::Ext4::Encrypt::Device
|
6
6
|
def initialize
|
7
7
|
super
|
8
|
-
@fs = 'ext4'
|
9
8
|
@state = Getch::States.new()
|
10
9
|
format
|
11
10
|
end
|
12
11
|
|
13
12
|
def format
|
14
13
|
return if STATES[:format]
|
15
|
-
|
16
|
-
exec("mkfs.
|
17
|
-
exec("mkfs.#{@fs} -F #{@luks_root}")
|
14
|
+
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
15
|
+
exec("mkfs.ext4 -F #{@luks_root}")
|
18
16
|
exec("mkswap -f #{@dev_swap}")
|
19
|
-
exec("mkfs
|
17
|
+
exec("mkfs.ext4 -F #{@luks_home}") if @dev_home
|
20
18
|
@state.format
|
21
19
|
end
|
22
20
|
|