getch 0.0.9 → 0.1.5

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +45 -0
  5. data/README.md +57 -11
  6. data/bin/setup.sh +4 -2
  7. data/lib/getch.rb +27 -10
  8. data/lib/getch/command.rb +25 -4
  9. data/lib/getch/config.rb +58 -0
  10. data/lib/getch/filesystem.rb +6 -0
  11. data/lib/getch/filesystem/clean.rb +58 -0
  12. data/lib/getch/filesystem/device.rb +61 -0
  13. data/lib/getch/filesystem/ext4/config.rb +8 -9
  14. data/lib/getch/filesystem/ext4/device.rb +2 -7
  15. data/lib/getch/filesystem/ext4/encrypt/config.rb +8 -9
  16. data/lib/getch/filesystem/ext4/encrypt/deps.rb +3 -19
  17. data/lib/getch/filesystem/ext4/encrypt/device.rb +3 -8
  18. data/lib/getch/filesystem/ext4/encrypt/format.rb +3 -5
  19. data/lib/getch/filesystem/ext4/encrypt/mount.rb +6 -43
  20. data/lib/getch/filesystem/ext4/encrypt/partition.rb +19 -38
  21. data/lib/getch/filesystem/ext4/format.rb +3 -5
  22. data/lib/getch/filesystem/ext4/mount.rb +7 -46
  23. data/lib/getch/filesystem/ext4/partition.rb +16 -39
  24. data/lib/getch/filesystem/lvm/config.rb +11 -15
  25. data/lib/getch/filesystem/lvm/deps.rb +5 -20
  26. data/lib/getch/filesystem/lvm/device.rb +33 -9
  27. data/lib/getch/filesystem/lvm/encrypt/config.rb +9 -12
  28. data/lib/getch/filesystem/lvm/encrypt/deps.rb +5 -22
  29. data/lib/getch/filesystem/lvm/encrypt/device.rb +33 -9
  30. data/lib/getch/filesystem/lvm/encrypt/format.rb +3 -3
  31. data/lib/getch/filesystem/lvm/encrypt/mount.rb +7 -46
  32. data/lib/getch/filesystem/lvm/encrypt/partition.rb +20 -31
  33. data/lib/getch/filesystem/lvm/format.rb +11 -7
  34. data/lib/getch/filesystem/lvm/mount.rb +7 -46
  35. data/lib/getch/filesystem/lvm/partition.rb +19 -31
  36. data/lib/getch/filesystem/mount.rb +56 -0
  37. data/lib/getch/filesystem/partition.rb +77 -0
  38. data/lib/getch/filesystem/zfs.rb +14 -0
  39. data/lib/getch/filesystem/zfs/config.rb +57 -0
  40. data/lib/getch/filesystem/zfs/deps.rb +95 -0
  41. data/lib/getch/filesystem/zfs/device.rb +58 -0
  42. data/lib/getch/filesystem/zfs/encrypt.rb +15 -0
  43. data/lib/getch/filesystem/zfs/encrypt/config.rb +67 -0
  44. data/lib/getch/filesystem/zfs/encrypt/deps.rb +97 -0
  45. data/lib/getch/filesystem/zfs/encrypt/device.rb +60 -0
  46. data/lib/getch/filesystem/zfs/encrypt/format.rb +104 -0
  47. data/lib/getch/filesystem/zfs/encrypt/mount.rb +51 -0
  48. data/lib/getch/filesystem/zfs/encrypt/partition.rb +66 -0
  49. data/lib/getch/filesystem/zfs/format.rb +113 -0
  50. data/lib/getch/filesystem/zfs/mount.rb +48 -0
  51. data/lib/getch/filesystem/zfs/partition.rb +65 -0
  52. data/lib/getch/gentoo.rb +11 -4
  53. data/lib/getch/gentoo/boot.rb +34 -16
  54. data/lib/getch/gentoo/chroot.rb +16 -25
  55. data/lib/getch/gentoo/config.rb +59 -7
  56. data/lib/getch/gentoo/sources.rb +54 -26
  57. data/lib/getch/gentoo/use.rb +43 -0
  58. data/lib/getch/gentoo/use_flag.rb +64 -0
  59. data/lib/getch/guard.rb +62 -0
  60. data/lib/getch/helpers.rb +31 -13
  61. data/lib/getch/options.rb +24 -9
  62. data/lib/getch/version.rb +1 -1
  63. metadata +40 -18
  64. metadata.gz.sig +0 -0
@@ -5,13 +5,15 @@ module Getch
5
5
  def initialize
6
6
  super
7
7
  @state = Getch::States.new()
8
+ @clean = Getch::FileSystem::Clean
9
+ @partition = Getch::FileSystem::Partition.new
8
10
  run_partition
9
11
  end
10
12
 
11
13
  def run_partition
12
14
  return if STATES[:partition ]
13
- clear_struct
14
- cleaning
15
+ @clean.hdd(@disk)
16
+ @clean.external_disk(@disk, @boot_disk, @cache_disk, @home_disk)
15
17
  if Helpers::efi?
16
18
  partition_efi
17
19
  else
@@ -22,35 +24,16 @@ module Getch
22
24
 
23
25
  private
24
26
 
25
- def clear_struct
26
- exec("sgdisk -Z /dev/#{@disk}")
27
- exec("wipefs -a /dev/#{@disk}")
28
- end
29
-
30
- def cleaning
31
- puts
32
- print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
33
- case gets.chomp
34
- when /^y|^Y/
35
- bloc=`blockdev --getbsz /dev/#{@disk}`.chomp
36
- exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress")
37
- else
38
- return
39
- end
40
- end
41
-
42
27
  # Follow https://wiki.archlinux.org/index.php/Partitioning
43
28
  def partition_efi
44
- # /boot/efi - EFI system partition - 260MB
45
- # / - Root
46
- # swap - Linux Swap - size of the ram
47
- # /home - Home
48
- mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
49
-
50
- exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}")
51
- exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}")
52
- exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
53
- exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home
29
+ # /efi - EFI system partition - 260MB
30
+ # swap - Linux Swap - size of the ram
31
+ # / - Root
32
+ # /home - Home
33
+ @partition.efi(@dev_esp)
34
+ @partition.swap(@dev_swap)
35
+ @partition.root(@dev_root, "8304")
36
+ @partition.home(@dev_home, "8302") if @dev_home
54
37
  end
55
38
 
56
39
  def partition_bios
@@ -58,16 +41,10 @@ module Getch
58
41
  # / - Root
59
42
  # swap - Linux Swap - size of the ram
60
43
  # /home - Home
61
- mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K'
62
-
63
- exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}")
64
- exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}")
65
- exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}")
66
- exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home
67
- end
68
-
69
- def exec(cmd)
70
- Getch::Command.new(cmd).run!
44
+ @partition.gpt(@dev_gpt)
45
+ @partition.swap(@dev_swap)
46
+ @partition.root(@dev_root, "8304")
47
+ @partition.home(@dev_home, "8302") if @dev_home
71
48
  end
72
49
  end
73
50
  end
@@ -16,23 +16,23 @@ module Getch
16
16
  end
17
17
 
18
18
  def systemd_boot
19
- return if ! Helpers::efi?
20
- esp = '/boot/efi'
19
+ return if !@efi
20
+ esp = '/efi'
21
21
  dir = "#{@root_dir}/#{esp}/loader/entries/"
22
22
  datas_gentoo = [
23
23
  'title Gentoo Linux',
24
24
  'linux /vmlinuz',
25
25
  'initrd /initramfs',
26
- "options resume=UUID=#{@uuid_swap} root=UUID=#{@uuid_root} init=#{@init} dolvm rw"
26
+ "options resume=#{@lv_swap} root=#{@lv_root} init=#{@init} dolvm rw"
27
27
  ]
28
28
  File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
29
29
  end
30
30
 
31
31
  def grub
32
- return if Helpers::efi?
32
+ return if @efi
33
33
  file = "#{@root_dir}/etc/default/grub"
34
34
  cmdline = [
35
- "GRUB_CMDLINE_LINUX=\"resume=UUID=#{@uuid_swap} root=UUID=#{@uuid_root} init=#{@init} dolvm rw\""
35
+ "GRUB_CMDLINE_LINUX=\"resume=#{@lv_swap} root=#{@lv_root} init=#{@init} dolvm rw\""
36
36
  ]
37
37
  File.write("#{file}", cmdline.join("\n"), mode: 'a')
38
38
  end
@@ -40,22 +40,18 @@ module Getch
40
40
  private
41
41
 
42
42
  def gen_uuid
43
- @uuid_swap = `lsblk -o "UUID" #{@lv_swap} | tail -1`.chomp() if @lv_swap
44
- @uuid_root = `lsblk -o "UUID" #{@lv_root} | tail -1`.chomp() if @lv_root
45
- @uuid_dev_root = `lsblk -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
46
43
  @uuid_boot = `lsblk -o "UUID" #{@dev_boot} | tail -1`.chomp() if @dev_boot
47
- @uuid_boot_efi = `lsblk -o "UUID" #{@dev_boot_efi} | tail -1`.chomp() if @dev_boot_efi
48
- @uuid_home = `lsblk -o "UUID" #{@lv_home} | tail -1`.chomp() if @lv_home
44
+ @uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
49
45
  end
50
46
 
51
47
  def data_fstab
52
- boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
48
+ efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
53
49
  boot = @dev_boot ? "UUID=#{@uuid_boot} /boot ext4 noauto,noatime 1 2" : ''
54
- swap = @lv_swap ? "UUID=#{@uuid_swap} none swap discard 0 0" : ''
55
- root = @lv_root ? "UUID=#{@uuid_root} / ext4 defaults 0 1" : ''
56
- home = @lv_home ? "UUID=#{@uuid_home} /home/#{@user} ext4 defaults 0 2" : ''
50
+ swap = "#{@lv_swap} none swap discard 0 0"
51
+ root = "#{@lv_root} / ext4 defaults 0 1"
52
+ home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
57
53
 
58
- [ boot_efi, boot, swap, root, home ]
54
+ [ efi, boot, swap, root, home ]
59
55
  end
60
56
  end
61
57
  end
@@ -2,16 +2,9 @@ module Getch
2
2
  module FileSystem
3
3
  module Lvm
4
4
  class Deps
5
- def initialize
6
- if Helpers::efi?
7
- install_efi
8
- else
9
- install_bios
10
- end
11
- install_deps
12
- end
13
-
14
5
  def make
6
+ install_bios unless Helpers::efi?
7
+ install_deps
15
8
  options_make
16
9
  Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
17
10
  end
@@ -34,22 +27,14 @@ module Getch
34
27
  File.write(file, datas.join("\n"), mode: 'a')
35
28
  end
36
29
 
37
- def install_efi
38
- end
39
-
40
- def install_bios
41
- exec("euse -p sys-boot/grub -E device-mapper")
42
- end
43
-
44
30
  def install_deps
45
- exec("euse -E lvm")
46
- Getch::Emerge.new('genkernel lvm2').pkg!
47
- Getch::Garden.new('-a lvm').run!
31
+ Getch::Bask.new('-a lvm').run!
32
+ Getch::Emerge.new('sys-fs/lvm2 genkernel').pkg!
48
33
  exec("systemctl enable lvm2-monitor")
49
34
  end
50
35
 
51
36
  def exec(cmd)
52
- Helpers::run_chroot(cmd, MOUNTPOINT)
37
+ Getch::Chroot.new(cmd).run!
53
38
  end
54
39
  end
55
40
  end
@@ -1,17 +1,41 @@
1
1
  module Getch
2
2
  module FileSystem
3
3
  module Lvm
4
- class Device
4
+ class Device < Getch::FileSystem::Device
5
5
  def initialize
6
- @disk = DEFAULT_OPTIONS[:disk]
7
- @user = DEFAULT_OPTIONS[:username]
8
- @dev_boot_efi = Helpers::efi? ? "/dev/#{@disk}1" : nil
9
- @dev_boot = Helpers::efi? ? nil : "/dev/#{@disk}2"
10
- @dev_root = Helpers::efi? ? "/dev/#{@disk}2" : "/dev/#{@disk}3"
6
+ super
11
7
  @vg = 'vg0'
12
- @lv_root = "/dev/mapper/#{@vg}-root"
13
- @lv_swap = "/dev/mapper/#{@vg}-swap"
14
- @lv_home = @user ? "/dev/mapper/#{@vg}-home" : nil
8
+ @lv_root = "/dev/#{@vg}/root"
9
+ @lv_swap = "/dev/#{@vg}/swap"
10
+ @lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
11
+ end
12
+
13
+ private
14
+
15
+ def search_boot
16
+ if @efi
17
+ if @boot_disk
18
+ @dev_esp = "/dev/#{@boot_disk}1"
19
+ else
20
+ @dev_esp = "/dev/#{@disk}1"
21
+ @root_part += 1
22
+ end
23
+ else
24
+ if @boot_disk
25
+ @dev_gpt = "/dev/#{@boot_disk}1"
26
+ @dev_boot = "/dev/#{@boot_disk}2"
27
+ @dev_grub = "/dev/#{@boot_disk}"
28
+ else
29
+ @dev_gpt = "/dev/#{@disk}1"
30
+ @dev_boot = "/dev/#{@disk}2"
31
+ @dev_grub = "/dev/#{@disk}"
32
+ @root_part += 2
33
+ end
34
+ end
35
+ end
36
+
37
+ # The swap is a part of the LVM volume, so we clean the func
38
+ def search_swap
15
39
  end
16
40
  end
17
41
  end
@@ -19,20 +19,20 @@ module Getch
19
19
 
20
20
  def systemd_boot
21
21
  return if ! Helpers::efi?
22
- esp = '/boot/efi'
22
+ esp = '/efi'
23
23
  dir = "#{@root_dir}/#{esp}/loader/entries/"
24
24
  datas_gentoo = [
25
25
  'title Gentoo Linux',
26
26
  'linux /vmlinuz',
27
27
  'initrd /initramfs',
28
- "options crypt_root=UUID=#{@uuid_dev_root} root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
28
+ "options crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} keymap=#{DEFAULT_OPTIONS[:keymap]} dolvm rw"
29
29
  ]
30
30
  File.write("#{dir}/gentoo.conf", datas_gentoo.join("\n"))
31
31
  end
32
32
 
33
33
  def crypttab
34
34
  datas = [
35
- "cryptswap #{@lv_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=256"
35
+ "cryptswap #{@lv_swap} /dev/urandom swap,cipher=aes-xts-plain64:sha256,size=512"
36
36
  ]
37
37
  File.write("#{@root_dir}/etc/crypttab", datas.join("\n"))
38
38
  end
@@ -41,7 +41,7 @@ module Getch
41
41
  return if Helpers::efi?
42
42
  file = "#{@root_dir}/etc/default/grub"
43
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]}\"",
44
+ "GRUB_CMDLINE_LINUX=\"crypt_root=UUID=#{@uuid_dev_root} root=/dev/mapper/root real_root=#{@lv_root} init=#{@init} dolvm rw slub_debug=P page_poison=1 slab_nomerge pti=on vsyscall=none spectre_v2=on spec_store_bypass_disable=seccomp iommu=force keymap=#{DEFAULT_OPTIONS[:keymap]}\"",
45
45
  "GRUB_ENABLE_CRYPTODISK=y"
46
46
  ]
47
47
  File.write("#{file}", cmdline.join("\n"), mode: 'a')
@@ -50,20 +50,17 @@ module Getch
50
50
  private
51
51
 
52
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
53
  @uuid_dev_root = `lsblk -d -o "UUID" #{@dev_root} | tail -1`.chomp() if @dev_root
56
54
  @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
55
+ @uuid_esp = `lsblk -o "UUID" #{@dev_esp} | tail -1`.chomp() if @dev_esp
59
56
  end
60
57
 
61
58
  def data_fstab
62
- boot_efi = @dev_boot_efi ? "UUID=#{@uuid_boot_efi} /boot/efi vfat noauto,noatime 1 2" : ''
59
+ boot_efi = @dev_esp ? "UUID=#{@uuid_esp} /efi vfat noauto,noatime 1 2" : ''
63
60
  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" : ''
61
+ swap = "/dev/mapper/cryptswap none swap discard 0 0"
62
+ root = "#{@lv_root} / ext4 defaults 0 1"
63
+ home = @lv_home ? "#{@lv_home} /home/#{@user} ext4 defaults 0 2" : ''
67
64
 
68
65
  [ boot_efi, boot, swap, root, home ]
69
66
  end
@@ -3,16 +3,8 @@ module Getch
3
3
  module Lvm
4
4
  module Encrypt
5
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
6
  def make
7
+ install_deps
16
8
  options_make
17
9
  Getch::Make.new("genkernel --kernel-config=/usr/src/linux/.config all").run!
18
10
  end
@@ -37,24 +29,15 @@ module Getch
37
29
  File.write(file, datas.join("\n"), mode: 'a')
38
30
  end
39
31
 
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
32
  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!
33
+ # lvm2, cryptsetup alrealy installed
34
+ Getch::Bask.new('-a lvm').run!
35
+ Getch::Emerge.new('genkernel').pkg!
53
36
  exec("systemctl enable lvm2-monitor")
54
37
  end
55
38
 
56
39
  def exec(cmd)
57
- Helpers::run_chroot(cmd, MOUNTPOINT)
40
+ Getch::Chroot.new(cmd).run!
58
41
  end
59
42
  end
60
43
  end
@@ -2,18 +2,42 @@ module Getch
2
2
  module FileSystem
3
3
  module Lvm
4
4
  module Encrypt
5
- class Device
5
+ class Device < Getch::FileSystem::Device
6
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"
7
+ super
12
8
  @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
9
+ @lv_root = "/dev/#{@vg}/root"
10
+ @lv_swap = "/dev/#{@vg}/swap"
11
+ @lv_home = @home_disk ? "/dev/#{@vg}/home" : nil
16
12
  @luks_root = "/dev/mapper/cryptroot"
13
+ @luks_home = @home_disk ? "/dev/mapper/crypthome" : nil
14
+ end
15
+
16
+ private
17
+
18
+ def search_boot
19
+ if @efi
20
+ if @boot_disk
21
+ @dev_esp = "/dev/#{@boot_disk}1"
22
+ else
23
+ @dev_esp = "/dev/#{@disk}1"
24
+ @root_part += 1
25
+ end
26
+ else
27
+ if @boot_disk
28
+ @dev_gpt = "/dev/#{@boot_disk}1"
29
+ @dev_boot = "/dev/#{@boot_disk}2"
30
+ @dev_grub = "/dev/#{@boot_disk}"
31
+ else
32
+ @dev_gpt = "/dev/#{@disk}1"
33
+ @dev_boot = "/dev/#{@disk}2"
34
+ @dev_grub = "/dev/#{@disk}"
35
+ @root_part += 2
36
+ end
37
+ end
38
+ end
39
+
40
+ def search_swap
17
41
  end
18
42
  end
19
43
  end
@@ -12,10 +12,10 @@ module Getch
12
12
 
13
13
  def format
14
14
  return if STATES[:format]
15
- puts "Format #{@disk} with #{@fs}"
16
- exec("mkfs.fat -F32 #{@dev_boot_efi}") if @dev_boot_efi
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
- #exec("mkswap -f #{@lv_swap}")
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
- @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()
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
- 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
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