getch 0.1.0 → 0.1.1
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 +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
@@ -12,10 +12,10 @@ module Getch
|
|
12
12
|
|
13
13
|
def format
|
14
14
|
return if STATES[:format]
|
15
|
-
puts "Format #{@disk}
|
16
|
-
exec("mkfs.fat -F32 #{@
|
15
|
+
puts "Format #{@disk}"
|
16
|
+
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
17
17
|
exec("mkfs.#{@fs} -F #{@dev_boot}") if @dev_boot
|
18
|
-
|
18
|
+
exec("mkswap -f #{@lv_swap}")
|
19
19
|
exec("mkfs.#{@fs} -F #{@lv_root}")
|
20
20
|
exec("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
|
21
21
|
@state.format
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
1
|
module Getch
|
4
2
|
module FileSystem
|
5
3
|
module Lvm
|
@@ -7,54 +5,17 @@ module Getch
|
|
7
5
|
class Mount < Getch::FileSystem::Lvm::Encrypt::Device
|
8
6
|
def initialize
|
9
7
|
super
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@boot_efi_dir = "#{@root_dir}/boot/efi"
|
13
|
-
@home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
|
14
|
-
@state = Getch::States.new()
|
8
|
+
@mount = Getch::FileSystem::Mount.new
|
9
|
+
@state = Getch::States.new
|
15
10
|
end
|
16
11
|
|
17
12
|
def run
|
18
13
|
return if STATES[:mount]
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
14
|
+
@mount.swap(@lv_swap)
|
15
|
+
@mount.root(@lv_root)
|
16
|
+
@mount.boot(@dev_boot)
|
17
|
+
@mount.esp(@dev_esp)
|
18
|
+
@mount.home(@lv_home)
|
58
19
|
@state.mount
|
59
20
|
end
|
60
21
|
end
|
@@ -6,14 +6,17 @@ module Getch
|
|
6
6
|
def initialize
|
7
7
|
super
|
8
8
|
@state = Getch::States.new()
|
9
|
+
@clean = Getch::FileSystem::Clean
|
10
|
+
@partition = Getch::FileSystem::Partition.new
|
9
11
|
@log = Log.new
|
10
12
|
run_partition
|
11
13
|
end
|
12
14
|
|
13
15
|
def run_partition
|
14
16
|
return if STATES[:partition ]
|
15
|
-
|
16
|
-
|
17
|
+
@clean.old_vg(@dev_root, @vg)
|
18
|
+
@clean.struct(@disk, @cache_disk, @home_disk)
|
19
|
+
@clean.hdd(@disk, @cache_disk, @home_disk)
|
17
20
|
partition
|
18
21
|
encrypt
|
19
22
|
lvm
|
@@ -22,35 +25,14 @@ module Getch
|
|
22
25
|
|
23
26
|
private
|
24
27
|
|
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
28
|
def partition
|
47
29
|
if Helpers::efi?
|
48
|
-
|
49
|
-
|
30
|
+
@partition.efi(@dev_esp)
|
31
|
+
@partition.root(@dev_root, "8e00")
|
50
32
|
else
|
51
|
-
|
52
|
-
|
53
|
-
|
33
|
+
@partition.gpt(@dev_gpt)
|
34
|
+
@partition.boot(@dev_boot)
|
35
|
+
@partition.root(@dev_root, "8e00")
|
54
36
|
end
|
55
37
|
end
|
56
38
|
|
@@ -66,15 +48,21 @@ module Getch
|
|
66
48
|
exec("pvcreate -f #{@luks_root}")
|
67
49
|
exec("vgcreate -f #{@vg} #{@luks_root}")
|
68
50
|
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
69
|
-
exec("lvcreate -y -Wy -Zy -L 15G -n root #{@vg}")
|
70
51
|
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
71
|
-
|
52
|
+
|
53
|
+
if @user
|
54
|
+
exec("lvcreate -y -Wy -Zy -L 18G -n root #{@vg}")
|
55
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}")
|
56
|
+
else
|
57
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n root #{@vg}")
|
58
|
+
end
|
59
|
+
|
72
60
|
exec("vgchange --available y")
|
73
61
|
end
|
74
62
|
|
75
63
|
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
76
64
|
# Partition_efi
|
77
|
-
# /
|
65
|
+
# /efi - EFI system partition - 260MB
|
78
66
|
# / - Root
|
79
67
|
|
80
68
|
# Partition_bios
|
@@ -4,21 +4,25 @@ module Getch
|
|
4
4
|
class Format < Getch::FileSystem::Lvm::Device
|
5
5
|
def initialize
|
6
6
|
super
|
7
|
-
@fs = 'ext4'
|
8
7
|
@state = Getch::States.new()
|
9
8
|
format
|
10
9
|
end
|
11
10
|
|
12
11
|
def format
|
13
12
|
return if STATES[:format]
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
system("mkfs.#{@fs} -F #{@lv_home}") if @lv_home
|
13
|
+
exec("mkfs.fat -F32 #{@dev_esp}") if @dev_esp
|
14
|
+
exec("mkfs.ext4 -F #{@dev_boot}") if @dev_boot
|
15
|
+
exec("mkswap -f #{@lv_swap}")
|
16
|
+
exec("mkfs.ext4 -F #{@lv_root}")
|
17
|
+
exec("mkfs.ext4 -F #{@lv_home}") if @lv_home
|
20
18
|
@state.format
|
21
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def exec(cmd)
|
24
|
+
Getch::Command.new(cmd).run!
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,59 +1,20 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
1
|
module Getch
|
4
2
|
module FileSystem
|
5
3
|
module Lvm
|
6
4
|
class Mount < Getch::FileSystem::Lvm::Device
|
7
5
|
def initialize
|
8
6
|
super
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@boot_efi_dir = "#{@root_dir}/boot/efi"
|
12
|
-
@home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
|
13
|
-
@state = Getch::States.new()
|
7
|
+
@mount = Getch::FileSystem::Mount.new
|
8
|
+
@state = Getch::States.new
|
14
9
|
end
|
15
10
|
|
16
11
|
def run
|
17
12
|
return if STATES[:mount]
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@state.mount
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def mount_swap
|
29
|
-
return if ! @lv_swap
|
30
|
-
system("swapon #{@lv_swap}")
|
31
|
-
end
|
32
|
-
|
33
|
-
def mount_root
|
34
|
-
return if ! @lv_root
|
35
|
-
Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
|
36
|
-
system("mount #{@lv_root} #{@root_dir}")
|
37
|
-
end
|
38
|
-
|
39
|
-
def mount_boot_efi
|
40
|
-
return if ! @dev_boot_efi
|
41
|
-
FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
|
42
|
-
system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
|
43
|
-
end
|
44
|
-
|
45
|
-
def mount_boot
|
46
|
-
return if ! @dev_boot
|
47
|
-
FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
|
48
|
-
system("mount #{@dev_boot} #{@boot_dir}")
|
49
|
-
end
|
50
|
-
|
51
|
-
def mount_home
|
52
|
-
return if ! @lv_home
|
53
|
-
if @user != nil then
|
54
|
-
FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
|
55
|
-
system("mount #{@lv_home} #{@home_dir}")
|
56
|
-
end
|
13
|
+
@mount.swap(@lv_swap)
|
14
|
+
@mount.root(@lv_root)
|
15
|
+
@mount.boot(@dev_boot)
|
16
|
+
@mount.esp(@dev_esp)
|
17
|
+
@mount.home(@lv_home)
|
57
18
|
@state.mount
|
58
19
|
end
|
59
20
|
end
|
@@ -5,13 +5,16 @@ module Getch
|
|
5
5
|
def initialize
|
6
6
|
super
|
7
7
|
@state = Getch::States.new()
|
8
|
+
@partition = Getch::FileSystem::Partition.new
|
9
|
+
@clean = Getch::FileSystem::Clean
|
8
10
|
run_partition
|
9
11
|
end
|
10
12
|
|
11
13
|
def run_partition
|
12
14
|
return if STATES[:partition ]
|
13
|
-
|
14
|
-
|
15
|
+
@clean.old_vg(@dev_root, @vg)
|
16
|
+
@clean.struct(@disk, @cache_disk, @home_disk)
|
17
|
+
@clean.hdd(@disk, @cache_disk, @home_disk)
|
15
18
|
partition
|
16
19
|
lvm
|
17
20
|
@state.partition
|
@@ -19,35 +22,14 @@ module Getch
|
|
19
22
|
|
20
23
|
private
|
21
24
|
|
22
|
-
def clear_struct
|
23
|
-
oldvg = `vgdisplay | grep #{@vg}`.chomp
|
24
|
-
exec("vgremove -f #{@vg}") if oldvg != '' # remove older volume group
|
25
|
-
exec("pvremove -f #{@dev_root}") if oldvg != '' and File.exist? @dev_root # remove older volume group
|
26
|
-
|
27
|
-
exec("sgdisk -Z /dev/#{@disk}")
|
28
|
-
exec("wipefs -a /dev/#{@disk}")
|
29
|
-
end
|
30
|
-
|
31
|
-
def cleaning
|
32
|
-
puts
|
33
|
-
print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
34
|
-
case gets.chomp
|
35
|
-
when /^y|^Y/
|
36
|
-
bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
|
37
|
-
exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
|
38
|
-
else
|
39
|
-
return
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
25
|
def partition
|
44
26
|
if Helpers::efi?
|
45
|
-
|
46
|
-
|
27
|
+
@partition.efi(@dev_esp)
|
28
|
+
@partition.root(@dev_root, "8e00")
|
47
29
|
else
|
48
|
-
|
49
|
-
|
50
|
-
|
30
|
+
@partition.gpt(@dev_gpt)
|
31
|
+
@partition.boot(@dev_boot)
|
32
|
+
@partition.root(@dev_root, "8e00")
|
51
33
|
end
|
52
34
|
end
|
53
35
|
|
@@ -56,15 +38,21 @@ module Getch
|
|
56
38
|
exec("pvcreate -f #{@dev_root}")
|
57
39
|
exec("vgcreate -f #{@vg} #{@dev_root}")
|
58
40
|
# Wipe old signature: https://github.com/chef-cookbooks/lvm/issues/45
|
59
|
-
exec("lvcreate -y -Wy -Zy -L 15G -n root #{@vg}")
|
60
41
|
exec("lvcreate -y -Wy -Zy -L #{mem} -n swap #{@vg}")
|
61
|
-
|
42
|
+
|
43
|
+
if @user
|
44
|
+
exec("lvcreate -y -Wy -Zy -L 18G -n root #{@vg}")
|
45
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n home #{@vg}")
|
46
|
+
else
|
47
|
+
exec("lvcreate -y -Wy -Zy -l 100%FREE -n root #{@vg}")
|
48
|
+
end
|
49
|
+
|
62
50
|
exec("vgchange --available y")
|
63
51
|
end
|
64
52
|
|
65
53
|
# Follow https://wiki.archlinux.org/index.php/Partitioning
|
66
54
|
# Partition_efi
|
67
|
-
# /
|
55
|
+
# /efi - EFI system partition - 260MB
|
68
56
|
# / - Root
|
69
57
|
|
70
58
|
# Partition_bios
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Getch
|
4
|
+
module FileSystem
|
5
|
+
class Mount
|
6
|
+
def initialize
|
7
|
+
@root_dir = MOUNTPOINT
|
8
|
+
@boot_dir = "#{@root_dir}/boot"
|
9
|
+
@boot_efi_dir = "#{@root_dir}/efi"
|
10
|
+
@home_dir = "#{@root_dir}/home"
|
11
|
+
@state = Getch::States.new()
|
12
|
+
@log = Getch::Log.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def swap(dev)
|
16
|
+
return if ! dev
|
17
|
+
if Helpers::grep?('/proc/swaps', /^\/dev/)
|
18
|
+
exec("swapoff #{dev}")
|
19
|
+
end
|
20
|
+
|
21
|
+
exec("swapon #{dev}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def root(dev)
|
25
|
+
return if ! dev
|
26
|
+
Helpers::mkdir(@root_dir)
|
27
|
+
exec("mount #{dev} #{@root_dir}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def esp(dev)
|
31
|
+
return if ! dev
|
32
|
+
Helpers::mkdir(@boot_efi_dir)
|
33
|
+
exec("mount #{dev} #{@boot_efi_dir}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def boot(dev)
|
37
|
+
return if ! dev
|
38
|
+
Helpers::mkdir(@boot_dir)
|
39
|
+
exec("mount #{dev} #{@boot_dir}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def home(dev)
|
43
|
+
return if ! dev
|
44
|
+
Helpers::mkdir(@home_dir)
|
45
|
+
exec("mount #{dev} #{@home_dir}")
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def exec(cmd)
|
51
|
+
@log.info("==> #{cmd}")
|
52
|
+
Helpers::sys(cmd)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Getch
|
2
|
+
module FileSystem
|
3
|
+
class Partition
|
4
|
+
def initialize
|
5
|
+
@log = Getch::Log.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def gpt(dev)
|
9
|
+
return if ! dev
|
10
|
+
disk = disk_name(dev)
|
11
|
+
part = dev.match(/[0-9]/)
|
12
|
+
exec("sgdisk -n#{part}:1MiB:+1MiB -t#{part}:EF02 #{disk}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def boot(dev)
|
16
|
+
return if ! dev
|
17
|
+
disk = disk_name(dev)
|
18
|
+
part = dev.match(/[0-9]/)
|
19
|
+
if DEFAULT_OPTIONS[:fs] == "zfs"
|
20
|
+
exec("sgdisk -n#{part}:0:+2G -t#{part}:BE00 #{disk}")
|
21
|
+
else
|
22
|
+
exec("sgdisk -n#{part}:0:+128MiB -t#{part}:8300 #{disk}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def efi(dev)
|
27
|
+
return if ! dev
|
28
|
+
disk = disk_name(dev)
|
29
|
+
part = dev.match(/[0-9]/)
|
30
|
+
exec("sgdisk -n#{part}:1M:+260M -t#{part}:EF00 #{disk}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def swap(dev)
|
34
|
+
return if ! dev
|
35
|
+
disk = disk_name(dev)
|
36
|
+
part = dev.match(/[0-9]/)
|
37
|
+
if DEFAULT_OPTIONS[:cache_disk]
|
38
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:8200 #{disk}")
|
39
|
+
else
|
40
|
+
mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
|
41
|
+
exec("sgdisk -n#{part}:0:+#{mem} -t#{part}:8200 #{disk}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def root(dev, code)
|
46
|
+
return if ! dev
|
47
|
+
disk = disk_name(dev)
|
48
|
+
part = dev.match(/[0-9]/)
|
49
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def home(dev, code)
|
53
|
+
return if ! dev
|
54
|
+
disk = disk_name(dev)
|
55
|
+
part = dev.match(/[0-9]/)
|
56
|
+
if DEFAULT_OPTIONS[:home_disk]
|
57
|
+
exec("sgdisk -n#{part}:0:0 -t#{part}:#{code} #{disk}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def disk_name(dev)
|
64
|
+
dev.match(/[^0-9]+/)
|
65
|
+
end
|
66
|
+
|
67
|
+
def exec(cmd)
|
68
|
+
@log.debug "Partition disk with #{cmd}"
|
69
|
+
if DEFAULT_OPTIONS[:encrypt]
|
70
|
+
Helpers::sys(cmd)
|
71
|
+
else
|
72
|
+
Getch::Command.new(cmd).run!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|