-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-gnome.sh
executable file
·443 lines (379 loc) · 11 KB
/
install-gnome.sh
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#!/bin/bash
function main(){
language="en_IN.UTF-8"
timezone="Asia/Kolkata"
linuxpkg="base linux linux-firmware"
develpkg="base-devel nano vim vi wget git go"
baseutilspkg="sudo man bash-completion reflector tmux tlp ffmpeg efibootmgr neofetch"
microcodepkg="amd-ucode"
filesystempkg="btrfs-progs"
networkpkg="wpa_supplicant"
audiopkg="alsa-utils pulseaudio pulseaudio-alsa"
bluetoothpkg="bluez bluez-utils"
xorgpkg="xorg-server xorg-xinit xorg-server-xwayland"
graphicspkg="mesa xf86-video-amdgpu vulkan-radeon libva-mesa-driver mesa-vdpau opencl-mesa lib32-mesa lib32-vulkan-radeon lib32-libva-mesa-driver lib32-mesa-vdpau"
iopkg="xf86-input-synaptics"
deskenvpkg="gnome"
guiutilspkg="ffmpegthumbnailer"
appspkg="gparted"
aurwrapper="yay"
continuestate=1
#try
(
set -e
if [[ -z "$@" ]]
then
continueinstall
else
if [[ -z "$2" && -f "archinstalllog.txt" ]]
then
source "archinstalllog.txt"
continuestate="$crashedstate"
else
continuestate="$2"
fi
export setupoption="$1"
setup "$0"
fi
)
# catch
errorcode="$?"
if [[ $errorcode -ne 0 ]]
then
echo "ERROR!!! Arch Linux Installer Failed at stage $continuestate!!"
echo crashedstate="$continuestate" > archinstalllog.txt
exit $continuestate
fi
}
function setup(){
case "$setupoption" in
"-h" | "--help")
echo ''
echo 'Usage:'
echo " $1"
echo " $1 [options]"
echo " $1 -c <continuecode>"
echo ''
echo 'Arch Linux Installer'
echo ''
echo 'Options:'
echo ' -h, --help help'
echo ' -u, --update update the install script'
echo ' -c, --continue continue'
echo ' -m, --mount mountall'
echo ' -um, --umount unmountall'
echo ' -cr, --chroot chroot into installed system'
echo ' -ft, --fixtime update system time (1)'
echo ' -p, --part partition disks (2)'
echo ' -f, --format format disks (3)'
echo ' -s, --swap turn on swap (4)'
echo ' -r, --root setup root (5)'
echo ' -m, --mirror refresh mirrors (6)'
echo ' -i, --install install arch (7)'
echo ' -et, --ntp enable ntp (8)'
echo ' -l, --locale generate locale (9)'
echo ' -hn, --hostname configure hostname (10)'
echo ' -in, --initramfs generate initramfs (11)'
echo ' -cu, --createuser create new user (12)'
echo ' -eb, --bluetooth enable bluetooth (13)'
echo ' -en, --network enable network manager (14)'
echo ' -et, --tlp enable tlp (15)'
echo ' -d, --displaymanager enable display manager (16)'
echo ' -g, --graphics configure graphics (17)'
echo ' -a, --aur install aur helpers (18)'
echo ' -b, --boot install bootloader (19)'
echo ' -sb, --secureboot enable secureboot (20)'
echo ' -q, --quit quit installer (21)'
echo ''
echo 'Continue codes are given in brackets. Installer will proceed to execute it and all the instructions below it.'
;;
"-u" | "--update") updatescript "$1"
;;
"-c" | "--continue") continueinstall
;;
"-m" | "--mount") mountall
;;
"-um" | "--umount") unmountall
;;
"-cr" | "--chroot") archchroot
;;
"-ft" | "--fixtime") updatesystime
;;
"-p" | "--part") partitiondisks
;;
"-f" | "--format") formatdisks
;;
"-s" | "--swap") turnonswap
;;
"-r" | "--root") setuproot
;;
"-m" | "--mirror") refreshmirrors || true
;;
"-i" | "--install") installarchlinux
;;
"-et" | "--ntp") archsynctime
;;
"-l" | "--locale") archlocalegen
;;
"-hn" | "--hostname") archsethostname
;;
"-in" | "--initramfs") archgeninitramfs
;;
"-cu" | "--createuser") archcreateuser
;;
"-eb" | "--bluetooth") archenablebluetooth
;;
"-en" | "--network") archenablenetwork
;;
"-et" | "--tlp") archenabletlp
;;
"-d" | "--displaymanager") archenabledisplaymanager
;;
"-g" | "--graphics") archgraphics
;;
"-a" | "--aur") archinstallaurhelpers
;;
"-b" | "--boot") archinstallbootloader
;;
"-sb" | "--secureboot") archsecureboot
;;
"-q" | "--quit") finishinstall
esac
}
function continueinstall(){
case "$continuestate" in
1) updatesystime
continuestate=1
;&
2) partitiondisks
continuestate=2
;&
3) formatdisks
continuestate=3
;&
4) turnonswap
continuestate=4
;&
5) setuproot
continuestate=5
;&
6) refreshmirrors || true
continuestate=6
;&
7) installarchlinux
continuestate=7
;&
8) archsynctime
continuestate=8
;&
9) archlocalegen
continuestate=9
;&
10) archsethostname
continuestate=10
;&
11) archgeninitramfs
continuestate=11
;&
12) archcreateuser
continuestate=12
;&
13) archenablebluetooth
continuestate=13
;&
14) archenablenetwork
continuestate=14
;&
15) archenabletlp
continuestate=15
;&
16) archenabledisplaymanager
continuestate=16
;&
17) archgraphics
continuestate=17
;&
18) archinstallaurhelpers
continuestate=18
;&
19) archinstallbootloader
continuestate=19
;&
20) archsecureboot
continuestate=20
;&
21) finishinstall
esac
}
function updatescript(){
curl -L "https://www.tinyurl.com/aim-arch-install" -o $1 && exit 0
}
function mountall(){
swapon /dev/sda2
mount -o subvol=@,compress=zstd,noatime,nodiratime /dev/sda3 /mnt
mount -o subvol=@home,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/home
mount -o subvol=@var,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/var
mount -o subvol=@snapshots,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/.snapshots
mount /dev/sda1 /mnt/boot
}
function unmountall(){
swapoff /dev/sda2 || true
umount /mnt/home || true
umount /mnt/var || true
umount /mnt/.snapshots || true
umount /mnt || true
umount /dev/sda3 || true
}
function archchroot(){
arch-chroot /mnt /bin/bash
}
function updatesystime() {
systemctl enable --now systemd-timesyncd
timedatectl set-ntp true
}
function partitiondisks(){
parted --script /dev/sda \
rm 1 \
rm 2 \
rm 3 \
mkpart primary fat32 1MiB 513MiB \
mkpart primary linux-swap 513MiB 4609MiB \
mkpart primary btrfs 4609MiB 500001MiB \
set 1 esp on \
set 2 swap on \
unit MiB print \
quit
}
function formatdisks(){
mkfs.fat -F32 /dev/sda1
mkswap /dev/sda2
mkfs.btrfs -L "Computer" -f /dev/sda3
}
function turnonswap(){
swapon /dev/sda2
}
function setuproot(){
mount /dev/sda3 /mnt
btrfs su cr /mnt/@
btrfs su cr /mnt/@home
btrfs su cr /mnt/@var
btrfs su cr /mnt/@snapshots
umount /mnt
mount -o subvol=@,compress=zstd,noatime,nodiratime /dev/sda3 /mnt
mkdir /mnt/{boot,home,var,.snapshots}
mount -o subvol=@home,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/home
mount -o subvol=@var,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/var
mount -o subvol=@snapshots,compress=zstd,noatime,nodiratime /dev/sda3 /mnt/.snapshots
mount /dev/sda1 /mnt/boot
}
function refreshmirrors(){
sed -i '/\[multilib\]/,/mirrorlist/ s/#//' /etc/pacman.conf
pacman -Syy --noconfirm reflector
reflector --verbose --sort rate --save /etc/pacman.d/mirrorlist
}
function installarchlinux(){
pacstrap /mnt $linuxpkg $microcodepkg $develpkg $baseutilspkg $filesystempkg $networkpkg $audiopkg $bluetoothpkg $xorgpkg $graphicspkg $iopkg $deskenvpkg $guiutilspkg $appspkg
genfstab -U /mnt >> /mnt/etc/fstab
}
function runinchroot(){
arch-chroot /mnt /bin/bash -c "$@"
}
function runasuser(){
runinchroot "su aim -c -- '$@'"
}
function archsynctime(){
runinchroot "ln -sf /usr/share/zoneinfo/$timezone /etc/localtime && \
hwclock --systohc && \
systemctl enable systemd-timesyncd && \
timedatectl set-ntp true"
}
function archlocalegen(){
sed -i "/$language/s/^#//g" /mnt/etc/locale.gen
runinchroot "locale-gen"
echo "LANG=$language" >> /mnt/etc/locale.conf
}
function archsethostname(){
echo pandora >> /mnt/etc/hostname
}
function archgeninitramfs(){
sed -i 's/block filesystems/block btrfs filesystems/' /mnt/etc/mkinitcpio.conf
sed -i '/MODULES=()/s/()/(amdgpu radeon)/' /mnt/etc/mkinitcpio.conf
runinchroot "mkinitcpio -P"
}
function archcreateuser(){
runinchroot "passwd -l root && \
useradd -mg users -G wheel,storage,power -s /bin/bash aim && \
echo aim:aim | chpasswd"
sed -i '/%wheel ALL=(ALL) ALL/s/# //' /mnt/etc/sudoers
}
function archenablebluetooth(){
runinchroot "systemctl enable bluetooth"
}
function archenablenetwork(){
runinchroot "systemctl enable NetworkManager"
}
function archenabletlp(){
runinchroot "tlp start || true"
}
function archenabledisplaymanager(){
runinchroot "systemctl enable gdm"
}
function archgraphics(){
(
echo 'Section "Device"'
echo ' Identifier "AMD"'
echo ' Driver "amdgpu"'
echo ' Option "TearFree" "true"'
echo ' Option "DRI" "3"'
echo 'EndSection'
) > /mnt/etc/X11/xorg.conf.d/20-amdgpu.conf
}
function aurinstall(){
sed -i '/%wheel ALL=(ALL) ALL/s/%/# %/g' /mnt/etc/sudoers
sed -i '/%wheel ALL=(ALL) NOPASSWD: ALL/s/# //g' /mnt/etc/sudoers
runasuser "export LANG=$language && $aurwrapper -Syy --noconfirm $@ ||true"
sed -i '/%wheel ALL=(ALL) ALL/s/# //g' /mnt/etc/sudoers
sed -i '/%wheel ALL=(ALL) NOPASSWD: ALL/s/%/# %/g' /mnt/etc/sudoers
}
function archinstallaurhelpers(){
if [[ -d /mnt/home/aim/.cache/aurinstaller ]]
then
rm -r /mnt/home/aim/.cache/aurinstaller
fi
runasuser "mkdir /home/aim/.cache || true"
runasuser "mkdir /home/aim/.cache/aurinstaller"
runasuser "git clone https://aur.archlinux.org/$aurwrapper.git /home/aim/.cache/aurinstaller/$aurwrapper"
sed -i '/%wheel ALL=(ALL) ALL/s/%/# %/g' /mnt/etc/sudoers
sed -i '/%wheel ALL=(ALL) NOPASSWD: ALL/s/# //g' /mnt/etc/sudoers
runasuser "export LANG=$language && cd /home/aim/.cache/aurinstaller/$aurwrapper && makepkg --syncdeps -si --noconfirm || true"
sed -i '/%wheel ALL=(ALL) ALL/s/# //g' /mnt/etc/sudoers
sed -i '/%wheel ALL=(ALL) NOPASSWD: ALL/s/%/# %/g' /mnt/etc/sudoers
rm -rf /mnt/home/aim/.cache/aurinstaller || true
}
function archinstallbootloader(){
runinchroot "bootctl --path=/boot install"
(
echo 'default arch'
echo 'timeout 0'
echo 'console-mode max'
echo 'editor 0'
) > /mnt/boot/loader/loader.conf
(
echo 'title Arch Linux'
echo 'linux /vmlinuz-linux'
echo 'initrd /amd-ucode.img'
echo 'initrd /initramfs-linux.img'
echo 'options root=LABEL=Computer rw rootflags=subvol=@ processor.max_cstate=1'
) > /mnt/boot/loader/entries/arch.conf
}
function archsecureboot(){
aurinstall preloader-signed
yes | cp -f /mnt/usr/share/preloader-signed/HashTool.efi /mnt/boot/EFI/Boot
yes | cp -f /mnt/boot/EFI/systemd/systemd-bootx64.efi /mnt/boot/EFI/Boot/loader.efi
yes | cp -f /mnt/usr/share/preloader-signed/PreLoader.efi /mnt/boot/EFI/Boot/bootx64.efi
}
function finishinstall(){
umount -a || true
telinit 6
}
main "$@"