warding 0.2.0 → 0.2.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/warding.rb +102 -90
  3. data/lib/warding/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61af4b1237c08e8310c900abea7ec87c83690338d9280f8fd1f560b3dd07f289
4
- data.tar.gz: bf550f3cee879ea196711c1de7939f8bc388db847707da10e30992cb351c7794
3
+ metadata.gz: 1336ed9c9428a9d4a863bcff8d1f9e5d9f5c10aac9470b613b77ef1bb582c766
4
+ data.tar.gz: 10b78d4ceeb9c41b8241b8273b84150baa9c991319f4397ccb1df784d554ac3d
5
5
  SHA512:
6
- metadata.gz: 209a4dbd18ab2939cde65efe6cf381b5e2064b336747a2f7c197ce508669c0b70a5715ae882767fc52175ef2bc6b82a3c0bd12fddae3b672927fdaccb36f66a3
7
- data.tar.gz: 113a0a52a3943836203b3b9959308473c3beec215019a457f3dba64b8293f11fe2dcebe333dea5063a33e19796c567e0f46fd13a4270ce79c56448448018b33c
6
+ metadata.gz: e9f73200e9ea088e7f1dc5a3b47e84b0b84ed6d6bb4008a16b4cbd48398c59f0262233f4923e42beb97ff0e6f5f0152dfecae9bdd498fbe89d1bfc3663eeda2a
7
+ data.tar.gz: 2814c6eae1c1f05fab93853b2e39e8bf7c41888bc28759955d13eec06e9536dc75955c17702ba50a52b341a8ea1ebf298a03c4d66c9e77f37d152f7b51e6ca68
@@ -89,133 +89,145 @@ module Warding
89
89
  def install(data)
90
90
  if @@prompt.yes?('Confirm settings and continue?')
91
91
 
92
- # setup mirrorlist
92
+ @@prompt.say("Installing, please wait...")
93
93
 
94
- if data[:update_mirrors]
94
+ def setup_mirrors
95
95
  `reflector --latest 25 --sort rate --save /etc/pacman.d/mirrorlist`
96
96
  end
97
97
 
98
- # setup timezone
98
+ setup_mirrors if data[:update_mirrors]
99
99
 
100
- `timedatectl set-ntp true`
101
-
102
- if data[:update_timezone]
103
- `timedatectl set-timezone #{data[:update_timezone]}`
104
- else
105
- `timedatectl set-timezone "$(curl --fail https://ipapi.co/timezone)"`
100
+ def setup_timezone(timezone)
101
+ `timedatectl set-ntp true`
102
+ if timezone
103
+ `timedatectl set-timezone #{timezone}`
104
+ else
105
+ `timedatectl set-timezone "$(curl --fail https://ipapi.co/timezone)"`
106
+ end
106
107
  end
107
108
 
108
- # setup paritions
109
-
110
- `parted -s -a optimal /dev/sda \
111
- mklabel gpt \
112
- mkpart primary fat32 0% #{data[:system_settings][:boot_size]}Mib \
113
- set 1 esp on \
114
- mkpart primary ext4 #{data[:system_settings][:boot_size]}Mib 100% \
115
- set 2 lvm on
116
- `
117
-
118
- `pvcreate /dev/sda2`
119
- `vgcreate vg0 /dev/sda2`
120
- `lvcreate -L #{data[:system_settings][:swap_size]}Mib vg0 -n swap`
121
- `lvcreate -L #{data[:system_settings[:home_size]]}Mib vg0 -n home` if data[:system_settings][:partition] == '/boot, /root and /home'
122
- `lvcreate -l 100%FREE vg0 -n root`
109
+ data[:update_timezone] ? setup_timezone(data[:update_timezone]) : setup_timezone
123
110
 
124
- `mkfs.ext4 /dev/vg0/root`
125
- `mount /dev/vg0/root /mnt`
126
-
127
- if data[:system_settings][:partition] == '/boot, /root and /home'
128
- `mkfs.ext4 /dev/vg0/home`
129
- `mount /dev/vg0/home /mnt/home`
111
+ def setup_partitions(boot_size)
112
+ `parted -s -a optimal /dev/sda \
113
+ mklabel gpt \
114
+ mkpart primary fat32 0% #{boot_size}Mib \
115
+ set 1 esp on \
116
+ mkpart primary ext4 #{boot_size}Mib 100% \
117
+ set 2 lvm on
118
+ `
130
119
  end
131
120
 
132
- `mkfs.fat -F32 /dev/sda1`
133
- `mkdir /mnt/boot`
134
-
135
- `mkswap /dev/vg0/swap`
136
- `swapon /dev/vg0/swap`
137
-
138
- # setup encryption
139
-
140
- # TODO: everything
141
-
142
- # setup base packages
143
-
144
- `pacman -Sy`
145
- `pacstrap /mnt base base-devel`
146
- `genfstab -U /mnt >> /mnt/etc/fstab`
147
-
148
- # setup chroot
149
-
150
- `arch-chroot /mnt ln -sf /usr/share/zoneinfo/"$(curl --fail https://ipapi.co/timezone)" /etc/localtime`
151
- `arch-chroot /mnt hwclock --systohc`
152
-
153
- `echo "#{data[:system_language]}.UTF-8" > /mnt/etc/locale.gen`
154
- `arch-chroot /mnt locale-gen`
155
- `echo "LANG=#{data[:system_language]}.UTF-8" > /mnt/etc/locale.conf`
121
+ setup_partitions(data[:system_settings][:boot_size])
156
122
 
157
- `echo KEYMAP=#{data[:keyboard_keymap]} > /mnt/etc/vconsole.conf`
158
-
159
- `echo "warding" > /mnt/etc/hostname`
160
-
161
- `echo "127.0.0.1 localhost
162
- ::1 localhost
163
- 127.0.1.1 warding.localdomain warding" > /mnt/etc/hosts`
164
-
165
- `arch-chroot /mnt echo -e "#{data[:root_password]}\n#{data[:root_password]}" | passwd`
166
-
167
- `arch-chroot /mnt pacman -Sy archlinux-keyring linux lvm2 mkinitcpio --noconfirm`
123
+ def setup_lvm(scheme, swap_size, home_size=false)
124
+ `pvcreate /dev/sda2`
125
+ `vgcreate vg0 /dev/sda2`
126
+ `lvcreate -L #{swap_size}Mib vg0 -n swap`
127
+ if scheme == '/boot, /root and /home'
128
+ `lvcreate -L #{home_size}Mib vg0 -n home`
129
+ end
130
+ `lvcreate -l 100%FREE vg0 -n root`
168
131
 
169
- `sed -i "/^HOOK/s/filesystems/lvm2 filesystems/" /mnt/etc/mkinitcpio.conf`
132
+ `mkfs.ext4 /dev/vg0/root`
133
+ `mount /dev/vg0/root /mnt`
170
134
 
171
- `arch-chroot /mnt mkinitcpio -p linux`
135
+ if scheme == '/boot, /root and /home'
136
+ `mkfs.ext4 /dev/vg0/home`
137
+ `mount /dev/vg0/home /mnt/home`
138
+ end
172
139
 
173
- `arch-chroot /mnt pacman -S intel-ucode --noconfirm`
140
+ `mkfs.fat -F32 /dev/sda1`
141
+ `mkdir /mnt/boot`
142
+ `mount /dev/sda1 /mnt/boot`
174
143
 
175
- # bootloader
144
+ `mkswap /dev/vg0/swap`
145
+ `swapon /dev/vg0/swap`
146
+ end
176
147
 
177
- if data[:system_settings][:bootloader] == 'systemd-boot'
178
- `arch-chroot /mnt bootctl install`
179
- `echo "title Warding Linux
180
- linux /vmlinuz-linux
181
- initrd /intel-ucode.img
182
- initrd /initramfs-linux.img
183
- options root=/dev/vg0/root rw" > /mnt/boot/loader/entries/warding.conf`
148
+ if data[:system_settings][:partition] == '/boot, /root and /home'
149
+ setup_lvm(data[:system_settings][:partition], data[:system_settings][:swap_size], data[:system_settings[:home_size]])
184
150
  else
185
- # TODO: grub
151
+ setup_lvm(data[:system_settings][:partition], data[:system_settings][:swap_size])
186
152
  end
187
153
 
188
- # setup default packages
154
+ # setup encryption
155
+ # TODO: everything
156
+
157
+ def setup_packages
158
+ `pacman -Sy`
159
+ `pacstrap /mnt base base-devel`
160
+ `genfstab -U /mnt >> /mnt/etc/fstab`
161
+ end
189
162
 
190
- # TODO: include gnome desktop
191
- `arch-chroot /mnt pacman -S make nano fuse wget automake cmake gcc autoconf openbsd-netcat dhcpcd samba openssh openvpn unzip vim xorg-server xf86-video-intel plasma konsole dolphin kmix sddm wget git kvantum-qt5 zsh --noconfirm`
163
+ def setup_chroot(lang, keymap, password)
164
+ `arch-chroot /mnt ln -sf /usr/share/zoneinfo/"$(curl --fail https://ipapi.co/timezone)" /etc/localtime`
165
+ `arch-chroot /mnt hwclock --systohc`
166
+
167
+ `echo "#{lang}.UTF-8" > /mnt/etc/locale.gen`
168
+ `arch-chroot /mnt locale-gen`
169
+ `echo "LANG=#{lang}.UTF-8" > /mnt/etc/locale.conf`
170
+ `echo KEYMAP=#{keymap} > /mnt/etc/vconsole.conf`
171
+ `echo "warding" > /mnt/etc/hostname`
172
+ `echo "127.0.0.1 localhost
173
+ ::1 localhost
174
+ 127.0.1.1 warding.localdomain warding" > /mnt/etc/hosts`
175
+
176
+ `arch-chroot /mnt echo -e "#{password}\n#{password}" | passwd`
177
+
178
+ `arch-chroot /mnt pacman -Sy linux lvm2 mkinitcpio --noconfirm`
179
+ `sed -i "/^HOOK/s/filesystems/lvm2 filesystems/" /mnt/etc/mkinitcpio.conf`
180
+ `arch-chroot /mnt mkinitcpio -p linux`
181
+ `arch-chroot /mnt pacman -S intel-ucode --noconfirm`
182
+ end
192
183
 
193
- `arch-chroot /mnt systemctl enable dhcpcd`
194
- `arch-chroot /mnt systemctl enable sddm`
184
+ setup_chroot(data[:system_language], data[:keyboard_keymap], data[:root_password])
185
+
186
+ def setup_bootloader(loader)
187
+ if loader == 'systemd-boot'
188
+ `arch-chroot /mnt bootctl install`
189
+ `echo "title Warding Linux
190
+ linux /vmlinuz-linux
191
+ initrd /intel-ucode.img
192
+ initrd /initramfs-linux.img
193
+ options root=/dev/vg0/root rw" > /mnt/boot/loader/entries/warding.conf`
194
+ else
195
+ # TODO: grub
196
+ end
197
+ end
195
198
 
196
- `arch-chroot /mnt wget -qO- https://blackarch.org/strap.sh | sh`
199
+ setup_bootloader(data[:system_settings][:bootloader])
197
200
 
198
- `arch-chroot /mnt wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh`
201
+ def setup_usability
202
+ # TODO: include gnome desktop
203
+ `arch-chroot /mnt pacman -S nano fuse wget cmake openbsd-netcat dhcpcd samba openssh openvpn unzip vim xorg-server xf86-video-intel plasma konsole dolphin kmix sddm wget git kvantum-qt5 zsh --noconfirm`
204
+ `arch-chroot /mnt systemctl enable dhcpcd`
205
+ `arch-chroot /mnt systemctl enable sddm`
206
+ `arch-chroot /mnt wget -qO- https://blackarch.org/strap.sh | sh`
207
+ `arch-chroot /mnt wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh`
208
+ end
199
209
 
200
- # setup themes
210
+ setup_usability
201
211
 
202
- if data[:extra_settings].include?('themes')
212
+ def setup_visuals
203
213
  `arch-chroot /mnt wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/arc-kde/master/install.sh | sh`
204
214
  `arch-chroot /mnt wget -qO- https://git.io/papirus-icon-theme-install | sh`
205
215
  end
206
216
 
207
- # setup extra tools
217
+ setup_visuals if data[:extra_settings].include?('themes')
208
218
 
209
- if data[:extra_settings].include?('tools')
219
+ def setup_extras
210
220
  `arch-chroot /mnt pacman -S nmap impacket go ruby php firefox atom hashcat john jre-openjdk proxychains-ng exploitdb httpie metasploit bind-tools radare2 sqlmap wpscan xclip --noconfirm`
211
221
  `arch-chroot /mnt mkdir -p /usr/share/wordlists`
212
222
  `arch-chroot /mnt wget -q https://github.com/danielmiessler/SecLists/raw/master/Passwords/Leaked-Databases/rockyou.txt.tar.gz -O /usr/share/wordlists/rockyou.txt.tar.gz`
213
223
  `arch-chroot /mnt wget -q https://github.com/danielmiessler/SecLists/raw/master/Discovery/Web-Content/common.txt -O /usr/share/wordlists/common.txt`
214
224
  end
215
225
 
216
- # setup crons
226
+ setup_extras if data[:extra_settings].include?('tools')
217
227
 
218
- # TODO: include crons
228
+ def setup_cron
229
+ # TODO: include crons
230
+ end
219
231
  end
220
232
  end
221
233
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Warding
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlos Pomin