aboutsummaryrefslogtreecommitdiffstats
path: root/arch_install-UEFI.sh
blob: 861877e06a5b28c04f5c3587e841cc12c0a49d3e (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
#!/bin/bash

answr=""
drvnm=""
rts=""
swps=""
rtpwd=""
rtrtpwd="walk"
usrpwd=""
usrusrpwd="fade"
hstnm=""
isusr="false"
somemore="false"
intelamdcpu="none"
intelamdgpu="none"

clear
echo "#============ WELCOME ============#"
echo "#                                 #"
echo "#        Welcome to Joe's         #"
echo "#           ARCH LINUX            #"
echo "#      UEFI INSTALL SCRIPT        #"
echo "#                                 #"
echo "#  (press [return] to begin...)   #"
echo "#                                 #"
echo "#=================================#"
read

# ================================================================================================ #
# ======================================== ERRORS CHECK ========================================== #
# ================================================================================================ #

if [ ! -r /sys/firmware/efi/efivars ]; then
				clear
				echo "X=X=X=X=X=X=X ERROR X=X=X=X=X=X=X=X"
				echo "X                                 X"
				echo "X    It seems that boot mode      X"
				echo "X      is not set to UEFI         X"
				echo "X    therefore Joe's script is    X"
				echo "X        forced to abort          X"
				echo "X                                 X"
				echo "X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X"
				sleep 6
				echo && echo
				echo "Thank you for using Joe's Arch Linux UEFI install scritpt."
				sleep 1
				echo "Aborting..."
				sleep 3
				clear
				exit
fi
clear
echo "Verifying that your are connected to the Internet, please wait..."
wget -q --spider https://google.com
if [ ! $? -eq 0 ]; then
				clear
				echo "X=X=X=X=X=X=X ERROR X=X=X=X=X=X=X=X"
				echo "X                                 X"
				echo "X       It seems that your        X"
				echo "X         terminal is not         X"
				echo "X    connected to the Internet    X"
				echo "X    therefore Joe's script is    X"
				echo "X        forced to abort          X"
				echo "X                                 X"
				echo "X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X=X"
				sleep 6
				echo && echo
				echo "Thank you for using Joe's Arch Linux UEFI install script."
				sleep 1
				echo "Aborting..."
				sleep 3
				clear
				exit
else
				echo "Success!"
				echo
				echo "Press [retrun] key to continue"
				read
fi

# ================================================================================================ #
# ========================================= DISK SETUP =========================================== #
# ================================================================================================ #

while [[ $answr != y && $answr != Y && $answr != yes && $answr != Yes && $answr != YES ]]; do
				drvnm=""
				swps=""
				rts=""
				clear
				echo "#========= I. DISK SETUP =========#"
				echo "#                                 #"
				echo "#      Please choose wisely       #"
				echo "#                                 #"
				echo "#      1. Drive to be used        #"
				echo "#                                 #"
				echo "#=================================#"
				while [[ $drvnm == "" ]]; do
								echo && echo
								echo "Please enter letter of the drive on which Arch Linux should be installed:"
								echo "/dev/sd_"
								echo -n "> "
								read -n 1 drvnm
								if [[ $drvnm == "" ]]; then
												echo && echo
												echo "Can't be empty, retrying..."
								fi
				done
				clear
				echo "#========= I. DISK SETUP =========#"
				echo "#                                 #"
				echo "#      Please choose wisely       #"
				echo "#                                 #"
				echo "#      2. swap partion size       #"
				echo "#                                 #"
				echo "#=================================#"
				while [[ $swps == "" ]]; do
								echo && echo
								echo "Please enter your swap partition disired size:"
								echo "_G"
								echo -n "> "
								read swps
								if [[ $swps == "" ]]; then
												echo && echo
												echo "Can't be empty, retrying..."
								fi
				done
				clear
				echo "#========= I. DISK SETUP =========#"
				echo "#                                 #"
				echo "#      Please choose wisely       #"
				echo "#                                 #"
				echo "#      3. root partion size       #"
				echo "#                                 #"
				echo "#=================================#"
				while [[ $rts == "" ]]; do
								echo && echo
								echo "Please enter your root partition disired size:"
								echo "__G"
								echo -n "> "
								read rts
								if [[ $rts == "" ]]; then
												echo && echo
												echo "Can't be empty, retrying..."
								fi
				done

				drv="/dev/sd$drvnm"
				btsze="128M"
				rtsze=$rts"G"
				swpsze=$swps"G"

				clear
				echo "#============= CONFIRM THIS IS CORRECT ===============#" 
				echo "#                                                     #"
				echo "#                DRIVE TO USE: $drv               #"
				echo "#                                                     #"
				echo "#  /boot/efi > BOOT partition size: $btsze              #"
				echo "#              SWAP partition size: $swpsze                #"
				echo "#  /         > ROOT partition size: $rtsze               #"
				echo "#  /home     > HOME partition size: all that remains  #"
				echo "#                                                     #"
				echo "#=====================================================#" 
				echo && echo
				echo "Is that correct? [y/N]"
				echo -n "> "
				read answr
				if [[ $answr != y && $answr != Y && $answr != yes && $answr != Yes && $answr != YES ]]; then
								echo && echo
								echo "Retrying..."
								echo
								echo "Press [retrun] key to continue"
								read
				fi
done

# ================================================================================================ #
# ========================================= USERS SETUP ========================================== #
# ================================================================================================ #

answr="n"

while [[ $rtrtpwd != $rtpwd || $rtpwd == "" ]]; do
				clear
				echo "#======= II. USERS SETUP =========#"
				echo "#                                 #"
				echo "#        1. root password         #"
				echo "#                                 #"
				echo "#=================================#"
				echo && echo
				echo "Enter your disired root password (can't be empty):"
				echo -n "> "
				read -s rtpwd
				echo && echo
				echo "Confirm root password:"
				echo -n "> "
				read -s rtrtpwd
				if [[ $rtrtpwd != $rtpwd ]]; then
								echo && echo
								echo "Password mismatch, retrying..."
								sleep 2
				fi
				if [[ $rtpwd == "" ]]; then
								echo && echo
								echo "Password is empty, retrying..."
								sleep 2
				fi
done

clear
echo "#======= II. USERS SETUP =========#"
echo "#                                 #"
echo "#          2. User add            #"
echo "#                                 #"
echo "#=================================#"
echo && echo
echo "Would you like to add a user to the system? [y/N]"
echo -n "> " 
read answr
if [[ $answr == y || $answr == Y || $answr == yes || $answr == Yes || $answr == YES ]]; then
				echo && echo
				echo "Enter your desired username:"
				echo -n "> "
				read usr
				isusr="true"
				usr=$(echo $usr | tr '[:upper:]' '[:lower:]')
				echo && echo
				while [[ $usrusrpwd != $usrpwd || $usrpwd == "" ]]; do
								echo "Enter your disired password for $usr (can't be empty):"
								echo -n "> "
								read -s usrpwd
								echo && echo
								echo "Confirm user password:"
								echo -n "> "
								read -s usrusrpwd
								if [[ $usrusrpwd != $usrpwd ]]; then
												echo && echo
												echo "Password mismatch, retrying..."
												sleep 2
								fi
								if [[ $usrpwd == "" ]]; then
												echo && echo
												echo "Password is empty, retrying..."
												sleep 2
								fi
				done
fi
clear
echo "#======= II. USERS SETUP =========#"
echo "#                                 #"
echo "#          3. hostname            #"
echo "#                                 #"
echo "#=================================#"
while [[ $hstnm == "" ]]; do
				echo && echo
				echo "Enter your disired hostname for this terminal (can't be empty):"
				echo -n "> "
				read hstnm
				if [[ $hstnm == "" ]]; then
								echo && echo
								echo "Hostname is empty, retrying..."
								sleep 2
				fi
done
answr="n"
clear
echo "#====== III. EXTRAS SETUP ========#"
echo "#                                 #"
echo "#            1. More              #"
echo "#                                 #"
echo "#=================================#"
echo && echo
echo "Do you wish to install xorg and gst-plugins as well? [y/N]"
echo -n "> "
read answr
if [[ $answr == y || $answr == Y || $answr == yes || $answr == Yes || $answr == YES ]]; then
				somemore="true"
fi
clear
echo "#====== III. EXTRAS SETUP ========#"
echo "#                                 #"
echo "#      2. Intel/AMD CPU           #"
echo "#                                 #"
echo "#=================================#"
while [[ $answr != 1 || $answr != 2 || $answr != 3 ]]; do
				echo && echo
				echo "Is your terminal runing on Intel or AMD CPU? [1 (Intel) | 2 (AMD) | 3 (Something else / don't know)]"
				echo -n "> "
				read -n 1 answr
				if [[ $answr != 1 || $answr != 2 || $answr != 3 ]]; then
								echo && echo "Wrong input, enter 1 for Intel, 2 for AMD, 3 if you don't know"
				fi
				if [[ $answr == 1 ]]; then
								intelamdcpu="intel"
				fi
				if [[ $answr == 2 ]]; then
								intelamdcpu="amd"
				fi
				if [[ $answr == 3 ]]; then
								intelamdcpu="other"
				fi
done
answr=""
clear
echo "#====== III. EXTRAS SETUP ========#"
echo "#                                 #"
echo "#      3. Intel/AMD GPU           #"
echo "#                                 #"
echo "#=================================#"
while [[ $answr != 1 || $answr != 2 || $answr != 3 ]]; do
				echo && echo
				echo "Is your terminal runing on Intel or AMD GPU? [1 (Intel) | 2 (AMD) | 3 (Something else / don't know)]"
				echo -n "> "
				read -n 1 answr
				if [[ $answr != 1 || $answr != 2 || $answr != 3 ]]; then
								echo && echo "Wrong input, enter 1 for Intel, 2 for AMD, 3 if you don't know"
				fi
				if [[ $answr == 1 ]]; then
								intelamdgpu="intel"
				fi
				if [[ $answr == 2 ]]; then
								intelamdgpu="amd"
				fi
				if [[ $answr == 3 ]]; then
								intelamdgpu="other"
				fi
done

# ================================================================================================ #
# ===================================== THE ACTUAL INSTALL ======================================= #
# ================================================================================================ #


# ============================================================== #
# ========================== NTP DATE ========================== #
# ============================================================== #


clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#        1. Setting date          #"
echo "#             via ntp             #"
echo "#                                 #"
echo "#=================================#"
timedatectl set-ntp true
sleep 2

# ============================================================== #
# ==================== PARTITIONING DISK ======================= #
# ============================================================== #


clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#        2. Partitionning         #"
echo "#          disk $drv          #"
echo "#                                 #"
echo "#=================================#"
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk $drv
	o	# test
	g	# create a new GPT partition table
	n	# new partition (/dev/sdx1)
	1	# partition number 1
		# first sector (2048)
	+$btsze	# boot size partition
	n	# new partition (/dev/sdx2)
	2	#	partition number 2
		# default start block
	+$swpsze	#	swap size partition
	n	# new partition (/dev/sdx3)
	3	# partition number 3
		# default start block
	+$rtsze	# root size partition
	n	# new partition (/dev/sdx4)
	4	# partition number 4
		# default start block
		#	all that remains
	w	# write the partition table and quit
EOF
mkswap $drv"2"
mkfs.ext2 $drv"1"
mkfs.ext4 $drv"3"
mkfs.ext4 $drv"4"
sleep 2
clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#     3. Mounting partitions      #"
echo "#                                 #"
echo "#=================================#"
swapon $drv"2"
mkdir /mnt/arch
mount $drv"3" /mnt/arch
mkdir /mnt/arch/boot
mkdir /mnt/arch/boot/efi
mount $drv"1" /mnt/arch/boot/efi
mkdir /mnt/arch/home
mount $drv"4" /mnt/arch/home
sleep 2
clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#    4. Installing base system    #"
echo "#                                 #"
echo "#=================================#"
pacstrap /mnt/arch base base-devel pacman-contrib
sleep 1
clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#   4.5 Installing some extras    #"
echo "#                                 #"
echo "#=================================#"
pacstrap /mnt/arch zip unzip p7zip vim mc alsa-utils syslog-ng mtools dostools lsb-releaseease ntfs-3g exfat-utils git zsh
pacstrap /mnt/arch ntp cronie
pacstrap /mnt/arch grub os-prober efibootmgr
sleep 1
clear
echo "#====== IV. INSTALLING LINUX =====#"
echo "#                                 #"
echo "#       5. Generating fstab       #"
echo "#                                 #"
echo "#=================================#"
genfstab -U /mnt/arch > /mnt/arch/etc/fstab
sleep 2
clear
echo "#====== V. CONFIGURING LINUX =====#"
echo "#                                 #"
echo "#      1. Now changing root       #"
echo "#                                 #"
echo "#=================================#"
sleep 2
sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#      2. Setting time zone       #
	#        to Paris, France,        #
	#    for this is my time zone.    #
	#  Change this later accordingly  #
	#      to your own time zone      #
	#    (Joe didn't find a quick     #
	#     and easy way to ask you     #
	#      about your time zone,      #
	# Joe hopes your can  understand) #
	#                                 #
	#=================================#
	ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
	sleep 8
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#    3. Setting hardware clock    #
	#          and ntp again          #
	#                                 #
	#=================================#
	hwclock --systohc
	ntpdate fr.pool.ntp.org
	systemctl enable ntpd
	sleep 1
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#        4. Localization          #
	#          (en_US.UTF-8)          #
	#                                 #
	#=================================#
	sed 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen > /etc/locale.gen.42
	mv /etc/locale.gen.42 /etc/locale.gen
	locale-gen
	echo "LANG=en_US.UTF-8" > /etc/locale.conf
	sleep 2
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#       5. Setting hostname       #
	#                                 #
	#=================================#
	echo $hstnm > /etc/hostname
	echo "127.0.0.1 localhost" > /etc/hosts
	echo "::1 localhost" >> /etc/hosts
	echo "127.0.1.1 $hstnm.localdomain $hstnm" >> /etc/hosts
	sleep 2
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#     6. Setting root password    #
	#                                 #
	#=================================#
	passwd
	$rtpwd
	$rtpwd
	sleep 2
	clear
	#===== IV. CONFIGURING LINUX =====#
	#                                 #
	#     7. Setting up network       #
	#                                 #
	#=================================#
	pacman -S networkmanager
	Y
EOF
sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	systemctl enable NetworkManager
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#        8. journald stuff        #
	#                                 #
	#=================================#
	sed 's/#ForwardToSyslog=no/ForwardToSyslog=yes/' /etc/systemd/journald.conf > /etc/systemd/journald.conf.42
	mv /etc/systemd/journald.conf.42 /etc/systemd/journald.conf
	sleep 2
EOF
if [[ $somemore == "true" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#         9. Installing           #
	#        some more utils          #
	#     (gst plugins, xorg...)      #
	#                                 #
	#=================================#
	pacman -S gst-plugins-{base,good,bad,ugly} gst-libav xorg-{server,xinit,apps} xf86-input-{mouse,keyboard} xdg-user-dirs mesa ttf-{bitstream-vera,liberation,freefont,dejavu} freetype2 xf86-video-vesa

	Y
EOF
fi
if [[ $intelamdgpu == "intel" && $somemore == "true" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#        9.5 Installing           #
	#        some more utils          #
	#         (xf86-video)            #
	#                                 #
	#=================================#
	pacman -S xf86-video-intel
	Y
EOF
fi
if [[ $intelamdgpu == "amd" && $somemore == "true" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#        9.5 Installing           #
	#        some more utils          #
	#         (xf86-video)            #
	#                                 #
	#=================================#
	pacman -S xf86-video-amdgpu
	Y
EOF
fi
if [[ $isusr == "true" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#      10. Installing sudo        #
	#                                 #
	#=================================#
	pacman -S sudo
	Y
EOF
sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#      11. Generating user        #
	#                                 #
	#=================================#
	useradd -m -g wheel -s /bin/zsh $usr
	passwd $usr
	$usrpwd
	$usrpwd
	sed 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers > /etc/sudoers.42
	mv /etc/sudoers.42 /etc/sudoers
EOF
fi
if [[ $intelamdcpu == "intel" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#      12. Installing CPU         #
	#           microcode             #
	#                                 #
	#=================================#
	pacman -S intel-ucode
	Y
EOF
fi
if [[ $intelamdcpu == "amd" ]]; then
	sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== V. CONFIGURING LINUX ======#
	#                                 #
	#      12. Installing CPU         #
	#           microcode             #
	#                                 #
	#=================================#
	pacman -S amd-ucode
	Y
EOF
fi
sed -e 's/\s*\([\+0-9a-zA-Z \"=#()[]{}<>,:. - \_\/?!@$%^&~`*|]*\).*/\1/' << EOF | arch-chroot /mnt/arch
	clear
	#===== VI. CONFIGURING BOOT ======#
	#                                 #
	#   1. Generating Kernel image    #
	#                                 #
	#=================================#
	mkinitcpio -p linux
	sleep 1
	clear
	#===== VI. CONFIGURING BOOT ======#
	#                                 #
	#       2. Configuring GRUB       #
	#                                 #
	#=================================#
	grub-mkconfig -o /boot/grub/grub.cfg
	grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck
EOF
clear
echo "#========= WORK COMPLETE =========#"
echo "#                                 #"
echo "#     Your system should now      #"
echo "#         be installed.           #"
echo "#   Thank your for using Joe's    #"
echo "#           ARCH LINUX            #"
echo "#      UEFI INSTALL UTILITY       #"
echo "#                                 #"
echo "#  (press [return] to reboot...)  #"
echo "#                                 #"
echo "#=================================#"
read
umount -R /mnt/arch
reboot