warding 0.2.7 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80f1a448f9e2dca165d0ae31d4d745b2bd6641a768d2455d64086bb04132a098
4
- data.tar.gz: d6afdd80c3497c2a6fd39dda60ebdcedb63d02483116c8ee68b0861f079f93a1
3
+ metadata.gz: 0e583d6fd634faea6fc3c02764e74d6ecaa11a1d0c12799fe0aa2138c3a9ed8b
4
+ data.tar.gz: 616f5c4f6878b89faa1de8f694ed982eb53302677e9a17d7ed92da2a3b684f77
5
5
  SHA512:
6
- metadata.gz: 3baef4c001d534fc9dcb595fb10b4b222121e2a161980c153856bee1365db895055b29b644f14739bba69b59535b9cf84359c7c3df69f52be676f8648916b10f
7
- data.tar.gz: 5acd8f21a504566276ad9e54a6407307bca3ea3b9e16f7d2001dadc8f80b60f62615f7fc4fac49f77caec34c6f1cf9c8563d13c80b1d0caed57e8f7301f7f22c
6
+ metadata.gz: 915cb9da2438da92acaeb61e5457fd837d0606897691ef4b4106bd1c03b9041c20d390eeea2b6539699d079aa55521101062974481d9572d5da8b896efcd332e
7
+ data.tar.gz: 349f376ce8339dc37d9dd32d4985b26c1fe7fbd7ca23cd1895339ae846b279bd4cfa9b731805e8855bbf0766130216600d9549df6d85d8bb7af97c26561a0c3c
data/README.md CHANGED
@@ -20,14 +20,9 @@ gem install warding
20
20
 
21
21
  ## Tasklist
22
22
 
23
- * Add sddm and gdm extra confs.
24
23
  * Refactor.
25
24
  * Suppress outputs.
26
- * Add AUR support.
27
- * Code missing features.
28
25
  * Add extra checks.
29
- * Add GitHub actions.
30
- * Publish gem/package on GitHub.
31
26
 
32
27
  ## Contributing
33
28
 
@@ -12,4 +12,8 @@ warding.check
12
12
  # gather inputs from the user
13
13
  user_input = warding.gather
14
14
  # install warding
15
- warding.install(user_input)
15
+ if user_input[:system_settings][:encrypted]
16
+ warding.install(user_input, true)
17
+ else
18
+ warding.install(user_input)
19
+ end
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ pacman -R man-pages --noconfirm
4
+ pacman -S ruby glibc libxcrypt --noconfirm
5
+ gem install bundle rake
6
+ export PATH="`ruby -e 'puts Gem.user_dir'`/bin:$PATH"
7
+ bundle
8
+ rake install
9
+ warding
@@ -53,29 +53,11 @@ module Warding
53
53
  key(:root_password).mask("Insert new root password:", required: true)
54
54
 
55
55
  key(:system_settings) do
56
- bootloader = key(:bootloader).select("Which bootloader to use?", %w[systemd-boot grub])
57
- partitions = key(:partitions).select(
58
- "Select partition scheme to use:", ["/boot and /root", "/boot, /root and /home"]
59
- )
60
-
61
56
  key(:boot_size).slider("Boot drive partition size (MiB):", min: 512, max: 4096, default: 1024, step: 128)
62
-
63
- if partitions == "/boot, /root and /home"
64
- key(:home_size).slider("Home partition size (MiB):", min: 2048, max: 8192, default: 4096, step: 256)
65
- end
66
-
67
57
  key(:swap_size).slider("Swap partition size (MiB):", min: 1024, max: 8192, default: 2048, step: 256)
68
58
 
69
- if @@prompt.yes?("Enable encryption?", default: false)
59
+ if key(:encrypted).yes?("Enable encryption?", default: false)
70
60
  key(:encryption_settings) do
71
- key(:encryption_mode).expand("Which cryptic setup to use?") do |q|
72
- if partitions == "/boot, /root and /home"
73
- q.choice key: "m", name: "minimal (/home only)" do :minimal end
74
- q.choice key: "s", name: "safe (/home, /var, /tmp and swap)", value: :safe
75
- end
76
- q.choice key: "p", name: "paranoid (full disk encryption, except /boot)", value: :paranoid
77
- q.choice key: "i", name: "insane (full disk encryption)", value: :insane if bootloader == "grub"
78
- end
79
61
  key(:encryption_key).mask("Insert the encryption key:", required: true)
80
62
  end
81
63
  end
@@ -87,7 +69,7 @@ module Warding
87
69
  parsed_input
88
70
  end
89
71
 
90
- def install(data)
72
+ def install(data, encrypted=false)
91
73
  if @@prompt.yes?("Confirm settings and continue?")
92
74
 
93
75
  @@prompt.say("Installing, please wait...")
@@ -125,56 +107,56 @@ module Warding
125
107
 
126
108
  setup_partitions(data[:system_settings][:boot_size])
127
109
 
128
- def setup_lvm(scheme, swap_size, home_size = false)
129
- # create physical volume
130
- `pvcreate /dev/sda2`
131
- # create virtual group
132
- `vgcreate vg0 /dev/sda2`
110
+ def setup_lvm(swap_size, key=false)
111
+ # setup encryption
112
+ if key
113
+ # create an encrypted volume
114
+ `echo "#{key}" | cryptsetup -q luksFormat --type luks2 --cipher aes-xts-plain64 --key-size 512 /dev/sda2`
115
+ # open the volume
116
+ `echo "#{key}" | cryptsetup open /dev/sda2 cryptlvm -`
117
+ # setup lvm
118
+ `pvcreate /dev/mapper/cryptlvm`
119
+ # create virtual group
120
+ `vgcreate vg0 /dev/mapper/cryptlvm`
121
+ else
122
+ # create physical volume
123
+ `pvcreate /dev/sda2`
124
+ # create virtual group
125
+ `vgcreate vg0 /dev/sda2`
126
+ end
133
127
  # create logical volumes
134
128
  `lvcreate -L #{swap_size}Mib vg0 -n swap`
135
- if scheme == "/boot, /root and /home"
136
- `lvcreate -L #{home_size}Mib vg0 -n home`
137
- end
138
129
  `lvcreate -l 100%FREE vg0 -n root`
139
- # make and mount root fs
130
+ # make and mount rootfs
140
131
  `mkfs.ext4 /dev/vg0/root`
141
132
  `mount /dev/vg0/root /mnt`
142
- # make and mount home folder
143
- if scheme == "/boot, /root and /home"
144
- `mkfs.ext4 /dev/vg0/home`
145
- `mount /dev/vg0/home /mnt/home`
146
- end
147
133
  # make and mount boot partition
148
134
  `mkfs.fat -F32 /dev/sda1`
149
135
  `mkdir /mnt/boot`
150
- if data[:system_settings][:bootloader] == "systemd-boot"
151
- `mount /dev/sda1 /mnt/boot`
152
- else
153
- `mount /dev/sda1 /mnt/boot/efi`
154
- end
136
+ `mount /dev/sda1 /mnt/boot`
155
137
  # setup swap
156
138
  `mkswap /dev/vg0/swap`
157
139
  `swapon /dev/vg0/swap`
158
140
  end
159
141
 
160
- if data[:system_settings][:partition] == "/boot, /root and /home"
161
- setup_lvm(data[:system_settings][:partition], data[:system_settings][:swap_size], data[:system_settings[:home_size]])
142
+ if encrypted
143
+ setup_lvm(data[:system_settings][:swap_size], data[:system_settings][:encryption_settings][:encryption_key])
162
144
  else
163
- setup_lvm(data[:system_settings][:partition], data[:system_settings][:swap_size])
145
+ setup_lvm(data[:system_settings][:swap_size])
164
146
  end
165
147
 
166
148
  def setup_packages
167
149
  # update packages list
168
150
  `pacman -Syy`
169
151
  # install base system
170
- `pacstrap /mnt base base-devel linux linux-firmware lvm2 mkinitcpio dmidecode reflector networkmanager cronie man-db nano vi fuse wget openbsd-netcat dhcpcd samba openssh openvpn unzip vim git zsh`
152
+ `pacstrap /mnt base base-devel linux linux-firmware linux-headers lvm2 mkinitcpio dmidecode reflector networkmanager cronie man-db nano vi fuse wget openbsd-netcat dhcpcd samba openssh openvpn unzip vim git zsh`
171
153
  # generate fstab
172
154
  `genfstab -U /mnt >> /mnt/etc/fstab`
173
155
  end
174
156
 
175
157
  setup_packages
176
158
 
177
- def setup_chroot(lang, keymap, password)
159
+ def setup_chroot(lang, keymap, password, encrypted=false)
178
160
  # set timezone
179
161
  `arch-chroot /mnt ln -sf /usr/share/zoneinfo/"$(curl -s https://ipapi.co/timezone)" /etc/localtime`
180
162
  # update clock
@@ -192,33 +174,43 @@ module Warding
192
174
  # update root password
193
175
  `echo -e "#{password}\n#{password}" | arch-chroot /mnt passwd`
194
176
  # update hooks
195
- `sed -i "/^HOOK/s/filesystems/lvm2 filesystems/" /mnt/etc/mkinitcpio.conf`
177
+ if encrypted
178
+ `sed -i "/^HOOK/s/modconf/keyboard keymap modconf/" /mnt/etc/mkinitcpio.conf`
179
+ `sed -i "/^HOOK/s/filesystems/encrypt lvm2 filesystems/" /mnt/etc/mkinitcpio.conf`
180
+ else
181
+ `sed -i "/^HOOK/s/filesystems/lvm2 filesystems/" /mnt/etc/mkinitcpio.conf`
182
+ end
196
183
  # recompile initramfs
197
- `arch-chroot /mnt mkinitcpio -p linux`
184
+ `arch-chroot /mnt mkinitcpio -P`
198
185
  # add intel microcode
199
186
  `arch-chroot /mnt pacman -S intel-ucode --noconfirm`
200
187
  end
201
188
 
202
- setup_chroot(data[:system_language], data[:keyboard_keymap], data[:root_password])
189
+ if encrypted
190
+ setup_chroot(data[:system_language], data[:keyboard_keymap], data[:root_password], true)
191
+ else
192
+ setup_chroot(data[:system_language], data[:keyboard_keymap], data[:root_password])
193
+ end
203
194
 
204
- def setup_bootloader(loader)
195
+ def setup_bootloader(encrypted=false)
205
196
  # setup systemd-boot
206
- if loader == "systemd-boot"
207
- `arch-chroot /mnt bootctl install`
208
- `echo "title Warding Linux
209
- linux /vmlinuz-linux
210
- initrd /intel-ucode.img
211
- initrd /initramfs-linux.img
212
- options root=/dev/vg0/root rw" > /mnt/boot/loader/entries/warding.conf`
197
+ `arch-chroot /mnt bootctl install`
198
+ `echo "title Warding Linux
199
+ linux /vmlinuz-linux
200
+ initrd /intel-ucode.img
201
+ initrd /initramfs-linux.img" > /mnt/boot/loader/entries/warding.conf`
202
+ if encrypted
203
+ `echo "options cryptdevice=UUID=$(blkid -s UUID -o value /dev/sda2):cryptlvm:allow-discards root=/dev/vg0/root quiet rw" >> /mnt/boot/loader/entries/warding.conf`
213
204
  else
214
- # setup grub
215
- `arch-chroot /mnt pacman -S grub efibootmgr --noconfirm`
216
- `arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB`
217
- `arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg`
205
+ `echo "options root=/dev/vg0/root rw" >> /mnt/boot/loader/entries/warding.conf`
218
206
  end
219
207
  end
220
208
 
221
- setup_bootloader(data[:system_settings][:bootloader])
209
+ if encrypted
210
+ setup_bootloader(true)
211
+ else
212
+ setup_bootloader
213
+ end
222
214
 
223
215
  def setup_usability
224
216
  # enable internet
@@ -230,19 +222,22 @@ module Warding
230
222
  # enable cron jobs
231
223
  `arch-chroot /mnt systemctl enable cronie`
232
224
  # change default shell
233
- `arch-chroot /mnt chsh -s $(which zsh)"`
225
+ `arch-chroot /mnt chsh -s /usr/bin/zsh`
234
226
  # setup blackarch's keyring
235
- `wget -q https://blackarch.org/keyring/blackarch-keyring.pkg.tar.xz{,.sig}`
236
- `gpg --keyserver hkp://pgp.mit.edu --recv-keys 4345771566D76038C7FEB43863EC0ADBEA87E4E3 > /dev/null 2>&1`
237
- `gpg --keyserver-options no-auto-key-retrieve --with-fingerprint blackarch-keyring.pkg.tar.xz.sig > /dev/null 2>&1`
238
- `rm blackarch-keyring.pkg.tar.xz.sig`
239
- `pacman-key --init`
240
- `pacman --config /dev/null --noconfirm -U blackarch-keyring.pkg.tar.xz`
241
- `pacman-key --populate`
227
+ `arch-chroot /mnt curl -s -O https://blackarch.org/keyring/blackarch-keyring.pkg.tar.xz{,.sig}`
228
+ `arch-chroot /mnt gpg --keyserver hkp://pgp.mit.edu --recv-keys 4345771566D76038C7FEB43863EC0ADBEA87E4E3`
229
+ `arch-chroot /mnt gpg --keyserver-options no-auto-key-retrieve --with-fingerprint blackarch-keyring.pkg.tar.xz.sig`
230
+ `arch-chroot /mnt pacman-key --init`
231
+ `arch-chroot /mnt rm blackarch-keyring.pkg.tar.xz.sig`
232
+ `arch-chroot /mnt pacman --noconfirm -U blackarch-keyring.pkg.tar.xz`
233
+ `arch-chroot /mnt pacman-key --populate`
234
+ `arch-chroot /mnt rm blackarch-keyring.pkg.tar.xz`
235
+ `arch-chroot /mnt curl -s https://blackarch.org/blackarch-mirrorlist -o /etc/pacman.d/blackarch-mirrorlist`
236
+ `echo "[blackarch]\nInclude = /etc/pacman.d/blackarch-mirrorlist" >> /mnt/etc/pacman.conf`
242
237
  # update package list
243
- `pacman -Syy`
238
+ `arch-chroot /mnt pacman -Syy`
244
239
  # check if on VM
245
- if `dmidecode -s system-manufacturer`.include?("VMware, Inc.")
240
+ if `arch-chroot /mnt dmidecode -s system-manufacturer`.include?("VMware, Inc.")
246
241
  # install and enable VMware utils
247
242
  `arch-chroot /mnt pacman -S openvpn-vm-tools --noconfirm`
248
243
  `arch-chroot /mnt systemctl enable vmtoolsd`
@@ -253,7 +248,7 @@ module Warding
253
248
 
254
249
  def setup_visuals(theme = "none")
255
250
  if theme == "none"
256
- break
251
+ nil
257
252
  elsif theme == "kde"
258
253
  # install packages
259
254
  `arch-chroot /mnt pacman -S xorg-server xf86-video-intel plasma konsole dolphin kmix sddm kvantum-qt5`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Warding
4
- VERSION = "0.2.7"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlos Pomin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -41,6 +41,7 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - bin/warding
44
+ - debug/install.sh
44
45
  - lib/warding.rb
45
46
  - lib/warding/version.rb
46
47
  - warding.gemspec