getch 0.1.0 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +95 -22
  5. data/assets/network-stack.conf +63 -0
  6. data/bin/getch +12 -4
  7. data/lib/getch.rb +116 -66
  8. data/lib/getch/command.rb +19 -5
  9. data/lib/getch/config.rb +42 -0
  10. data/lib/getch/config/gentoo.rb +59 -0
  11. data/lib/getch/config/void.rb +49 -0
  12. data/lib/getch/filesystem.rb +5 -0
  13. data/lib/getch/filesystem/.mount.rb.swp +0 -0
  14. data/lib/getch/filesystem/clean.rb +58 -0
  15. data/lib/getch/filesystem/device.rb +61 -0
  16. data/lib/getch/filesystem/ext4.rb +1 -0
  17. data/lib/getch/filesystem/ext4/config.rb +8 -9
  18. data/lib/getch/filesystem/ext4/device.rb +2 -7
  19. data/lib/getch/filesystem/ext4/encrypt.rb +1 -0
  20. data/lib/getch/filesystem/ext4/encrypt/config.rb +8 -9
  21. data/lib/getch/filesystem/ext4/encrypt/deps.rb +3 -19
  22. data/lib/getch/filesystem/ext4/encrypt/device.rb +3 -8
  23. data/lib/getch/filesystem/ext4/encrypt/format.rb +3 -6
  24. data/lib/getch/filesystem/ext4/encrypt/mount.rb +5 -43
  25. data/lib/getch/filesystem/ext4/encrypt/partition.rb +29 -54
  26. data/lib/getch/filesystem/ext4/encrypt/void.rb +100 -0
  27. data/lib/getch/filesystem/ext4/format.rb +4 -6
  28. data/lib/getch/filesystem/ext4/mount.rb +7 -46
  29. data/lib/getch/filesystem/ext4/partition.rb +16 -39
  30. data/lib/getch/filesystem/ext4/void.rb +43 -0
  31. data/lib/getch/filesystem/lvm.rb +1 -0
  32. data/lib/getch/filesystem/lvm/config.rb +11 -15
  33. data/lib/getch/filesystem/lvm/deps.rb +4 -19
  34. data/lib/getch/filesystem/lvm/device.rb +33 -9
  35. data/lib/getch/filesystem/lvm/encrypt.rb +1 -0
  36. data/lib/getch/filesystem/lvm/encrypt/config.rb +9 -12
  37. data/lib/getch/filesystem/lvm/encrypt/deps.rb +4 -21
  38. data/lib/getch/filesystem/lvm/encrypt/device.rb +33 -9
  39. data/lib/getch/filesystem/lvm/encrypt/format.rb +3 -4
  40. data/lib/getch/filesystem/lvm/encrypt/mount.rb +7 -47
  41. data/lib/getch/filesystem/lvm/encrypt/partition.rb +30 -38
  42. data/lib/getch/filesystem/lvm/encrypt/void.rb +100 -0
  43. data/lib/getch/filesystem/lvm/format.rb +12 -8
  44. data/lib/getch/filesystem/lvm/mount.rb +7 -46
  45. data/lib/getch/filesystem/lvm/partition.rb +19 -31
  46. data/lib/getch/filesystem/lvm/void.rb +45 -0
  47. data/lib/getch/filesystem/mount.rb +56 -0
  48. data/lib/getch/filesystem/partition.rb +77 -0
  49. data/lib/getch/filesystem/zfs.rb +1 -0
  50. data/lib/getch/filesystem/zfs/config.rb +7 -8
  51. data/lib/getch/filesystem/zfs/deps.rb +24 -12
  52. data/lib/getch/filesystem/zfs/device.rb +54 -9
  53. data/lib/getch/filesystem/zfs/encrypt.rb +1 -0
  54. data/lib/getch/filesystem/zfs/encrypt/.mount.rb.swp +0 -0
  55. data/lib/getch/filesystem/zfs/encrypt/config.rb +11 -11
  56. data/lib/getch/filesystem/zfs/encrypt/deps.rb +24 -14
  57. data/lib/getch/filesystem/zfs/encrypt/device.rb +54 -9
  58. data/lib/getch/filesystem/zfs/encrypt/format.rb +84 -3
  59. data/lib/getch/filesystem/zfs/encrypt/mount.rb +8 -28
  60. data/lib/getch/filesystem/zfs/encrypt/partition.rb +26 -109
  61. data/lib/getch/filesystem/zfs/encrypt/void.rb +96 -0
  62. data/lib/getch/filesystem/zfs/format.rb +97 -4
  63. data/lib/getch/filesystem/zfs/mount.rb +10 -32
  64. data/lib/getch/filesystem/zfs/partition.rb +25 -106
  65. data/lib/getch/filesystem/zfs/void.rb +81 -0
  66. data/lib/getch/gentoo.rb +20 -16
  67. data/lib/getch/gentoo/boot.rb +24 -16
  68. data/lib/getch/gentoo/chroot.rb +16 -25
  69. data/lib/getch/gentoo/config.rb +67 -15
  70. data/lib/getch/gentoo/sources.rb +55 -13
  71. data/lib/getch/gentoo/stage.rb +0 -1
  72. data/lib/getch/gentoo/use.rb +43 -0
  73. data/lib/getch/gentoo/use_flag.rb +63 -0
  74. data/lib/getch/guard.rb +64 -0
  75. data/lib/getch/helpers.rb +133 -0
  76. data/lib/getch/log.rb +3 -2
  77. data/lib/getch/options.rb +46 -24
  78. data/lib/getch/version.rb +1 -1
  79. data/lib/getch/void.rb +59 -0
  80. data/lib/getch/void/boot.rb +80 -0
  81. data/lib/getch/void/chroot.rb +55 -0
  82. data/lib/getch/void/config.rb +87 -0
  83. data/lib/getch/void/stage.rb +70 -0
  84. metadata +46 -25
  85. metadata.gz.sig +0 -0
  86. data/.gitignore +0 -2
  87. data/CHANGELOG.md +0 -60
  88. data/Rakefile +0 -21
  89. data/bin/setup.sh +0 -90
  90. data/getch.gemspec +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 259461a4875fb46c062067c9663e211c206475aaaaa89d3066f85d1b3be2c19b
4
- data.tar.gz: 3ab40d87e3f039ef840156cc81df8ee75e3f8f76c332ae4ba08335b04440625f
3
+ metadata.gz: 9291f8df276b462cd310f6dc759d6c0526a9d8fdc7c47116f4c22e53d1aec6e6
4
+ data.tar.gz: c7c325c4fbc228110630b98f9d52d110bdc7d5654566efb0a136bbcfedbe5331
5
5
  SHA512:
6
- metadata.gz: eef130ea5b78dcde7f2897d16f3f74293c16da487ca029c0d47c905489d5cd4d9f32d5bffeba30fe06ab13694370f99a380aceaec6da053dece11598eb938ba4
7
- data.tar.gz: f9f4584abb87c4287ba81e16bb0274c483627a712916728fbcc9a4667a2d91f03e09a092bdf09400bd1f92318c67ddabdf4c20217eff1eeb64f2d8d0c97a1a02
6
+ metadata.gz: f7634afba44f36e31c1ab56bc373afbf1b20cce50d97445410ffc496d4c803b3c5d978c98d1a0949dc41de725db25236185df5492a0c9115425a4dc08d1c73e8
7
+ data.tar.gz: d807dbcdf3fc769473c5c14200ad91c3e8c878f6f6627a0a242481601be05e57ffe58d623c1e0431b510546f896e7fdb0f0c98bd719298977cef15ad50a76c65
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,34 +1,53 @@
1
1
  # Getch
2
- A CLI tool to install Gentoo.
2
+ A CLI tool to install Gentoo or Void Linux with default:
3
+ + DNS over HTTPS (with [Quad9](https://www.quad9.net/)).
4
+ + Vim | Nano installed.
5
+ + Iptables installed (not configured).
6
+ + Sudo installed (not configured).
7
+ + [iwd](https://iwd.wiki.kernel.org/) installed if wifi is detected.
8
+ + No GUI installed.
9
+
10
+ Hardened System:
11
+ + sysctl.conf with TCP/IP stack hardening and more [Arch](https://wiki.archlinux.org/title/Sysctl)
12
+ + Kernel parameters enforced (dmesg restricted, kexec disabled, etc)
13
+ + Kernel source (Gentoo) patched with [bask](https://github.com/szorfein/bask).
3
14
 
4
15
  ## Description
5
- Actually, Getch support only the [AMD64 handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64) and only with the last `stage3-amd64-systemd`.
6
- It also require a disk (only one for now) with a minimum of 20G.
16
+ Actually, Getch support only the `x86_64` architecture and only with the following archives:
17
+ + **Gentoo**: `stage3-amd64-systemd` [Gentoo](https://www.gentoo.org/downloads/).
18
+ + **Void**: `rootfs glibc` [Void](https://voidlinux.org/download/).
7
19
 
8
- BIOS system will use Grub2 and UEFI, systemd-boot. Filesystem supported by Getch are for now:
9
- + ext4
10
- + lvm
20
+ Filesystem supported (with or without encryption)
21
+ + Ext4
22
+ + Lvm
23
+ + ZFS
11
24
 
12
- Encryption is also supported.
25
+ Boot Manager:
26
+ + **Gentoo**: `BIOS` will use `Grub2` and `systemd-boot` for `UEFI`.
27
+ + **Void**: use only Grub2, encryption for the root fs use luks1.
13
28
 
14
29
  The ISO images i was able to test and that works:
15
30
  + [Archlinux](https://www.archlinux.org/download/)
31
+ + [Archaeidae](https://github.com/szorfein/archaeidae): Custom Archiso that includes ZFS support.
32
+
33
+ ## Dependencies
34
+ Getch is build without external libs, so it only require `ruby >= 2.5`.
16
35
 
17
36
  ## Install
18
37
  Getch is cryptographically signed, so add my public key (if you haven’t already) as a trusted certificate.
19
38
  With `gem` installed:
20
39
 
21
40
  $ gem cert --add <(curl -Ls https://raw.githubusercontent.com/szorfein/getch/master/certs/szorfein.pem)
22
-
23
41
  $ gem install getch -P HighSecurity
24
42
 
25
- When you boot from an `iso`, you can install `ruby`, `getch` and correct your `PATH=` directly with the `bin/setup.sh`:
43
+ If you want to try the master branch (can be unstable):
26
44
 
27
- # sh <(curl -L https://raw.githubusercontent.com/szorfein/getch/master/bin/setup.sh)
28
- # source ~/.zshrc # or ~/.bashrc
45
+ # git clone https://github.com/szorfein/getch
46
+ # cd getch
47
+ # ruby -I lib bin/getch -h
29
48
 
30
49
  ## Usage
31
- Just ensure than the script is run with a root account, not just sudo.
50
+ Just ensure than the script is run with a root account.
32
51
 
33
52
  # getch -h
34
53
 
@@ -39,28 +58,82 @@ For a french user:
39
58
 
40
59
  # getch --zoneinfo "Europe/Paris" --language fr_FR --keymap fr
41
60
 
42
- Install Gentoo on LVM:
61
+ Install Gentoo on LVM and use a different root disk `/dev/sdc`
43
62
 
44
- # getch --format lvm --disk sda
63
+ # getch --format lvm --disk sdc
45
64
 
46
65
  Encrypt your disk with LVM with a french keymap
47
66
 
48
67
  # getch --format lvm --encrypt --keymap fr
49
68
 
50
- Encrypt with ext4 and create a home directory /home/ninja
69
+ Encrypt with ext4 and create a new user `ninja`:
51
70
 
52
71
  # getch --format ext4 --encrypt --username ninja
53
72
 
73
+ With ZFS, if used with `--encrypt`, it use the native ZFS encryption:
74
+
75
+ # getch --format zfs
76
+
77
+ With `Void Linux`:
78
+
79
+ # getch --os void --encrypt -k fr
80
+
54
81
  ## Troubleshooting
55
82
 
56
- #### LVM
57
- Unless your old LVM volume group is also named `vg0`, `getch` may fail to partition your disk. You have to clean up your device before proceed with `vgremove` and `pvremove`.
83
+ #### Old VG for LVM
84
+ If a old volume group exist, `getch` may fail to partition your disk. You have to clean up your device before proceed with `vgremove` and `pvremove`. An short example how doing this with a volume group named `vg0`:
85
+
86
+ # vgdisplay | grep vg0
87
+ # vgremove -f vg0
88
+ # pvremove -f /dev/sdb
58
89
 
59
90
  #### Encryption enable on BIOS with ext4
60
- 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).
91
+ To decrypt your disk on BIOS system, you have to enter your password twice. One time for Grub and another time for Genkernel. [post](https://wiki.archlinux.org/index.php/GRUB#Encrypted_/boot).
61
92
  Also with GRUB, only a `us` keymap is working.
62
93
 
63
- ## Issues
64
- 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
- + lspci
66
- + lsmod
94
+ #### ZFS for Gentoo
95
+ When Gentoo boot the first time, the pool may fail to start, it's happen when the pool has not been `export` to the ISO. So just `export` your pool from the genkernel shell:
96
+
97
+ The zpool name should be visible (rpool-150ed here), so enter in the Genkernel shell:
98
+
99
+ > shell
100
+ zpool import -f -N -R /tmp rpool-150ed
101
+ zpool export -a
102
+
103
+ Then, just reboot now, it's all.
104
+
105
+ *INFO*: To create the zpool, getch use the 5 fist characters from the `partuuid`, just replace `sdX` by your real device:
106
+
107
+ # ls -l /dev/disk/by-partuuid/ | grep sdX4
108
+ -> 150ed969...
109
+
110
+ The pool will be called `rpool-150ed`.
111
+
112
+ #### ZFS for Void Linux - Enable the boot pool
113
+ You have some extras step to do after booting to enable the boot pool, you need this pool when you update your system. It's used mainly by Grub and Dracut.
114
+ By default, your /boot is empty because your boot pool is not imported...
115
+
116
+ # zpool import -N bpool150ed
117
+ # zfs mount bpool150ed/BOOT/void
118
+ # ls /boot
119
+
120
+ You should see something in the boot (initramfs, vmlinuz).. Recreate the initramfs.
121
+
122
+ # xbps-reconfigure -fa
123
+
124
+ Transform the boot pool in legacy mode and add this to the fstab:
125
+
126
+ # zfs set mountpoint=legacy bpool150ed/BOOT/void
127
+ # echo "bpool150ed/BOOT/void /boot zfs defaults 0 0" >> /etc/fstab
128
+ # mount /boot
129
+
130
+ The /boot should not be empty again and then, reboot. `fstab` should do this automatically now.
131
+
132
+ #### ZFS Encrypted with Void
133
+ Well, another weird issue, the first time you boot on your encrypted pool, nothing append. Dracut try to mount inexistent device. Just wait for enter in the shell:
134
+
135
+ # ls /lib/dracut/hooks/initqueue/finished/*
136
+ # rm /lib/dracut/hooks/initqueue/finished/dev*
137
+ # exit
138
+
139
+ Dracut should finally start `mount-zfs.sh` and ask for your password. After you first login, follow instructions above for recompile the initramfs and mount the boot pool and your good.
@@ -0,0 +1,63 @@
1
+ # https://wiki.archlinux.org/title/Sysctl#TCP/IP_stack_hardening
2
+ # https://github.com/trimstray/the-practical-linux-hardening-guide/wiki/Network-stack
3
+
4
+ # TCP SYN cookie protection
5
+ net.ipv4.tcp_syncookies = 1
6
+
7
+ # TCP rfc1337
8
+ net.ipv4.tcp_rfc1337 = 1
9
+
10
+ # Reverse path filtering
11
+ net.ipv4.conf.default.rp_filter = 1
12
+ net.ipv4.conf.all.rp_filter = 1
13
+
14
+ # Log martian packets
15
+ net.ipv4.conf.default.log_martians = 1
16
+ net.ipv4.conf.all.log_martians = 1
17
+
18
+ # Disable ICMP redirects
19
+ net.ipv6.conf.all.accept_redirects = 0
20
+ net.ipv6.conf.default.accept_redirects = 0
21
+
22
+ # Disable IP source routing
23
+ net.ipv4.conf.default.accept_source_route = 0
24
+ net.ipv4.conf.all.accept_source_route = 0
25
+
26
+ # Ignore ICMP echo requests
27
+ net.ipv4.icmp_echo_ignore_all = 1
28
+ net.ipv6.icmp.echo_ignore_all = 1
29
+
30
+ # Ignoring broadcasts request
31
+ net.ipv4.icmp_echo_ignore_broadcasts = 1
32
+
33
+ # An illicit router advertisement message could result in a man-in-the-middle attack.
34
+ net.ipv6.conf.default.accept_ra = 0
35
+ net.ipv6.conf.all.accept_ra = 0
36
+
37
+ # Ignore bogus ICMP error responses
38
+ net.ipv4.icmp_ignore_bogus_error_responses = 1
39
+
40
+ # ICMP redirects
41
+ net.ipv4.conf.default.accept_redirects = 0
42
+ net.ipv4.conf.all.accept_redirects = 0
43
+
44
+ # Accepting secure redirects
45
+ net.ipv4.conf.default.secure_redirects = 0
46
+ net.ipv4.conf.all.secure_redirects = 0
47
+
48
+ # IP forwarding
49
+ net.ipv4.ip_forward = 0
50
+
51
+ # Sending ICMP redirects
52
+ net.ipv4.conf.default.send_redirects = 0
53
+ net.ipv4.conf.all.send_redirects = 0
54
+
55
+ # Keep sockets in FIN-WAIT-2 state
56
+ net.ipv4.tcp_fin_timeout = 30
57
+
58
+ # Keepalive packets to keep an connection alive
59
+ net.ipv4.tcp_keepalive_time = 180
60
+ net.ipv4.tcp_keepalive_intvl = 10
61
+ net.ipv4.tcp_keepalive_probes = 3
62
+
63
+
data/bin/getch CHANGED
@@ -2,8 +2,16 @@
2
2
 
3
3
  require 'getch'
4
4
 
5
- def main(argv)
6
- Getch::main(argv)
7
- end
5
+ getch = Getch::Main.new(
6
+ :cli => Getch::Options.new(ARGV)
7
+ )
8
8
 
9
- main(ARGV)
9
+ getch.resume
10
+
11
+ getch.partition
12
+ getch.format
13
+ getch.mount
14
+
15
+ getch.install
16
+
17
+ getch.configure
data/lib/getch.rb CHANGED
@@ -1,22 +1,30 @@
1
1
  require_relative 'getch/options'
2
2
  require_relative 'getch/states'
3
3
  require_relative 'getch/gentoo'
4
+ require_relative 'getch/void'
4
5
  require_relative 'getch/filesystem'
5
6
  require_relative 'getch/command'
6
7
  require_relative 'getch/helpers'
7
8
  require_relative 'getch/log'
9
+ require_relative 'getch/config'
10
+ require_relative 'getch/guard'
11
+ require_relative 'getch/version'
8
12
 
9
13
  module Getch
10
14
 
11
- DEFAULT_OPTIONS = {
12
- language: 'en_US',
13
- zoneinfo: 'US/Eastern',
14
- keymap: 'us',
15
- disk: 'sda',
16
- fs: 'ext4',
17
- username: nil,
18
- encrypt: false,
19
- verbose: false
15
+ OPTIONS = {
16
+ :language => 'en_US',
17
+ :zoneinfo => 'US/Eastern',
18
+ :keymap => 'us',
19
+ :disk => false,
20
+ :fs => 'ext4',
21
+ :username => false,
22
+ :os => 'gentoo',
23
+ :boot_disk => false,
24
+ :cache_disk => false,
25
+ :home_disk => false,
26
+ :encrypt => false,
27
+ :verbose => false
20
28
  }
21
29
 
22
30
  STATES = {
@@ -29,76 +37,118 @@ module Getch
29
37
  :gentoo_kernel => false
30
38
  }
31
39
 
32
- MOUNTPOINT = "/mnt/gentoo".freeze
40
+ MOUNTPOINT = "/mnt/gentoo"
41
+
33
42
  DEFAULT_FS = {
34
43
  true => {
35
- ext4: Getch::FileSystem::Ext4::Encrypt,
36
- lvm: Getch::FileSystem::Lvm::Encrypt,
37
- zfs: Getch::FileSystem::Zfs::Encrypt
44
+ ext4: FileSystem::Ext4::Encrypt,
45
+ lvm: FileSystem::Lvm::Encrypt,
46
+ zfs: FileSystem::Zfs::Encrypt
38
47
  },
39
48
  false => {
40
- ext4: Getch::FileSystem::Ext4,
41
- lvm: Getch::FileSystem::Lvm,
42
- zfs: Getch::FileSystem::Zfs,
49
+ ext4: FileSystem::Ext4,
50
+ lvm: FileSystem::Lvm,
51
+ zfs: FileSystem::Zfs,
43
52
  }
44
53
  }.freeze
45
54
 
46
- def self.class_fs
47
- encrypt = DEFAULT_OPTIONS[:encrypt]
48
- fs = DEFAULT_OPTIONS[:fs].to_sym
49
- DEFAULT_FS[encrypt][fs]
55
+ def self.select_fs
56
+ encrypt = OPTIONS[:encrypt]
57
+ fs_sym = OPTIONS[:fs].to_sym
58
+ DEFAULT_FS[encrypt][fs_sym]
50
59
  end
51
60
 
52
- def self.resume_options(opts)
53
- puts "\nBuild Gentoo with the following args:\n"
54
- puts "lang: #{DEFAULT_OPTIONS[:language]}"
55
- puts "zoneinfo: #{DEFAULT_OPTIONS[:zoneinfo]}"
56
- puts "keymap: #{DEFAULT_OPTIONS[:keymap]}"
57
- puts "disk: #{DEFAULT_OPTIONS[:disk]}"
58
- puts "fs: #{DEFAULT_OPTIONS[:fs]}"
59
- puts "username: #{DEFAULT_OPTIONS[:username]}"
60
- puts "encrypt: #{DEFAULT_OPTIONS[:encrypt]}"
61
- puts
62
- print "Continue? (n,y) "
63
- case gets.chomp
64
- when /^y|^Y/
65
- return
66
- else
67
- exit 1
61
+ class Main
62
+ def initialize(argv)
63
+ argv[:cli]
64
+ @class_fs = Getch::select_fs
65
+ @log = Log.new
66
+ Getch::States.new # Update States
68
67
  end
69
- end
70
68
 
71
- def self.format(disk, fs, user)
72
- return if STATES[:format] and STATES[:partition]
73
- log = Log.new
74
- puts
75
- print "Partition and format disk #{disk}, this will erase all data, continue? (n,y) "
76
- case gets.chomp
77
- when /^y|^Y/
78
- log.info("Partition start")
79
- class_fs::Partition.new
80
- class_fs::Format.new
81
- else
82
- exit 1
69
+ def resume
70
+ raise "No disk, use at least getch with -d DISK" if !OPTIONS[:disk]
71
+ puts "\nBuild " + OPTIONS[:os].capitalize + " Linux with the following args:\n"
72
+ puts
73
+ puts "\tLang: #{OPTIONS[:language]}"
74
+ puts "\tZoneinfo: #{OPTIONS[:zoneinfo]}"
75
+ puts "\tKeymap: #{OPTIONS[:keymap]}"
76
+ puts "\tDisk: #{OPTIONS[:disk]}"
77
+ puts "\tFilesystem: #{OPTIONS[:fs]}"
78
+ puts "\tUsername: #{OPTIONS[:username]}"
79
+ puts "\tEncrypt: #{OPTIONS[:encrypt]}"
80
+ puts
81
+ puts "\tseparate-boot disk: #{OPTIONS[:boot_disk]}"
82
+ puts "\tseparate-cache disk: #{OPTIONS[:cache_disk]}"
83
+ puts "\tseparate-home disk: #{OPTIONS[:home_disk]}"
84
+ puts
85
+ print "Continue? (y,N) "
86
+ case gets.chomp
87
+ when /^y|^Y/
88
+ return
89
+ else
90
+ exit
91
+ end
83
92
  end
84
- end
85
93
 
86
- def self.init_gentoo(options)
87
- gentoo = Getch::Gentoo
88
- gentoo.stage3
89
- gentoo.config(options)
90
- gentoo.chroot
91
- gentoo.kernel
92
- gentoo.boot(options)
93
- end
94
+ def partition
95
+ return if STATES[:partition]
96
+ puts
97
+ print "Partition and format disk #{OPTIONS[:disk]}, this will erase all data, continue? (y,N) "
98
+ case gets.chomp
99
+ when /^y|^Y/
100
+ @log.info("Partition start")
101
+ @class_fs::Partition.new
102
+ else
103
+ exit
104
+ end
105
+ end
106
+
107
+ def format
108
+ return if STATES[:format]
109
+ @class_fs::Format.new
110
+ end
94
111
 
95
- def self.main(argv)
96
- options = Options.new(argv)
97
- DEFAULT_OPTIONS.freeze
98
- resume_options(options)
99
- Getch::States.new # Update States
100
- format(options.disk, options.fs, options.username)
101
- class_fs::Mount.new.run
102
- init_gentoo(options)
112
+ def mount
113
+ return if STATES[:mount]
114
+ @class_fs::Mount.new.run
115
+ end
116
+
117
+ def install
118
+ if OPTIONS[:os] == 'gentoo'
119
+ install_gentoo
120
+ elsif OPTIONS[:os] == 'void'
121
+ install_void
122
+ else
123
+ puts "Options #{OPTIONS[:os]} not supported...."
124
+ exit 1
125
+ end
126
+ end
127
+
128
+ def install_gentoo
129
+ gentoo = Getch::Gentoo::Main.new
130
+ gentoo.stage3
131
+ gentoo.config
132
+ gentoo.chroot
133
+ gentoo.kernel
134
+ gentoo.boot
135
+ end
136
+
137
+ def install_void
138
+ void = Getch::Void::Main.new
139
+ void.root_fs
140
+ void.config
141
+ void.chroot
142
+ void.boot
143
+ end
144
+
145
+ def configure
146
+ config = Getch::Config::Main.new
147
+ config.ethernet
148
+ config.wifi
149
+ config.dns
150
+ config.sysctl
151
+ config.shell
152
+ end
103
153
  end
104
154
  end