getch 0.0.4 → 0.0.9
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 +40 -5
- data/README.md +31 -2
- data/bin/setup.sh +25 -11
- data/lib/getch.rb +41 -30
- data/lib/getch/command.rb +156 -0
- data/lib/getch/filesystem.rb +7 -0
- data/lib/getch/filesystem/ext4.rb +14 -0
- data/lib/getch/filesystem/ext4/config.rb +59 -0
- data/lib/getch/filesystem/ext4/deps.rb +22 -0
- data/lib/getch/filesystem/ext4/device.rb +16 -0
- data/lib/getch/filesystem/ext4/encrypt.rb +15 -0
- data/lib/getch/filesystem/ext4/encrypt/config.rb +85 -0
- data/lib/getch/filesystem/ext4/encrypt/deps.rb +59 -0
- data/lib/getch/filesystem/ext4/encrypt/device.rb +21 -0
- data/lib/getch/filesystem/ext4/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/ext4/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/ext4/encrypt/partition.rb +116 -0
- data/lib/getch/filesystem/ext4/format.rb +30 -0
- data/lib/getch/filesystem/ext4/mount.rb +62 -0
- data/lib/getch/filesystem/ext4/partition.rb +75 -0
- data/lib/getch/filesystem/lvm.rb +14 -0
- data/lib/getch/filesystem/lvm/config.rb +63 -0
- data/lib/getch/filesystem/lvm/deps.rb +57 -0
- data/lib/getch/filesystem/lvm/device.rb +19 -0
- data/lib/getch/filesystem/lvm/encrypt.rb +15 -0
- data/lib/getch/filesystem/lvm/encrypt/config.rb +74 -0
- data/lib/getch/filesystem/lvm/encrypt/deps.rb +63 -0
- data/lib/getch/filesystem/lvm/encrypt/device.rb +22 -0
- data/lib/getch/filesystem/lvm/encrypt/format.rb +32 -0
- data/lib/getch/filesystem/lvm/encrypt/mount.rb +64 -0
- data/lib/getch/filesystem/lvm/encrypt/partition.rb +92 -0
- data/lib/getch/filesystem/lvm/format.rb +25 -0
- data/lib/getch/filesystem/lvm/mount.rb +62 -0
- data/lib/getch/filesystem/lvm/partition.rb +81 -0
- data/lib/getch/gentoo.rb +4 -2
- data/lib/getch/gentoo/boot.rb +46 -11
- data/lib/getch/gentoo/chroot.rb +18 -14
- data/lib/getch/gentoo/config.rb +24 -9
- data/lib/getch/gentoo/sources.rb +54 -29
- data/lib/getch/gentoo/stage.rb +2 -2
- data/lib/getch/helpers.rb +28 -1
- data/lib/getch/log.rb +54 -0
- data/lib/getch/options.rb +16 -7
- data/lib/getch/version.rb +1 -1
- metadata +34 -5
- metadata.gz.sig +3 -4
- data/lib/getch/disk.rb +0 -77
- data/lib/getch/mount.rb +0 -73
metadata.gz.sig
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
��x��}�d��-�|>�N�C��Z���h��"w4GS�q�Cg��]=/�V,�"B9�`w�3�����C9r&��&��E(�z�|L�]�;�����l�W��{��͓ɛ;y��=oswǢ�J��-��߈b�
|
1
|
+
p�י#J:�>�Ɇ���{��*�}А�}��=[����R:j�}��|�Ń�~�ڨ����Cg��k�U(*D��iK��ZU��bAyK�xFy���\۠r\����x,L�sW|&]~�PΗ'�g�_����5{��M����
|
2
|
+
�*�ܵ�mG��Q8f�D"39K�di���Fmv�45��h��`_��ח�P�JfJ,��߭k$���"���}���R'���Z!�s���G�B��B0�:�����zj�D�(���q�
|
3
|
+
gS�V'�C#�r�o��H
|
data/lib/getch/disk.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module Getch
|
2
|
-
class Disk
|
3
|
-
def initialize(disk, fs)
|
4
|
-
@hdd = disk
|
5
|
-
@fs = fs
|
6
|
-
@state = Getch::States.new()
|
7
|
-
end
|
8
|
-
|
9
|
-
# https://wiki.archlinux.org/index.php/Securely_wipe_disk
|
10
|
-
def cleaning
|
11
|
-
return if STATES[:partition ]
|
12
|
-
puts
|
13
|
-
print "Cleaning data on #{@hdd}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) "
|
14
|
-
case gets.chomp
|
15
|
-
when /^y|^Y/
|
16
|
-
system("dd if=/dev/urandom of=/dev/#{@hdd} bs=4M status=progress")
|
17
|
-
else
|
18
|
-
return
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def partition
|
23
|
-
return if STATES[:partition]
|
24
|
-
system("sgdisk --zap-all /dev/#{@hdd}")
|
25
|
-
system("wipefs -a /dev/#{@hdd}")
|
26
|
-
if Helpers::efi? then
|
27
|
-
puts "Partition disk #{@hdd} for an EFI system"
|
28
|
-
partition_efi
|
29
|
-
else
|
30
|
-
puts "Partition disk #{@hdd} for a Bios system"
|
31
|
-
partition_bios
|
32
|
-
end
|
33
|
-
@state.partition
|
34
|
-
end
|
35
|
-
|
36
|
-
def format
|
37
|
-
return if STATES[:format]
|
38
|
-
puts "Format #{@hdd} with #{@fs}"
|
39
|
-
if Helpers::efi? then
|
40
|
-
system("mkfs.fat -F32 /dev/#{@hdd}1")
|
41
|
-
system("mkswap /dev/#{@hdd}2")
|
42
|
-
system("mkfs.ext4 /dev/#{@hdd}3")
|
43
|
-
system("mkfs.ext4 /dev/#{@hdd}4")
|
44
|
-
else
|
45
|
-
system("mkswap /dev/#{@hdd}2")
|
46
|
-
system("mkfs.ext4 /dev/#{@hdd}3")
|
47
|
-
system("mkfs.ext4 /dev/#{@hdd}4")
|
48
|
-
end
|
49
|
-
@state.format
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
# follow https://wiki.archlinux.org/index.php/Partitioning
|
55
|
-
def partition_efi
|
56
|
-
# /boot/efi - EFI system partition - 260MB
|
57
|
-
# swap - Linux Swap - size of the ram
|
58
|
-
# / - Root
|
59
|
-
# /home - Home
|
60
|
-
system("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@hdd}") # boot EFI
|
61
|
-
system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
|
62
|
-
system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
|
63
|
-
system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
|
64
|
-
end
|
65
|
-
|
66
|
-
def partition_bios
|
67
|
-
# None - Bios Boot Partition - 1MiB
|
68
|
-
# swap - Linux Swap - size of the ram
|
69
|
-
# / - Root
|
70
|
-
# /home - Home
|
71
|
-
system("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@hdd}") # Bios boot
|
72
|
-
system("sgdisk -n2:0:+2G -t2:8200 /dev/#{@hdd}") # swap
|
73
|
-
system("sgdisk -n3:0:+15G -t3:8304 /dev/#{@hdd}") # root
|
74
|
-
system("sgdisk -n4:0:0 -t3:8302 /dev/#{@hdd}") # home
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/lib/getch/mount.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Getch
|
4
|
-
class Mount
|
5
|
-
def initialize(disk, user)
|
6
|
-
@disk = disk
|
7
|
-
@user = user
|
8
|
-
@dest = MOUNTPOINT
|
9
|
-
@boot_efi = MOUNTPOINT + '/boot/efi'
|
10
|
-
@home = @user == nil ? MOUNTPOINT + '/home' : MOUNTPOINT + "/home/#{@user}"
|
11
|
-
@state = Getch::States.new()
|
12
|
-
end
|
13
|
-
|
14
|
-
def swap
|
15
|
-
return if STATES[:mount]
|
16
|
-
system("swapon /dev/#{@disk}2")
|
17
|
-
end
|
18
|
-
|
19
|
-
def root
|
20
|
-
return if STATES[:mount]
|
21
|
-
Dir.mkdir(@dest, 0700) if ! Dir.exist?(@dest)
|
22
|
-
system("mount /dev/#{@disk}3 #{@dest}")
|
23
|
-
end
|
24
|
-
|
25
|
-
def boot
|
26
|
-
return if STATES[:mount]
|
27
|
-
if Helpers::efi? then
|
28
|
-
FileUtils.mkdir_p @boot_efi, mode: 0700 if ! Dir.exist?(@boot_efi)
|
29
|
-
system("mount /dev/#{@disk}1 #{@boot_efi}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def home
|
34
|
-
return if STATES[:mount]
|
35
|
-
if @user != nil then
|
36
|
-
FileUtils.mkdir_p @home, mode: 0700 if ! Dir.exist?(@home)
|
37
|
-
system("mount /dev/#{@disk}4 #{@home}")
|
38
|
-
#FileUtils.chown @user, @user, @home
|
39
|
-
end
|
40
|
-
@state.mount
|
41
|
-
end
|
42
|
-
|
43
|
-
def gen_fstab
|
44
|
-
gen_uuid
|
45
|
-
datas = gen_data
|
46
|
-
File.write("#{MOUNTPOINT}/etc/fstab", datas.join("\n"), mode: "a")
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def gen_uuid
|
52
|
-
@hdd1_uuid = `lsblk -o "UUID" /dev/#{@disk}1 | tail -1`.chomp()
|
53
|
-
@hdd2_uuid = `lsblk -o "UUID" /dev/#{@disk}2 | tail -1`.chomp()
|
54
|
-
@hdd3_uuid = `lsblk -o "UUID" /dev/#{@disk}3 | tail -1`.chomp()
|
55
|
-
@hdd4_uuid = `lsblk -o "UUID" /dev/#{@disk}4 | tail -1`.chomp()
|
56
|
-
end
|
57
|
-
|
58
|
-
def gen_data
|
59
|
-
boot = Helpers::efi? ? "UUID=#{@hdd1_uuid} /boot/efi vfat noauto,defaults 0 2" : ''
|
60
|
-
swap = "UUID=#{@hdd2_uuid} none swap discard 0 0"
|
61
|
-
root = "UUID=#{@hdd3_uuid} / ext4 defaults 0 1"
|
62
|
-
home = @user != nil ? "UUID=#{@hdd4_uuid} /home/#{@user} ext4 defaults 0 2" : ''
|
63
|
-
|
64
|
-
datas = [
|
65
|
-
boot,
|
66
|
-
swap,
|
67
|
-
root,
|
68
|
-
home
|
69
|
-
]
|
70
|
-
return datas
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|