summaryrefslogtreecommitdiff
path: root/abi
blob: 46818e054e66bed5dcb4483f535aa9bd726560be (plain)
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
#!/bin/sh

OS=$(grep -i ^id= /etc/os-release | cut -d= -f2)

#############################

echo
echo "################################"
echo "# Checking Internet Connection #"
echo "################################"
echo
echo
sleep 2

if ! ping -q -c 4 archlinux.org >/dev/null;then
	echo "YOU MUST HAVE INTERNET CONNECTION TO RUN THIS SCRIPT" && exit
fi


case "$OS" in
	"artix")
		pacman-key --init
		pacman-key --populate artix
		;;

	"parabola")
		# Killing GPG agent that blocks pacman-key --init
		if pgrep gpg-agent
		then
			pkill gpg-agent
		fi

		# Reloading GPG Keys
		rm -rf /etc/pacman.d/gnupg
		pacman-key --init
		pacman-key --refresh-keys
		pacman-key --populate parabola archlinux archlinuxarm archlinux32

		# Automatically assuming yes to all questions relative to replacing old libs
		yes | pacman -S util-linux-libs glibc
esac
clear

#############################

echo
echo "######################"
echo "# Set Your Variables #"
echo "######################"
echo
echo
sleep 2

# Reading Variables
## Reading Keyboard Layout
printf "What is your Keyboard Layout (e.g. us)\n-> " && read -r KEYMAP && loadkeys "$KEYMAP" || exit
clear

## Reading Locale
printf "Select your locale (e.g. en_US)\n-> " && read -r LOCALE
clear

## Reading Desired Username
printf "Select your Username (Use only lowercase letters and numbers)\n-> " && read -r USERNAME
clear

## Reading Desired Hostname
printf "Select your Hostname (You can use Uppercase and lowercase letters, numbers and hypens)\n-> " && read -r HOSTNAME
clear

## Reading Desired Timezone
printf "Select the Timezone that better suits you...\nPress ENTER to continue and then press \"Q\" to exit" && read -r TIMEZONE
find /usr/share/zoneinfo -type d | grep -vi zoneinfo$ | grep -vi etc | xargs -I {} find {} -type f | sed s:"/usr/share/zoneinfo/"::g | less -i
printf "Which Timezone? (eg America/New_York)\n-> " && read -r TIMEZONE
clear

## Reading Kernel
case "$OS" in
	"parabola")
		printf "Select your kernel:\n1)linux-libre\n2)linux-libre-hardened\n3)linux-libre-lts [Recommended](Default)\n-> " && read -r KERNEL
		case "$KERNEL" in
			1)
				KERNEL="linux-libre"
				;;
			2)
				KERNEL="linux-libre-hardened"
				;;
			*)
				KERNEL="linux-libre-lts"
		esac
		;;

	*)
		printf "Select your kernel:\n1)linux\n2)linux-hardened\n3)linux-lts [Recommended](Default)\n4)linux-zen\n-> " && read -r KERNEL
		case "$KERNEL" in
			1)
				KERNEL="linux"
				;;
			2)
				KERNEL="linux-hardened"
				;;
			4)
				KERNEL="linux-zen"
				;;
			*)
				KERNEL="linux-lts"
		esac
esac
clear

## Reading Init System
case "$OS" in
	"artix")
		printf "Select your init system:\n1) dinit\n2) OpenRC (default)\n3) Runit\n4) S6\n-> " && read -r INIT
		case "$INIT" in
			1)
				INIT="dinit"
				;;
			3)
				INIT="runit"
				;;
			4)
				INIT="s6"
				;;
			*)
				INIT="openrc"
		esac
		;;

	"parabola")
		printf "Select your init system:\n1) OpenRC\n2) SystemD (default)\n-> " && read -r INIT
		if [ "$INIT" -eq 2 ]; then
			INIT="openrc"
		else
			INIT="systemd"
		fi
		;;

	*)
		INIT="systemd"
esac

#############################

echo
echo "#####################"
echo "# Disk Partitioning #"
echo "#####################"
echo
echo
sleep 2

#Partitioning HDD
## Reading Main Drive
lsblk
printf "What is your drive (e.g. sda)\n-> " && read -r SDX
clear

## Partitionier
cfdisk /dev/"$SDX"
clear

## Making SWAP Partition
lsblk
printf "Do you wish to use a swap parition? [Y/n]" && read -r SWAPUSE
clear

if [ "$SWAPUSE" != "N" ] && [ "$SWAPUSE" != "n" ]; then
	lsblk
	echo ""
	echo ""
	printf "What is your swap parition (e.g. sda1)\n-> " && read -r SWAP
	swapoff /dev/"$SWAP" >/dev/null
	clear

	printf "Wipe Swap Partition? [Y/n]" && read -r WIPESWAP
	if [ "$WIPESWAP" != "N" ] && [ "$WIPESWAP" != "n" ]; then
		mkswap /dev/"$SWAP" >/dev/null
	fi
	swapon /dev/"$SWAP" >/dev/null
	clear
fi
clear

## Disk Encryption
printf "Do you wish to use any encrypted parition? [Y/n]" && read -r ENCRYPTED
if [ "$ENCRYPTED" != "N" ] && [ "$ENCRYPTED" != "n" ]; then
	pacman --noconfirm --needed -Sy cryptsetup
	clear
	lsblk
	echo ""
	echo ""

	printf "Type the parition you wish to use encrypted (e.g. sda2)\n-> " && read -r ENCRYPTEDPARTITION
	clear

	printf "Do you wish to wipe this encrypted parition? [Y/n]" && read -r WIPENCRYPT
	clear

	if [ "$WIPENCRYPT" != "N" ] && [ "$WIPENCRYPT" != "n" ]; then
		cryptsetup luksFormat /dev/"$ENCRYPTEDPARTITION"
		clear
	fi

	cryptsetup open /dev/"$ENCRYPTEDPARTITION" cryptdevice
	clear
fi
clear

## Mounting Partitions
echo "Mount your partitions to /mnt and wipe them if necessary"
echo "After partitioning, type \"exit\" to go back to the script"
echo ""
echo ""
lsblk
echo ""
bash
clear

#############################

echo
echo "#######################"
echo "# Bootstraping System #"
echo "#######################"
echo
echo
sleep 2

# Sorting Servers
echo "Downloading rankmirror script for pacman"
pacman -Sy --noconfirm --needed pacman-contrib
clear

echo "Updating Repos..."
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
grep -vi ^# /etc/pacman.d/mirrorlist.backup | rankmirrors - > /etc/pacman.d/mirrorlist
clear

# Bootstrapping Filesystem
echo "Bootstrapping Filesystem"

if [ "$OS" = "artix" ]; then
	case "$INIT" in
		"dinit")
			basestrap /mnt base dinit elogind-dinit "$KERNEL"
			;;
		"runit")
			basestrap /mnt base runit elogind-runit "$KERNEL"
			;;
		"s6")
			basestrap /mnt base s6 elogind-s6 "$KERNEL"
			;;
		*)
			basestrap /mnt base openrc elogind-openrc "$KERNEL"
	esac
	fstabgen -U /mnt >> /mnt/etc/fstab
else
	if [ "$OS" = "parabola" ] && [ "$INIT" != "openrc" ]; then
		pacstrap /mnt base libelogind udev-init-scripts elogind "$KERNEL"
	else
		pacstrap /mnt base "$KERNEL"
	fi
	genfstab -U /mnt >> /mnt/etc/fstab
fi
clear

#############################

echo
echo "######################"
echo "# Configuring System #"
echo "######################"
echo
echo
sleep 2

if [ "$OS" = "artix" ]; then
	CHROOT="artix-chroot /mnt /bin/bash -c"
else
	CHROOT="arch-chroot /mnt /bin/bash -c"
fi

## Managing Localtime and Timezone
rm -rf /mnt/etc/localtime
$CHROOT "ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime"

## Managing Users and Passwords
$CHROOT "useradd -m -g users -G wheel $USERNAME"
echo "Enter a password for $USERNAME"
$CHROOT -c "passwd $USERNAME"
clear

echo "Enter a new password for root account"
$CHROOT -c "passwd root"
clear

if [ "$INIT" = "openrc" ]; then
	$CHROOT "echo hostname=$HOSTNAME > /etc/conf.d/hostname"
	sed -i s:'keymap="us"':keymap="$KEYMAP":g /mnt/etc/conf.d/keymaps

	if [ "$OS" = "parabola" ]; then
		sed -i 's:^#.nonsystemd\]:\[nonsystemd\]\nInclude \= \/etc\/pacman.d\/mirrorlist:g' /mnt/etc/pacman.conf
	fi
else
	 $CHROOT "echo $HOSTNAME > /etc/hostname"
	 $CHROOT "echo KEYMAP=$KEYMAP > /etc/vconsole.conf"
fi

if [ "$OS" = "parabola" ]; then
	sed -i 's:^#.nonprism\]:\[nonprism\]\nInclude \= \/etc\/pacman.d\/mirrorlist:g' /mnt/etc/pacman.conf
fi

$CHROOT "echo LANG=$LOCALE.UTF-8 > /etc/locale.conf"
$CHROOT "awk 'FNR>23' /etc/locale.gen | grep $LOCALE | sed s:#::g >> /etc/locale.gen"
$CHROOT "locale-gen"
clear

## Adding Encrypted Hook to Init Cpio
if [ "$ENCRYPTED" != "N" ] && [ "$ENCRYPTED" != "n" ]; then
	 $CHROOT "pacman --noconfirm --needed -Sy cryptsetup"
	 HOOKS=$(grep ^HOOKS /mnt/etc/mkinitcpio.conf)
	 grep ^HOOKS /mnt/etc/mkinitcpio.conf | sed s:'block':'block encrypt':g | xargs -I {} sed -i s:"$HOOKS":{}:g /mnt/etc/mkinitcpio.conf
fi

## Generating Initramfs
$CHROOT "mkinitcpio -p $KERNEL"
clear

#############################

echo
echo "#################"
echo "# Base Packages #"
echo "#################"
echo
echo
sleep 2

# Installation of Base Packages
echo "Installing Base Packages..."
$CHROOT "pacman --needed --noconfirm -Syu base base-devel"
clear

# Enabling Sudo For :wheel Group
$CHROOT "sed -i s/'# %wheel ALL=(ALL:ALL) ALL'/'%wheel ALL=(ALL:ALL) ALL'/g /etc/sudoers"

# Installation of Extra Base
printf "Do you want to install Extra Base Packages? [Y/n]" && read -r EXTRA
if [ "$EXTRA" != "N" ] && [ "$EXTRA" != "n" ]; then

	# Text Editor Setup
	printf "Select a Text Editor:\n1) emacs\n2) nano\n3) neovim\n4) vi\n5) vim\n-> " && read -r TEXT
	case "$TEXT" in
		1)
			$CHROOT "pacman --noconfirm --needed -S emacs"
			;;
		2)
			$CHROOT "pacman --noconfirm --needed -S nano"
			;;
		3)
			$CHROOT "pacman --noconfirm --needed -S neovim"
			;;
		4)
			$CHROOT "pacman --noconfirm --needed -S vi"
			;;
		5)
			$CHROOT "pacman --noconfirm --needed -S vim"
	esac
	clear

	# WiFi and Ethernet Setup
	printf "Do you wish to use WiFi? [Y/n]" && read -r WIFI
	clear
	if [ "$WIFI" != "N" ] && [ "$WIFI" != "n" ]; then
		printf "Select a Network Manager:\n1) connman\n2) network manager\n-> " && read -r NM
		case "$NM" in
			1)
				$CHROOT "pacman --noconfirm --needed -S connman wpa_supplicant"
				case "$INIT" in
					"dinit")
						$CHROOT "pacman --noconfirm --needed -S connman-dinit && ln -s /etc/dinit.d/connmand /etc/dinit.d/boot.d/"
						;;

					"openrc")
						$CHROOT "pacman --noconfirm --needed -S connman-openrc && rc-update add connmand default"
						;;

					"runit")
						$CHROOT "pacman --noconfirm --needed -S connman-runit && ln -s /etc/runit/sv/connmand /etc/runit/runsvdir/default"
						;;

					"s6")
						$CHROOT "pacman --noconfirm --needed -S connman-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default connmand"
						;;

					*)
						$CHROOT "systemctl enable connmand"
				esac
				;;
			2)
				$CHROOT "pacman --noconfirm --needed -S networkmanager"
				case "$INIT" in
					"dinit")
						$CHROOT "pacman --noconfirm --needed -S networkmanager-dinit && ln -s /etc/dinit.d/NetworkManager /etc/dinit.d/boot.d/"
						;;

					"openrc")

						if [ "$OS" != "parabola" ]; then
							$CHROOT "pacman --noconfirm --needed -S networkmanager-openrc && rc-update add NetworkManager default"
						fi

						$CHROOT "rc-update add NetworkManager default"
						;;

					"runit")

						$CHROOT "pacman --noconfirm --needed -S networkmanager-runit && ln -s /etc/runit/sv/NetworkManager /etc/runit/runsvdir/default"
						;;

					"s6")
						$CHROOT "pacman --noconfirm --needed -S networkmanager-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default NetworkManager"
						;;

					*)
						$CHROOT "systemctl enable NetworkManager"
				esac
		esac
	else
		$CHROOT "pacman --noconfirm --needed -S dhcpcd"
		case "$INIT" in
			"dinit")
				$CHROOT "pacman --noconfirm --needed -S dhcpcd-dinit && ln -s /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/"
				;;

			"openrc")
				$CHROOT "pacman --noconfirm --needed -S dhcpcd-openrc && rc-update add dhcpcd default"
				;;

			"runit")
				$CHROOT "pacman --noconfirm --needed -S dhcpcd-runit && ln -s /etc/runit/sv/dhcpcd /etc/runit/runsvdir/default"
				;;

			"s6")
				$CHROOT "pacman --noconfirm --needed -S dhcpcd-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default dhcpcd"
				;;
			*)
				$CHROOT "systemctl enable dhcpcd"
		esac
	fi
	clear

	# Installation of Base Fonts
	printf "Do you want to install Base Fonts Packages? [Y/n]" && read -r FONTS
	if [ "$FONTS" != "N" ] && [ "$FONTS" != "n" ]; then
		$CHROOT "pacman --needed --noconfirm -S ttf-bitstream-vera ttf-dejavu gnu-free-fonts adobe-source-code-pro-fonts noto-fonts-cjk noto-fonts-emoji"
	fi
	clear

	# Installation of Proprietary Blobs
	printf "Do you want to install support for Proprietary Firmware? [Y/n]" && read -r BLOBS
	if [ "$BLOBS" != "N" ] && [ "$BLOBS" != "n" ]; then
		if [ "$OS" = parabola ]; then
			$CHROOT "pacman --needed --noconfirm -S linux-libre-firmware"
		else
			$CHROOT "pacman --needed --noconfirm -S linux-firmware"
		fi
	fi
	clear

	# Installation of Audio System
	printf "Select an Audio Package:\n1) alsa\n2) jack\n3) pipewire\n4) pulseaudio\n-> " && read -r AUDIO
	case "$AUDIO" in
		1)
			$CHROOT "pacman --noconfirm --needed -S alsa-lib alsa-oss alsa-utils alsa-plugins"
			;;
		2)
			$CHROOT "pacman --noconfirm --needed -S jack"
			;;
		3)
			$CHROOT "pacman --noconfirm --needed -S pipewire"
			;;
		4)
			$CHROOT "pacman --noconfirm --needed -S pulseaudio pavucontrol pulseaudio-alsa alsa-utils"
	esac
	clear

	# Installation of a Graphical Environment
	printf "Select a Graphical Environment:\n1) bspwm\n2) Cinnamon\n3) dwm (Requires Online Git Build)\n4) Gnome\n5) i3 [Gaps Edition]\n6) Kde\n7) LXDE\n8) LXQt\n9) Mate\n10) Openbox\n11) XFCE\n12) Xorg\n13) None\n-> " && read -r ENVIRONMENT

	case "$ENVIRONMENT" in
		1)
			$CHROOT "pacman --needed --noconfirm -S bspwm sxhkd"
			;;
		2)
			$CHROOT "pacman --needed --noconfirm -S cinnamon nemo-fileroller gnome-terminal"
			;;
		3)
			printf "Enter your dwm build location (e.g. https://git.suckless.org/dwm)\n-> " && read -r DWM
			$CHROOT "git clone $DWM /tmp/dwm && cd /tmp/dwm && make clean install && cd /"
			;;
		4)
			$CHROOT "pacman --needed --noconfirm -S gnome nautilus gnome-terminal"
			;;
		5)
			$CHROOT "pacman --needed -S i3 dmenu i3blocks"
			;;
		6)
			$CHROOT "pacman --needed --noconfirm -S plasma kde-applications"
			;;
		7)
			$CHROOT "pacman --needed --noconfirm -S lxde"
			;;
		8)
			$CHROOT "pacman --needed --noconfirm -S lxqt"
			;;
		9)
			$CHROOT "pacman --needed --noconfirm -S mate mate-extra"
			;;
		10)
			$CHROOT "pacman --needed --noconfirm -S openbox obconf-qt menumaker"
			;;
		11)
			$CHROOT "pacman --needed --noconfirm -S xfce4 xfce4-goodies"
			;;
		12)
			$CHROOT "pacman --needed --noconfirm -S xorg xorg-apps xorg-server xorg-xinit"
	esac
	clear

	# Installation of Xorg and Drivers
	$CHROOT "pacman --needed --noconfirm -S xorg"
	clear

	echo "Pick your Xorg Driver:"
	$CHROOT "pacman --needed -S xorg-drivers"
	clear

	# Installation of a Display Manager
	printf "Select your desired Display Manager\n1) Gdm\n2) Lightdm\n3) Sddm\n4) None\n-> " && read -r DISPLAY && clear
	case "$DISPLAY" in
		1)
			$CHROOT "pacman --needed --noconfirm -S gdm"
			clear
			case "$INIT" in
				"dinit")
					$CHROOT "pacman --needed --noconfirm -S gdm-dinit && ln -s /etc/dinit.d/gdm /etc/dinit.d/boot.d/"
					;;
				"openrc")
					$CHROOT "pacman --needed --noconfirm -S gdm-openrc && rc-update add gdm default"
					;;
				"runit")
					$CHROOT "pacman --needed --noconfirm -S gdm-runit && ln -s /etc/runit/sv/gdm /etc/runit/runsvdir/default"
					;;
				"s6")
					$CHROOT "pacman --needed --noconfirm -S gdm-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default gdm"
					;;
				*)
					$CHROOT "systemctl enable gdm"
			esac
			;;
		2)
			$CHROOT "pacman --needed --noconfirm -S lightdm lightdm-gtk-greeter"
			clear
			case "$INIT" in
				"dinit")
					$CHROOT "pacman --needed --noconfirm -S lightdm-dinit && ln -s /etc/dinit.d/lightdm /etc/dinit.d/boot.d/"
					;;
				"openrc")
					$CHROOT "pacman --needed --noconfirm -S lightdm-openrc && rc-update add lightdm default"
					;;
				"runit")
					$CHROOT "pacman --needed --noconfirm -S lightdm-runit && ln -s /etc/runit/sv/lightdm /etc/runit/runsvdir/default"
					;;
				"s6")
					$CHROOT "pacman --needed --noconfirm -S lightdm-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default lightdm"
					;;
				*)
					$CHROOT "systemctl enable lightdm"
			esac
			;;
		3)
			$CHROOT "pacman --needed --noconfirm -S sddm"
			clear
			case "$INIT" in
				"dinit")
					$CHROOT "pacman --needed --noconfirm -S sddm-dinit && ln -s /etc/dinit.d/sddm /etc/dinit.d/boot.d/"
					;;
				"openrc")
					$CHROOT "pacman --needed --noconfirm -S sddm-openrc && rc-update add sddm default"
					;;
				"runit")
					$CHROOT "pacman --needed --noconfirm -S sddm-runit && ln -s /etc/runit/sv/sddm /etc/runit/runsvdir/default"
					;;
				"s6")
					$CHROOT "pacman --needed --noconfirm -S sddm-s6 && s6-rc-bundle-update -c /etc/s6/rc/compiled add default sddm"
					;;
				*)
					$CHROOT "systemctl enable sddm"
			esac
	esac
	clear

	printf "Do you want to install GRUB? [Y/n]" && read -r GRUB
	if [ "$GRUB" != "N" ] && [ "$GRUB" != "n" ]; then

		# Installing GRUB
		$CHROOT "pacman --needed --noconfirm -Syu grub"
		clear

		# Installation of GRUB Bootloader
		printf "Choose the type of boot you want to use for grub\n1) BIOS\n2) EFI\n3) Auto\n-> " && read -r GRUB
		clear

		## Adding Encrypted Config to GRUB
		if [ "$ENCRYPTED" != "N" ] && [ "$ENCRYPTED" != "n" ]; then
			$CHROOT "pacman --needed --noconfirm -Syu cryptsetup"
			sed -i s:'GRUB_CMDLINE_LINUX=""':"GRUB_CMDLINE_LINUX=\"cryptdevice=/dev/$ENCRYPTEDPARTITION\:cryptdevice\"":g /mnt/etc/default/grub
		fi

		case "$GRUB" in
			1)
				$CHROOT "grub-install --target=i386-pc /dev/$SDX"
				$CHROOT "grub-mkconfig -o /boot/grub/grub.cfg"
				;;
			2)
				$CHROOT "pacman --noconfirm --needed -S efibootmgr"
				$CHROOT "grub-install --target=x86_46-efi /dev/$SDX"
				$CHROOT "grub-mkconfig -o /boot/grub/grub.cfg"
				;;
			*)
				$CHROOT "grub-install /dev/$SDX"
				$CHROOT "grub-mkconfig -o /boot/grub/grub.cfg"
		esac
		clear
	fi
fi
clear

#############################

echo
echo "##################"
echo "# Extra Packages #"
echo "##################"
echo
echo
sleep 2

# Printer and Scanners
printf "Do you want to install Printers & Scanners support? [Y/n]" && read -r CUPS
if [ "$CUPS" != "N" ] && [ "$CUPS" != "n" ]; then
	$CHROOT "pacman --needed --noconfirm -S cups cups-pdf hplip system-config-printer simple-scan"
	case "$INIT" in
		1)
			$CHROOT "pacman --needed --noconfirm -S cups-dinit avahi-dinit && ln -s /etc/dinit.d/cupsd /etc/dinit.d/boot.d/"
			;;
		2)
			$CHROOT "pacman --needed --noconfirm -S cups-openrc avahi-openrc && rc-update add cupsd default && rc-update add avahi default"
			;;
		3)
			$CHROOT "pacman --needed --noconfirm -S cups-runit avahi-runit && ln -s /etc/runit/sv/cupsd /etc/runit/runsvdir/default && ln -s /etc/runit/sv/runit /etc/runit/runsvdir/default"
			;;
		4)
			$CHROOT "pacman --needed --noconfirm -S cups-s6 avahi-s6 && s6-rc-bundle add default cupsd && s6-rc-bundle-update -c /etc/s6/rc/compiled add default avahi"
			;;
		*)
			$CHROOT "systemctl enable cupsd && systemctl enable avahi"
	esac
fi
clear

if [ "$OS" = "artix" ]; then
	printf "Do you want to install Arch Linux Repos? [Y/n]" && read -r ARCH
	if [ "$ARCH" != "N" ] && [ "$ARCH" != "n" ]; then
		echo
		echo "############################################"
		echo "# Installation of Arch Linux Support Repos #"
		echo "############################################"
		echo
		echo
		sleep 2

		# Adding Arch Linux Support
		printf "\n[universe]\nInclude = /etc/pacman.d/mirrorlist" >> /mnt/etc/pacman.conf
		$CHROOT "pacman --needed --noconfirm -Syu artix-archlinux-support"
		printf "\n#[testing]\n#Include = /etc/pacman.d/mirrorlist-arch\n\n[extra]\nInclude = /etc/pacman.d/mirrorlist-arch\n\n[community]\nInclude = /etc/pacman.d/mirrorlist-arch\n\n#[community-testing]\n#Include = /etc/pacman.d/mirrorlist-arch" >> /mnt/etc/pacman.conf
		$CHROOT "pacman-key --populate archlinux"
		mv /mnt/etc/pacman.d/mirrorlist-arch /mnt/etc/pacman.d/mirrorlist-arch.backup
		clear

		echo "Updating Arch Linux Repos..."
		grep -vi ^# /mnt/etc/pacman.d/mirrorlist-arch.backup | rankmirrors - > /mnt/etc/pacman.d/mirrorlist-arch
		clear
	fi
fi

if [ "$OS" != "parabola" ]; then
	if [ "$OS" = "arch" ]; then
		printf "Do you want to multilib repo? [Y/n]" && read -r MULTI
		if [ "$MULTI" != "N" ] && [ "$MULTI" != "n" ]; then
			printf "[multilib]\nSigLevel = PackageRequired\nInclude = /etc/pacman.d/mirrorlist" >> /mnt/etc/pacman.conf
			$CHROOT "pacman --needed --noconfirm -Syu"
		fi
	else
		if [ "$OS" = "artix" ]; then
			if [ "$ARCH" != "N" ] && [ "$ARCH" != "n" ]; then
				printf "Do you want to multilib repo? [Y/n]" && read -r MULTI
				if [ "$MULTI" != "N" ] && [ "$MULTI" != "n" ]; then
					printf "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist-arch" >> /mnt/etc/pacman.conf
					$CHROOT "pacman --needed --noconfirm -Syu"
				fi
			fi
		fi
	fi
	clear

	# Gaming Related Stuff
	if [ "$MULTI" != "N" ] && [ "$MULTI" != "n" ]; then
		printf "Do you want to install Gaming software and related dependencies? (steam, lutris, 32 bit libraries) [Y/n]" && read -r GAME
		if [ "$GAME" != "N" ] && [ "$GAME" != "n" ]; then
			$CHROOT "pacman --needed --noconfirm -S wine-staging wine-mono wine-gecko winetricks giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls mpg123 lib32-mpg123 openal lib32-openal v4l-utils lib32-v4l-utils libpulse lib32-libpulse libgpg-error lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo lib32-libjpeg-turbo sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama ncurses lib32-ncurses opencl-icd-loader lib32-opencl-icd-loader libxslt lib32-libxslt libva lib32-libva gtk3 lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader lutris steam"
			clear

			printf "Select a graphics card brand:\n1)AMD\n2)Intel\n3)NVIDIA\n-> " && read -r GPU
			case "$GPU" in
				1)
					$CHROOT "pacman --noconfirm --needed -S lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader"
					;;
				2)
					$CHROOT "pacman --noconfirm -S lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader"
					;;
				3)
					$CHROOT "pacman --noconfirm -S nvidia nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader"
			esac
		fi
	fi
	clear
fi

# Office Suite
printf "Do you want to install LibreOffice Suite? [Y/n]" && read -r OFFICE
if [ "$OFFICE" != "N" ] && [ "$OFFICE" != "n" ]; then
	$CHROOT "pacman --needed -S libreoffice"
fi
clear

# Internet Related Stuff
printf "Do you want to install Internet related stuff? (firefox and transmission) [Y/n]" && read -r INTERNET
if [ "$INTERNET" != "N" ] && [ "$INTERNET" != "n" ]; then

	$CHROOT "pacman --needed --noconfirm -S firefox"

	if [ "$ENVIRONMENT" -eq 6 ] || [ "$ENVIRONMENT" -eq 8 ]; then
		$CHROOT "pacman --needed --noconfirm -S transmission-qt"
	else
		$CHROOT "pacman --needed --noconfirm -S transmission-gtk"
	fi
fi
clear

# Multimedia Related Stuff
printf "Do you want to install Multimedia manipulation tools? (gimp, inkscape, kdenlive, vlc) [Y/n]" && read -r MEDIA
if [ "$MEDIA" != "N" ] && [ "$MEDIA" != "n" ]; then
	$CHROOT "pacman --needed --noconfirm -S gimp kdenlive frei0r-plugins breeze-icons vlc inkscape"
fi
clear

# AUR
printf "Do you want to Enable AUR support? [Y/n] (yay)" && read -r AUR
if [ "$AUR" != "N" ] && [ "$AUR" != "n" ]; then
	$CHROOT "pacman --noconfirm --needed -Sy curl"
	$CHROOT "sudo -u $USERNAME mkdir /home/$USERNAME/AUR && cd /home/$USERNAME/AUR && sudo -u $USERNAME curl -LO 'https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yay' && sudo -u $USERNAME mv PKGBUILD\?h\=yay PKGBUILD && sudo -u $USERNAME makepkg --noconfirm -si && cd / && rm -rf /home/$USERNAME/AUR /home/$USERNAME/go"
fi
clear

# Extra Programs
printf "Do you want to install any extra packages not mentioned above? [Y/n]" && read -r MISSING
if [ "$MISSING" != "N" ] && [ "$MISSING" != "n" ]; then
	printf "Type below the extra packages you want to install separated by spaces:\n-> " && read -r PACKAGES
	$CHROOT "pacman --needed -S $PACKAGES"
fi
clear

#############################

echo "###############################"
echo "# Updating System Services... #"
echo "###############################"
echo
echo
sleep 2

printf "Do you want to Disable internal system beep? [Y/n]" && read -r BEEP
if [ "$BEEP" != "N" ] && [ "$BEEP" != "n" ]; then
	$CHROOT "echo "blacklist pcspkr" > /mnt/etc/modprobe.d/nobeep.conf"
fi
clear

$CHROOT "pacman --noconfirm -Syyuu"
clear

$CHROOT "pacman --noconfirm -Scc"
clear

#############################

echo "###########"
echo "# DONE :) #"
echo "###########"
echo "           "
echo "Installation Complete"
echo "System Will Shutdown in a second"

umount -R /mnt

if [ "$WIPENCRYPT" != "N" ] && [ "$WIPENCRYPT" != "n" ]; then
	cryptsetup close cryptdevice
fi


if [ "$USESWAP" != "N" ] && [ "$USESWAP" != "n" ]; then
	swapoff "$SWAP"
fi

poweroff