-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
697 lines (624 loc) · 23.3 KB
/
install.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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#!/bin/bash
# Redirect stdout and stderr to archsetup.txt and still output to console
exec > >(tee -i archsetup.txt)
exec 2>&1
echo -ne "
-------------------------------------------------------------------------
Automated Arch Linux Installer
-------------------------------------------------------------------------
Verifying Arch Linux ISO is Booted
"
if [ ! -f /usr/bin/pacstrap ]; then
echo "This script must be run from an Arch Linux ISO environment."
exit 1
fi
root_check() {
if [[ "$(id -u)" != "0" ]]; then
echo -ne "ERROR! This script must be run under the 'root' user!\n"
exit 0
fi
}
docker_check() {
if awk -F/ '$2 == "docker"' /proc/self/cgroup | read -r; then
echo -ne "ERROR! Docker container is not supported (at the moment)\n"
exit 0
elif [[ -f /.dockerenv ]]; then
echo -ne "ERROR! Docker container is not supported (at the moment)\n"
exit 0
fi
}
arch_check() {
if [[ ! -e /etc/arch-release ]]; then
echo -ne "ERROR! This script must be run in Arch Linux!\n"
exit 0
fi
}
pacman_check() {
if [[ -f /var/lib/pacman/db.lck ]]; then
echo "ERROR! Pacman is blocked."
echo -ne "If not running remove /var/lib/pacman/db.lck.\n"
exit 0
fi
}
background_checks() {
root_check
arch_check
pacman_check
docker_check
}
select_option() {
local options=("$@")
local num_options=${#options[@]}
local selected=0
local last_selected=-1
while true; do
# Move cursor up to the start of the menu
if [ $last_selected -ne -1 ]; then
echo -ne "\033[${num_options}A"
fi
if [ $last_selected -eq -1 ]; then
echo "Please select an option using the arrow keys and Enter:"
fi
for i in "${!options[@]}"; do
if [ $i -eq $selected ]; then
echo "> ${options[$i]}"
else
echo " ${options[$i]}"
fi
done
last_selected=$selected
# Read user input
read -rsn1 key
case $key in
$'\x1b') # ESC sequence
read -rsn2 -t 0.1 key
case $key in
'[A') # Up arrow
((selected--))
if [ $selected -lt 0 ]; then
selected=$((num_options - 1))
fi
;;
'[B') # Down arrow
((selected++))
if [ $selected -ge $num_options ]; then
selected=0
fi
;;
esac
;;
'') # Enter key
break
;;
esac
done
return $selected
}
# @description Displays ArchTitus logo
# @noargs
logo () {
# This will be shown on every set as user is progressing
echo -ne "
------------------------------------------------------------------------
Please select presetup settings for your system
------------------------------------------------------------------------
"
}
# @description This function will handle file systems. At this movement we are handling only
# btrfs and ext4. Others will be added in future.
filesystem () {
echo -ne "
Please Select your file system for both boot and root
"
options=("btrfs" "ext4" "luks" "exit")
select_option "${options[@]}"
case $? in
0) export FS=btrfs;;
1) export FS=ext4;;
2)
set_password "LUKS_PASSWORD"
export FS=luks
;;
3) exit ;;
*) echo "Wrong option please select again"; filesystem;;
esac
}
# @description Detects and sets timezone.
timezone () {
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
time_zone="$(curl --fail https://ipapi.co/timezone)"
echo -ne "
System detected your timezone to be '$time_zone' \n"
echo -ne "Is this correct?
"
options=("Yes" "No")
select_option "${options[@]}"
case ${options[$?]} in
y|Y|yes|Yes|YES)
echo "${time_zone} set as timezone"
export TIMEZONE=$time_zone;;
n|N|no|NO|No)
echo "Please enter your desired timezone e.g. Europe/London :"
read new_timezone
echo "${new_timezone} set as timezone"
export TIMEZONE=$new_timezone;;
*) echo "Wrong option. Try again";timezone;;
esac
}
# @description Set user's keyboard mapping.
keymap () {
echo -ne "
Please select key board layout from this list"
# These are default key maps as presented in official arch repo archinstall
options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk)
select_option "${options[@]}"
keymap=${options[$?]}
# Check if the selected keymap is "se" and set it to "se-lat6" for correct layout.
if [[ "$keymap" == "se" ]]; then
keymap="sv-latin1"
fi
echo -ne "Your key boards layout: ${keymap} \n"
export KEYMAP=$keymap
}
# @description Choose whether drive is SSD or not.
drivessd () {
echo -ne "
Is this an ssd? yes/no:
"
options=("Yes" "No")
select_option "${options[@]}"
case ${options[$?]} in
y|Y|yes|Yes|YES)
export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120";;
n|N|no|NO|No)
export MOUNT_OPTIONS="noatime,compress=zstd,commit=120";;
*) echo "Wrong option. Try again";drivessd;;
esac
}
# @description Disk selection for drive to be used with installation.
diskpart () {
echo -ne "
------------------------------------------------------------------------
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
Please make sure you know what you are doing because
after formating your disk there is no way to get data back
*****BACKUP YOUR DATA BEFORE CONTINUING*****
***I AM NOT RESPONSIBLE FOR ANY DATA LOSS***
------------------------------------------------------------------------
"
PS3='
Select the disk to install on: '
options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}'))
select_option "${options[@]}"
disk=${options[$?]%|*}
echo -e "\n${disk%|*} selected \n"
export DISK=${disk%|*}
drivessd
}
# @description Gather username and password to be used for installation.
userinfo () {
# Loop through user input until the user gives a valid username
while true
do
read -p "Please enter username:" username
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then
break
fi
echo "Incorrect username."
done
export USERNAME=$username
while true
do
read -rs -p "Please enter password: " PASSWORD1
echo -ne "\n"
read -rs -p "Please re-enter password: " PASSWORD2
echo -ne "\n"
if [[ "$PASSWORD1" == "$PASSWORD2" ]]; then
break
else
echo -ne "ERROR! Passwords do not match. \n"
fi
done
export PASSWORD=$PASSWORD1
# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
read -p "Please name your machine:" name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
break
fi
# if validation fails allow the user to force saving of the hostname
read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]]
then
break
fi
done
export NAME_OF_MACHINE=$name_of_machine
}
# Starting functions
background_checks
clear
logo
userinfo
clear
logo
diskpart
clear
logo
filesystem
clear
logo
timezone
clear
logo
keymap
echo "Setting up mirrors for optimal download"
iso=$(curl -4 ifconfig.co/country-iso)
timedatectl set-ntp true
pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install
pacman -S --noconfirm --needed pacman-contrib terminus-font
setfont ter-v18b
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
pacman -S --noconfirm --needed reflector rsync grub
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
echo -ne "
-------------------------------------------------------------------------
Setting up $iso mirrors for faster downloads
-------------------------------------------------------------------------
"
reflector -a 48 -c $iso -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist
if [ ! -d "/mnt" ]; then
mkdir /mnt
fi
echo -ne "
-------------------------------------------------------------------------
Installing Prerequisites
-------------------------------------------------------------------------
"
pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc
echo -ne "
-------------------------------------------------------------------------
Formating Disk
-------------------------------------------------------------------------
"
umount -A --recursive /mnt # make sure everything is unmounted before we start
# disk prep
sgdisk -Z ${DISK} # zap all on disk
sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment
# create partitions
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition)
sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition)
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining
if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system
sgdisk -A 1:set:2 ${DISK}
fi
partprobe ${DISK} # reread partition table to ensure it is correct
# make filesystems
echo -ne "
-------------------------------------------------------------------------
Creating Filesystems
-------------------------------------------------------------------------
"
# @description Creates the btrfs subvolumes.
createsubvolumes () {
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@var
btrfs subvolume create /mnt/@tmp
btrfs subvolume create /mnt/@.snapshots
}
# @description Mount all btrfs subvolumes after root has been mounted.
mountallsubvol () {
mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home
mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp
mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var
mount -o ${MOUNT_OPTIONS},[email protected] ${partition3} /mnt/.snapshots
}
# @description BTRFS subvolulme creation and mounting.
subvolumesetup () {
# create nonroot subvolumes
createsubvolumes
# unmount root to remount with subvolume
umount /mnt
# mount @ subvolume
mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt
# make directories home, .snapshots, var, tmp
mkdir -p /mnt/{home,var,tmp,.snapshots}
# mount subvolumes
mountallsubvol
}
if [[ "${DISK}" =~ "nvme" ]]; then
partition2=${DISK}p2
partition3=${DISK}p3
else
partition2=${DISK}2
partition3=${DISK}3
fi
if [[ "${FS}" == "btrfs" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
mkfs.btrfs -L ROOT ${partition3} -f
mount -t btrfs ${partition3} /mnt
subvolumesetup
elif [[ "${FS}" == "ext4" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
mkfs.ext4 -L ROOT ${partition3}
mount -t ext4 ${partition3} /mnt
elif [[ "${FS}" == "luks" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
# enter luks password to cryptsetup and format root partition
echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat ${partition3} -
# open luks container and ROOT will be place holder
echo -n "${LUKS_PASSWORD}" | cryptsetup open ${partition3} ROOT -
# now format that container
mkfs.btrfs -L ROOT ${partition3}
# create subvolumes for btrfs
mount -t btrfs ${partition3} /mnt
subvolumesetup
fi
sync
if ! mountpoint -q /mnt; then
echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts."
exit 1
fi
mkdir -p /mnt/boot/efi
mount -t vfat -L EFIBOOT /mnt/boot/
if ! grep -qs '/mnt' /proc/mounts; then
echo "Drive is not mounted can not continue"
echo "Rebooting in 3 Seconds ..." && sleep 1
echo "Rebooting in 2 Seconds ..." && sleep 1
echo "Rebooting in 1 Second ..." && sleep 1
reboot now
fi
echo -ne "
-------------------------------------------------------------------------
Arch Install on Main Drive
-------------------------------------------------------------------------
"
if [[ ! -d "/sys/firmware/efi" ]]; then
pacstrap /mnt base base-devel linux-lts linux-firmware --noconfirm --needed
else
pacstrap /mnt base base-devel linux-lts linux-firmware efibootmgr --noconfirm --needed
fi
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
genfstab -L /mnt >> /mnt/etc/fstab
echo "
Generated /etc/fstab:
"
cat /mnt/etc/fstab
echo -ne "
-------------------------------------------------------------------------
GRUB BIOS Bootloader Install & Check
-------------------------------------------------------------------------
"
if [[ ! -d "/sys/firmware/efi" ]]; then
grub-install --boot-directory=/mnt/boot ${DISK}
fi
echo -ne "
-------------------------------------------------------------------------
Checking for low memory systems <8G
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
if [[ $TOTAL_MEM -lt 8000000 ]]; then
# Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything.
mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly.
if findmnt -n -o FSTYPE /mnt | grep -q btrfs; then
chattr +C /mnt/opt/swap # apply NOCOW, btrfs needs that.
fi
dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress
chmod 600 /mnt/opt/swap/swapfile # set permissions.
chown root /mnt/opt/swap/swapfile
mkswap /mnt/opt/swap/swapfile
swapon /mnt/opt/swap/swapfile
# The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself.
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
fi
gpu_type=$(lspci | grep -E "VGA|3D|Display")
arch-chroot /mnt /bin/bash <<EOF
echo -ne "
-------------------------------------------------------------------------
Network Setup
-------------------------------------------------------------------------
"
pacman -S --noconfirm --needed networkmanager dhclient
systemctl enable --now NetworkManager
echo -ne "
-------------------------------------------------------------------------
Setting up mirrors for optimal download
-------------------------------------------------------------------------
"
pacman -S --noconfirm --needed pacman-contrib curl
pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git ntp wget
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
nc=$(grep -c ^processor /proc/cpuinfo)
echo -ne "
-------------------------------------------------------------------------
You have " $nc" cores. And
changing the makeflags for " $nc" cores. Aswell as
changing the compression settings.
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
if [[ $TOTAL_MEM -gt 8000000 ]]; then
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf
fi
echo -ne "
-------------------------------------------------------------------------
Setup Language to US and set locale
-------------------------------------------------------------------------
"
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
timedatectl --no-ask-password set-timezone ${TIMEZONE}
timedatectl --no-ask-password set-ntp 1
localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8"
ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
# Set keymaps
localectl --no-ask-password set-keymap ${KEYMAP}
# Add sudo no password rights
sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers
#Add parallel downloading
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
#Enable multilib
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
pacman -Sy --noconfirm --needed
echo -ne "
-------------------------------------------------------------------------
Installing Microcode
-------------------------------------------------------------------------
"
# determine processor type and install microcode
if grep -q "GenuineIntel" /proc/cpuinfo; then
echo "Installing Intel microcode"
pacman -S --noconfirm --needed intel-ucode
elif grep -q "AuthenticAMD" /proc/cpuinfo; then
echo "Installing AMD microcode"
pacman -S --noconfirm --needed amd-ucode
else
echo "Unable to determine CPU vendor. Skipping microcode installation."
fi
echo -ne "
-------------------------------------------------------------------------
Installing Graphics Drivers
-------------------------------------------------------------------------
"
# Graphics Drivers find and install
if echo "${gpu_type}" | grep -E "NVIDIA|GeForce"; then
echo "Installing NVIDIA drivers: nvidia-lts"
pacman -S --noconfirm --needed nvidia-lts
elif echo "${gpu_type}" | grep 'VGA' | grep -E "Radeon|AMD"; then
echo "Installing AMD drivers: xf86-video-amdgpu"
pacman -S --noconfirm --needed xf86-video-amdgpu
elif echo "${gpu_type}" | grep -E "Integrated Graphics Controller"; then
echo "Installing Intel drivers:"
pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa
elif echo "${gpu_type}" | grep -E "Intel Corporation UHD"; then
echo "Installing Intel UHD drivers:"
pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa
fi
echo -ne "
-------------------------------------------------------------------------
Adding User
-------------------------------------------------------------------------
"
groupadd libvirt
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
echo "$USERNAME:$PASSWORD" | chpasswd
echo "$USERNAME password set"
echo $NAME_OF_MACHINE > /etc/hostname
if [[ ${FS} == "luks" ]]; then
# Making sure to edit mkinitcpio conf if luks is selected
# add encrypt in mkinitcpio.conf before filesystems in hooks
sed -i 's/filesystems/encrypt filesystems/g' /etc/mkinitcpio.conf
# making mkinitcpio with linux kernel
mkinitcpio -p linux-lts
fi
echo -ne "
-------------------------------------------------------------------------
Automated Arch Linux Installer
-------------------------------------------------------------------------
Final Setup and Configurations
GRUB EFI Bootloader Install & Check
"
if [[ -d "/sys/firmware/efi" ]]; then
grub-install --efi-directory=/boot ${DISK}
fi
echo -ne "
-------------------------------------------------------------------------
Creating Grub Boot Menu
-------------------------------------------------------------------------
"
# set kernel parameter for decrypting the drive
if [[ "${FS}" == "luks" ]]; then
sed -i "s%GRUB_CMDLINE_LINUX_DEFAULT=\"%GRUB_CMDLINE_LINUX_DEFAULT=\"cryptdevice=UUID=${ENCRYPTED_PARTITION_UUID}:ROOT root=/dev/mapper/ROOT %g" /etc/default/grub
fi
# set kernel parameter for adding splash screen
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub
# Set GRUB timeout to 0 seconds
sed -i 's/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=0/' /etc/default/grub
echo "GRUB timeout set to 0 seconds"
echo -e "Backing up Grub config..."
cp -an /etc/default/grub /etc/default/grub.bak
echo -e "Updating grub..."
grub-mkconfig -o /boot/grub/grub.cfg
echo -ne "
-------------------------------------------------------------------------
Enabling Essential Services
-------------------------------------------------------------------------
"
ntpd -qg
systemctl enable ntpd.service
echo " NTP enabled"
systemctl disable dhcpcd.service
echo " DHCP disabled"
systemctl stop dhcpcd.service
echo " DHCP stopped"
systemctl enable NetworkManager.service
echo " NetworkManager enabled"
# @description Edit vconsole.conf and locale.conf for persistence
# Sometimes the locale and vconsole.conf files are not updated, so we need to force update them manually.
echo -ne "
-------------------------------------------------------------------------
Updating vconsole.conf and locale.conf
-------------------------------------------------------------------------
"
# Ensure /mnt is mounted and necessary directories exist
if ! mountpoint -q /mnt; then
echo "Mounting the root filesystem..."
# Mount the correct filesystem based on user selection
if [[ "${FS}" == "btrfs" ]]; then
mount -o subvol=@ ${partition3} /mnt # Specify the subvolume for Btrfs
elif [[ "${FS}" == "ext4" ]]; then
mount -t ext4 ${partition3} /mnt
elif [[ "${FS}" == "luks" ]]; then
mount -t btrfs /dev/mapper/ROOT /mnt # Adjust if using a different filesystem for LUKS
fi
# Create necessary directories
mount -t proc /mnt/proc
mount -t sysfs /mnt/sys
mount --bind /dev /mnt/dev
fi
# Install terminus font
pacman -S --noconfirm --needed terminus-font
# Set terminus font
echo "FONT=ter-v18b" >> /mnt/etc/vconsole.conf
# Update /etc/vconsole.conf
echo "KEYMAP=${KEYMAP}" > /mnt/etc/vconsole.conf
echo "FONT=ter-v18b" >> /mnt/etc/vconsole.conf
# Update /etc/locale.conf
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
# Ensure the locale is generated
echo "Generating locales..."
arch-chroot /mnt locale-gen
# Unmount the filesystems
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount /mnt
echo -ne "
-------------------------------------------------------------------------
Cleaning
-------------------------------------------------------------------------
"
# Remove no password sudo rights
sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers
# Add sudo rights
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
echo -ne "
-------------------------------------------------------------------------
Automated Arch Linux Installer
-------------------------------------------------------------------------
Finished!
-------------------------------------------------------------------------
"
EOF