-
Notifications
You must be signed in to change notification settings - Fork 1
/
2step
executable file
·391 lines (375 loc) · 13.2 KB
/
2step
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
#!/usr/bin/bash
# SCRIPT - Installation Script
# Installation-Modes:
# 2Step
function part_cfdisk() {
umount $ndrive*
cfdisk $ndrive
if [[ $extparted = *"multiple-drives"* ]]; then
x1=$(dialog --no-cancel --title "$tit7b" --menu "$lan35" 0 0 0 partition "$but8" continue "$but9" 3>&1 1>&2 2>&3 3>&-)
if [[ $x1 == partition ]]; then
ndrive=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit6" --menu "$lan10 \n\n$(lsblk --output NAME,MODEL,PARTTYPENAME,SIZE /dev/{vd*[!0-9],sd*[!0-9],hd*[!0-9],nvme0n[0-9]})" 0 0 0 $drives 3>&1 1>&2 2>&3 3>&-)
part_cfdisk
fi
fi
}
function part_manual() {
extparted=$(dialog --nocancel --title "$tit15" --checklist "$lan36" 0 0 0 "multiple-drives" "$lan37" off "separate-home" "$lan38" off 3>&1 1>&2 2>&3 3>&-)
if [[ -d /sys/firmware/efi ]]; then
dialog --cr-wrap --title "$tit7a $boot_drive" --msgbox "$lan11" 0 0
else
dialog --cr-wrap --title "$tit7a $boot_drive" --msgbox "$lan12" 0 0
fi
ndrive=$boot_drive
part_cfdisk
# Just to fix some problems with lsblk
lsblk $o6 --output NAME,PARTTYPENAME,FSTYPE,SIZE
if [[ $extparted = *"multiple-drives"* ]]; then
partition=$(find /dev/sd* -name '*[0-9]'; find /dev/nvme* -name '*p[0-9]'; find /dev/hd* -name '*[0-9]'; find /dev/vd* -name "*[0-9]")
partition=$(echo $partition | tr "\n" " ")
partlsblk=$(lsblk $drives --output NAME,PARTTYPENAME,FSTYPE,SIZE)
else
partlsblk=$(lsblk $o6 --output NAME,PARTTYPENAME,FSTYPE,SIZE)
if [[ $nvme == true ]]; then
partition=$(find $boot_drive* -name '*p[0-9]' | tr "\n" " ")
partition=$(echo $partition)
if [[ "$partition" == "" ]]; then
partition=$(find "$boot_drive"* -name '*p[0-9]' | tr "\n" " ")
partition=$(echo $partition)
if [[ "$partition" == "" ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err4a $boot_drive $err4b" 0 0
exit
fi
fi
else
partition=$(find $boot_drive* -name '*[0-9]' | tr "\n" " ")
partition=$(echo $partition)
if [[ "$partition" == "" ]]; then
partition=$(find "$boot_drive"* -name '*[0-9]' | tr "\n" " ")
partition=$(echo $partition)
if [[ "$partition" == "" ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err4a $boot_drive $err4b" 0 0
exit
fi
fi
fi
fi
if [[ -d /sys/firmware/efi ]]; then
e1=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit7b" --menu "$lan13 \n\n$partlsblk" 0 0 0 $partition 3>&1 1>&2 2>&3 3>&-)
dialog --cr-wrap --title "$tit8 $e1" --yesno "$lan14" 0 0
if [[ $? == 0 ]]; then
yes | mkfs.vfat $e1
fi
fi
o7=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit7b" --menu "$lan17 \n\n$partlsblk" 0 0 0 $partition 3>&1 1>&2 2>&3 3>&-)
fs=$(dialog --cr-wrap --no-items --no-cancel --title "$tit7b" --menu "$lan33" 0 0 0 btrfs ext4 3>&1 1>&2 2>&3 3>&-)
case $fs in
btrfs) extp="grub-btrfs btrfs-progs" ;;
esac
dialog --cr-wrap --title "$tit8 $o7" --default-button no --yesno "$lan18" 0 0
if [[ $? == 1 ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err5" 0 0
exit
fi
case $fs in
ext4) yes | mkfs.ext4 $o7 ;;
btrfs) mkfs.btrfs --force $o7 ;;
esac
if [[ $extparted = *"separate-home"* ]]; then
x2=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit7b" --menu "$lan34 \n\n$partlsblk" 0 0 0 $partition 3>&1 1>&2 2>&3 3>&-)
x2fs=$(dialog --cr-wrap --no-items --no-cancel --title "$tit7b" --menu "$lan33" 0 0 0 btrfs ext4 3>&1 1>&2 2>&3 3>&-)
case $x2fs in
btrfs) extp="grub-btrfs btrfs-progs" ;;
esac
dialog --cr-wrap --title "$tit8 $x2" --default-button no --yesno "$lan18" 0 0
if [[ $? == 1 ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err5" 0 0
exit
fi
case $x2fs in
ext4) yes | mkfs.ext4 $x2 ;;
btrfs) mkfs.btrfs --force $x2 ;;
esac
dialog --cr-wrap --title "$tit9" --yesno "$lan15" 0 0
fi
if [[ $? == 0 ]]; then
swap=yes
o8=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit7b" --menu "$lan16 \n\n$partlsblk" 0 0 0 $partition 3>&1 1>&2 2>&3 3>&-)
yes | mkswap $o8
fi
}
function part_automatic() {
fs=$(dialog --cr-wrap --no-items --no-cancel --title "$tit7b" --menu "$lan33" 0 0 0 btrfs ext4 3>&1 1>&2 2>&3 3>&-)
case $fs in
btrfs) extp="grub-btrfs" ;;
esac
dialog --cr-wrap --title "$tit8 $boot_drive" --default-button no --yesno "$lan31" 0 0
if [[ $? == 1 ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err9" 0 0
exit
fi
if [[ -d /sys/firmware/efi ]]; then
echo "o
y
n
300M
ef00
n
5G
8200
n
8300
w
y" | gdisk $boot_drive
swap=yes
if [[ $nvme == true ]]; then
yes | mkfs.vfat "$boot_drive"p1
e1="$boot_drive"p1
yes | mkswap "$boot_drive"p2
o8="$boot_drive"p2
case $fs in
ext4) yes | mkfs.ext4 "$boot_drive"p3 ;;
btrfs) mkfs.btrfs --force "$boot_drive"p3 ;;
esac
o7="$boot_drive"p3
else
yes | mkfs.vfat "$boot_drive"1
e1="$boot_drive"1
yes | mkswap "$boot_drive"2
o8="$boot_drive"2
case $fs in
ext4) yes | mkfs.ext4 "$boot_drive"3 ;;
btrfs) mkfs.btrfs --force "$boot_drive"3 ;;
esac
o7="$boot_drive"3
fi
else
echo "o
n
p
+5G
t
82
n
p
a
2
w" | fdisk $boot_drive
swap=yes
if [[ $nvme == true ]]; then
yes | mkswap "$boot_drive"p1
o8="$boot_drive"p1
case $fs in
ext4) yes | mkfs.ext4 "$boot_drive"p2 ;;
btrfs) mkfs.btrfs --force "$boot_drive"p2 ;;
esac
o7="$boot_drive"p2
else
yes | mkswap "$boot_drive"1
o8="$boot_drive"1
case $fs in
ext4) yes | mkfs.ext4 "$boot_drive"2 ;;
btrfs) mkfs.btrfs --force "$boot_drive"2 ;;
esac
o7="$boot_drive"2
fi
fi
}
slan=$1
source /var/setup/lang.conf $slan
d1=$(find /dev/sd* -not -name '*[0-9]' | tr "\n" " ")
d2=$(find /dev/vd* -not -name '*[0-9]' | tr "\n" " ")
d3=$(find /dev/hd* -not -name '*[0-9]' | tr "\n" " ")
d4=$(find /dev/nvme0n* -not -name '*p[0-9]' | tr "\n" " ")
drives="$d1 $d2 $d3 $d4"
drives=$(echo $drives)
o6=$(dialog --cr-wrap --no-collapse --no-cancel --no-items --title "$tit6" --menu "$lan10 \n\n$(lsblk --output NAME,MODEL,PARTTYPENAME,SIZE /dev/{vd*[!0-9],sd*[!0-9],hd*[!0-9],nvme0n[0-9]})" 0 0 0 $drives 3>&1 1>&2 2>&3 3>&-)
if [[ $o6 == /dev/nvme* ]]; then
nvme=true
else
nvme=false
fi
boot_drive=$o6
umount $boot_drive*
swapoff $boot_drive*
o10=$(dialog --title "$tit7b" --menu "$lan30" 0 0 0 "$but5b" "$but5" "$but6b" "$but6" 3>&1 1>&2 2>&3 3>&-)
if [[ $o10 == "$but5b" ]]; then
part_automatic
elif [[ $o10 == "$but6b" ]]; then
part_manual
fi
if grep -q "GenuineIntel" /proc/cpuinfo; then
cpu=intel-ucode
elif grep -q "AuthenticAMD" /proc/cpuinfo; then
cpu=amd-ucode
elif grep -q "CentaurHauls\|TransmetaCPU" /proc/cpuinfo; then
:
else
cpu=$(dialog --no-items --cr-wrap --title "$tit12" --menu "$lan21" 0 0 0 Intel AMD Transmeta VIA 3>&1 1>&2 2>&3 3>&-)
if [[ $cpu == AMD ]]; then
cpu=amd-ucode
elif [[ $cpu == Intel ]]; then
cpu=intel-ucode
fi
fi
pci=$(lspci)
dialog --cr-wrap --title "$tit14" --yes-label "Opensource" --no-label "Proprietary" --yesno "$lan32" 0 0
if [[ $? == 0 ]]; then
drsrc="open"
elif [[ $? == 1 ]]; then
drsrc="pro"
else
drsrc="open"
fi
if echo "$pci" | grep -i amd > /dev/null; then
case $drsrc in
pro) gpu="xf86-video-amdgpu mesa" ;;
open) gpu="xf86-video-ati mesa" ;;
esac
echo "AMD Device detected"
fi
if echo "$pci" | grep -i nvidia > /dev/null; then
case $drsrc in
pro) gpu="nvidia nvidia-utils nvidia-settings" ;;
open) gpu="xf86-video-nouveau mesa" ;;
esac
echo "NVIDIA Graphics Card detected"
fi
if echo "$pci" | grep -i virtualbox > /dev/null || echo "$pci" | grep -i vmware > /dev/null; then
gpu="virtualbox-guest-utils open-vm-tools"
echo "VMware or Virtualbox Hypervisor detected"
fi
if echo "$pci" | grep -i intel > /dev/null; then
case $drsrc in
pro) gpu="xf86-video-intel mesa" ;;
open) gpu="mesa" ;;
esac
echo "Intel Device detected"
fi
dialog --cr-wrap --title "$mtit" --msgbox "$lan23" 0 0
mount "$o7" /target
if [[ $fs == btrfs ]]; then
btrfs subvolume create /target/@
if [[ $extparted != *"separate-home"* ]]; then
btrfs subvolume create /target/@home
fi
btrfs subvolume create /target/@var
btrfs subvolume create /target/@snapshots
umount /target
mount -o noatime,compress=zstd,space_cache=v2,ssd,discard=async,subvol=@ $o7 /target
mkdir -p /target/{home,var,.snapshots}
if [[ $extparted != *"separate-home"* ]]; then
mount -o noatime,compress=zstd,space_cache=v2,ssd,discard=async,subvol=@home $o7 /target/home
fi
mount -o noatime,compress=zstd,space_cache=v2,ssd,discard=async,subvol=@var $o7 /target/var
mount -o noatime,compress=zstd,space_cache=v2,ssd,discard=async,subvol=@snapshots $o7 /target/.snapshots
fi
if [[ $extparted = *"separate-home"* ]]; then
mkdir -p /target/home
mount "$x2" /target/home
if [[ $x2fs == btrfs ]]; then
echo "Please note: This is not a bug! The Partition will be unmounted later and correctly mounted:"
btrfs subvolume create /target/home/@home
umount /target/home
mount -o noatime,compress=zstd,space_cache=v2,ssd,discard=async,subvol=@home $x2 /target/home
fi
fi
if [[ -d /sys/firmware/efi ]]; then
mkdir -p /target/boot/efi
mount "$e1" /target/boot/efi
fi
pacman --noconfirm --needed -Sy archlinux-keyring
pacstrap /target base linux linux-firmware git nano $cpu iptables-nft neovim vim
if [[ $swap == yes ]]; then
swapon "$o8"
fi
genfstab -U /target >> /target/etc/fstab
if [[ -d /sys/firmware/efi ]]; then
grub="grub efibootmgr"
else
grub="grub"
fi
arch-chroot /target bash -c "pacman --needed --noconfirm -Sy $gpu $grub networkmanager network-manager-applet dialog wpa_supplicant mtools dosfstools reflector base-devel linux-headers avahi xdg-user-dirs xdg-utils gvfs gvfs-smb nfs-utils inetutils dnsutils bluez bluez-utils cups hplip alsa-utils pulseaudio bash-completion openssh rsync reflector acpi acpi_call tlp edk2-ovmf bridge-utils dnsmasq vde2 openbsd-netcat iptables-nft ipset firewalld flatpak sof-firmware nss-mdns acpid os-prober ntfs-3g terminus-font numlockx wget man-db neofetch cargo nvme-cli"
echo "echo 'root:$root_pass' | chpasswd" > /target/chpasswd.sh
sed -i "s/#GRUB_DISABLE_OS_PROBER=false/GRUB_DISABLE_OS_PROBER=false/" /target/etc/default/grub
if [[ -d /sys/firmware/efi ]]; then
arch-chroot /target bash -c "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB"
else
arch-chroot /target bash -c "grub-install --target=i386-pc $boot_drive"
fi
arch-chroot /target bash -c "grub-mkconfig -o /boot/grub/grub.cfg"
arch-chroot /target bash -c "systemctl enable NetworkManager bluetooth cups.service avahi-daemon tlp reflector.timer fstrim.timer firewalld acpid"
# NOTE: The User will change this after a reboot
arch-chroot /target bash -c "echo root:root | chpasswd"
mkdir -p /target/var/setup
if [[ ! -f /var/setup/bashrc ]]; then
curl -o /var/setup/bashrc https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/bashrc
fi
if [[ ! -f /var/setup/bashrc.root ]]; then
curl -o /var/setup/bashrc.root https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/bashrc.root
fi
cp /var/setup/bashrc /target/etc/skel/.bashrc
cp /var/setup/bashrc.root /target/root/.bashrc
echo "if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi" > /target/root/.profile
if [[ -f /var/setup/installed.conf ]]; then
cp /var/setup/installed.conf /target/var/setup/lang.conf
else
curl -o /var/setup/installed.conf https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/installed/lang.conf
fi
if [[ -f /var/setup/installer ]]; then
cp /var/setup/installer /target/usr/bin/installer
else
curl -o /target/usr/bin/installer https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/installed/installer
fi
chmod +x /target/usr/bin/installer
if [[ ! -f /target/usr/bin/installer ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err6" 0 0
fi
if [[ -f /var/setup/sumkpkg ]]; then
cp /var/setup/sumkpkg /target/var/setup/sumkpkg
else
curl -o /target/var/setup/sumkpkg https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/sumkpkg
fi
chmod +x /target/var/setup/sumkpkg
if [[ ! -f /target/var/setup/sumkpkg ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err7" 0 0
exit
fi
if [[ ! -f /var/setup/autologin.tmp ]]; then
curl -o /var/setup/autologin.tmp https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/autologin.tmp
fi
if [[ -f /var/setup/desktopinstall ]]; then
cp /var/setup/desktopinstall /target/usr/bin/desktopinstall
else
curl -o /target/usr/bin/desktopinstall https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/installed/destopinstall
fi
chmod +x /target/usr/bin/desktopinstall
if [[ ! -f /target/usr/bin/desktopinstall ]]; then
dialog --cr-wrap --title "$err2" --msgbox "$err8b" 0 0
exit
fi
if [[ ! -f /var/setup/setup ]]; then
curl -o /target/usr/bin/setup https://raw.githubusercontent.com/Niklas20114552/arch-tui-installer/main/installed/setup
else
cp -r /var/setup/setup /target/usr/bin/setup
fi
chmod +x /target/usr/bin/setup
if [ -e /etc/iwd/main.conf ]; then
cp /etc/iwd/main.conf /target/etc/iwd/main.conf
else
echo "/etc/iwd/main.conf does not exist. Skipped."
fi
cp -rf /var/lib/iwd /target/var/lib/iwd
cp -f /var/setup/lang.conf /target/var/setup/2step.conf
mkdir -p "/target/etc/systemd/system/[email protected]"
echo "setup" >> /target/root/.bashrc
cp /var/setup/autologin.tmp /target/etc/systemd/system/[email protected]/autologin.conf
dialog --title "$mtit" --ok-label "$but4" --pause "$lan24" 8 50 10
if [[ $? != 1 ]]; then
umount -a
reboot
else
exit
fi