forked from vitamins/archinstaller
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchinstaller
More file actions
executable file
·794 lines (723 loc) · 20.1 KB
/
Copy patharchinstaller
File metadata and controls
executable file
·794 lines (723 loc) · 20.1 KB
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
#!/bin/bash
##############################################################
# title : archinstaller
# description : Automated installation script for arch linux
# authors : Dennis Anfossi & teateawhy
# contact : https://github.com/vitamins/archinstaller
# date : 19.01.2014
# version : 0.6.4.2
# license : GPLv2
# usage : Edit ari.conf and run ./archinstaller
##############################################################
# functions
config_fail() {
echo -ne '\033[31m'
echo "| Error, please check variable $1 !"
echo -ne '\033[0m'
exit 1
}
fail() {
echo -ne '\033[31m'
echo "| Error, $1"
echo -ne '\033[0m'
exit 1
}
# wait 2 seconds to allow for reading the message
message() {
echo -e '\033[31m'
echo '| archinstaller:'
echo "| $1"
echo -e '\033[0m'
sleep 2
}
unit_to_bytes() {
x=$1
case ${x: -1} in
K) mult='1024';;
M) mult='1048576';;
G) mult='1073741824';;
T) mult='1099511627776';;
esac
num=${x%?}
echo $(( $num * $mult ))
}
check_conf() {
echo -e '\033[31m| Checking configuration..\033[0m'
# confirm
[[ "$confirm" = 'yes' || "$confirm" = 'no' ]] || config_fail 'confirm'
# edit_conf
if [[ "$edit_conf" = 'yes' ]]; then
type "$EDITOR" > /dev/null || config_fail 'EDITOR'
else
[[ "$edit_conf" = 'no' ]] || config_fail 'edit_conf'
fi
# dest_disk
[[ -z "$dest_disk" ]] && config_fail 'dest_disk'
## check if dest_disk is a valid block device
[[ $(lsblk -dno TYPE "$dest_disk") = 'disk' ]] || config_fail 'dest_disk'
dest_disk_size=$(blockdev --getsize64 "$dest_disk")
totalsize=0
# manual_part
if [[ "$manual_part" = 'yes' ]]; then
findmnt -nfo TARGET /mnt > /dev/null || fail 'no mounted filesystem found at /mnt!'
[[ -z "$root_num" ]] && config_fail 'root_num'
[[ -b "$dest_disk""$root_num" ]] || config_fail 'root_num'
# determine fstype of /mnt/boot or /mnt
fstype=$(findmnt -no FSTYPE /mnt/boot) || fstype=$(findmnt -no FSTYPE /mnt)
encrypt_home='no'
else
[[ "$manual_part" = 'no' ]] || config_fail 'manual_part'
# check /mnt for availability
findmnt -nfo TARGET /mnt > /dev/null && \
fail 'working directory /mnt is blocked by mounted filesystem!'
# check dest_disk for mounted filesystems
mount | grep "$dest_disk" > /dev/null && \
fail 'found mounted filesystem on destination disk!'
# swap
if [[ "$swap" = 'yes' ]]; then
## swap_size
[[ -z "$swap_size" ]] && config_fail 'swap_size'
[[ "$swap_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'swap_size'
totalsize=$(unit_to_bytes "$swap_size")
else
[[ "$swap" = 'no' ]] || config_fail 'swap'
fi
# root_size
if [[ "$root_size" = '0' ]]; then
[[ "$home" = 'no' ]] || config_fail 'home'
else
[[ -z "$root_size" ]] && config_fail 'root_size'
[[ "$root_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'root_size'
totalsize=$(( totalsize + $(unit_to_bytes "$root_size") ))
fi
# home
if [[ "$home" = 'yes' ]]; then
## home_size
if [[ "$home_size" != '0' ]]; then
[[ -z "$home_size" ]] && config_fail 'home_size'
[[ "$home_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'home_size'
totalsize=$(( totalsize + $(unit_to_bytes "$home_size") ))
fi
## encrypt_home
if [[ "$encrypt_home" = 'yes' ]]; then
### cipher
[[ -z "$cipher" ]] && config_fail 'cipher'
### hash_alg
[[ -z "$hash_alg" ]] && config_fail 'hash_alg'
### key_size
[[ -z "$key_size" ]] && config_fail 'key_size'
else
[[ "$encrypt_home" = 'no' ]] || config_fail 'encrypt_home'
fi
else
[[ "$home" = 'no' ]] || config_fail 'home'
encrypt_home='no'
fi
# fstpye
## check if mkfs utilities are installed
case "$fstype" in
btrfs) type mkfs.btrfs > /dev/null || \
fail 'please install the btrfs-progs package!';;
ext2) ;;
ext3) ;;
ext4) ;;
jfs) type mkfs.jfs > /dev/null || fail 'please install the jfsutils package!';;
nilfs2) type mkfs.nilfs2 > /dev/null || \
fail 'please install the nilfs-utils package!';;
reiserfs) type mkfs.reiserfs > /dev/null || \
fail 'please install the reiserfsprogs package!';;
xfs) type mkfs.xfs > /dev/null || fail 'please install the xfsprogs package!';;
*) config_fail 'fstype';;
esac
fi
# partition_table
if [[ "$partition_table" = 'gpt' ]]; then
if [[ "$manual_part" = 'no' ]]; then
type gdisk > /dev/null || fail 'please install the gptfdisk package!'
fi
else
[[ "$partition_table" = 'mbr' ]] || config_fail 'partition_table'
fi
# uefi
if [[ "$uefi" = 'yes' ]]; then
## check if install host is booted in uefi mode
if [[ -z "$(mount -t efivarfs)" ]]; then
mount -t efivarfs efivarfs /sys/firmware/efi/efivars -o nosuid,noexec,nodev \
> /dev/null || config_fail 'uefi'
fi
efivar -l > /dev/null || config_fail 'uefi'
## bootloader
[[ "$bootloader" = 'grub' || "$bootloader" = 'gummiboot' ]] || config_fail 'bootloader'
## partition_table
[[ "$partition_table" = 'gpt' ]] || config_fail 'partition_table'
if [[ "$manual_part" = 'no' ]]; then
type mkfs.vfat > /dev/null || fail 'please install the dosfstools package!'
fi
[[ -z "$esp_size" ]] && config_fail 'esp_size'
[[ "$esp_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'esp_size'
totalsize=$(( totalsize + $(unit_to_bytes "$esp_size") ))
else
[[ "$uefi" = 'no' ]] || config_fail 'uefi'
## bootloader
if [[ "$bootloader" = 'syslinux' ]]; then
## syslinux supports the following filesystems
case "$fstype" in
ext2) ;;
ext3) ;;
ext4) ;;
btrfs) ;;
*) config_fail 'bootloader';;
esac
else
[[ "$bootloader" = 'grub' ]] || config_fail 'bootloader'
fi
fi
# check if totalsize plus 100 MiB is smaller than disk size
if [[ "$manual_part" = 'no' ]]; then
(( totalsize + 104857600 < dest_disk_size )) || fail 'disk size is too small!'
fi
# mirror
## online status is checked after internet connection was tested successfully
[[ -z "$mirror" ]] && config_fail 'mirror'
# locale
[[ -z "$locale" ]] && config_fail 'locale'
## enforce UTF-8
[[ "$locale" =~ ^[a-z]{2,3}_[A-Z]{2}(.UTF-8)?\ UTF-8$ ]] || config_fail 'locale'
# keymap
[[ -z "$keymap" ]] && config_fail 'keymap'
localectl --no-pager list-keymaps | grep -x "$keymap" > /dev/null || config_fail 'keymap'
# font
[[ -z "$font" ]] && config_fail 'font'
# timezone
[[ -z "$timezone" ]] && config_fail 'timezone'
timedatectl --no-pager list-timezones | grep -x "$timezone" > /dev/null || config_fail 'timezone'
# hardware_clock
[[ "$hardware_clock" = 'utc' || "$hardware_clock" = 'localtime' ]] || config_fail 'hardware_clock'
# hostname
[[ -z "$hostname" ]] && config_fail 'hostname'
[[ "$hostname" =~ ^[a-z0-9][a-z0-9-]*[a-z0-9]$ ]] || config_fail 'hostname'
# network
case "$network" in
no) ;;
dhcpcd) ;;
netctl-dhcp) ;;
ifplugd) ;;
netctl-custom) [[ -z "$netctl_profile" ]] && config_fail 'netctl_profile'
[[ -s ./"$netctl_profile" ]] || config_fail 'netctl_profile';;
*) config_fail 'network';;
esac
# set_password
[[ "$set_password" = 'yes' || "$set_password" = 'no' ]] || config_fail 'set_password'
# add_user
if [[ "$add_user" = 'yes' ]]; then
## username
[[ -z "$username" ]] && config_fail 'username'
[[ "$username" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]] || config_fail 'username'
else
[[ "$add_user" = 'no' ]] || config_fail 'add_user'
fi
# xorg
if [[ "$xorg" = 'yes' ]]; then
## desktop_environment
case "$desktop_environment" in
no) ;;
cinnamon) ;;
enlightenment17);;
gnome) ;;
kde) ;;
lxde) ;;
mate) ;;
xfce4) ;;
*) config_fail 'desktop_environment';;
esac
### display_manager
case "$display_manager" in
no) ;;
gdm) ;;
kdm) ;;
lxdm) ;;
xdm) ;;
*) config_fail 'display_manager';;
esac
else
[[ "$xorg" = 'no' ]] || config_fail 'xorg'
fi
# no config_fail beyond this point
echo -e '\033[32m| OK.\033[0m'
}
ask_confirm() {
echo -e '\033[31m'
echo '---------------------------------------'
if [[ "$manual_part" = 'no' ]]; then
echo 'The following drive will be formatted.'
lsblk -o NAME,TYPE,MODEL,SIZE,FSTYPE "$dest_disk"
else
echo 'The following filesystems are targeted.'
findmnt -l -o TARGET,SOURCE -R /mnt
fi
echo '---------------------------------------'
echo -ne '\033[0m'
answer='x'
while [[ "$answer" != 'Y' ]]; do
echo -n 'Continue? (Y/n) '
read -n 2 -r answer
[[ "$answer" = 'n' ]] && fail 'script cancelled!'
echo
done
}
make_part() {
# prepare disk
message 'Preparing disk..'
sgdisk -Z "$dest_disk"
dd bs=1K count=1024 iflag=nocache oflag=direct if=/dev/zero of="$dest_disk"
wipefs -a "$dest_disk"
blockdev --rereadpt "$dest_disk"; sync; blockdev --rereadpt "$dest_disk"
# partitioning
message 'Creating partitions..'
## partition layout
if [[ "$uefi" = 'yes' ]]; then
if [[ "$swap" = 'yes' ]]; then
esp_num=1
swap_num=2
root_num=3
home_num=4
else
esp_num=1
root_num=2
home_num=3
fi
else
if [[ "$bootloader" = 'grub' && "$partition_table" = 'gpt' ]]; then
if [[ "$swap" = 'yes' ]]; then
bios_num=1
swap_num=2
root_num=3
home_num=4
else
bios_num=1
root_num=2
home_num=3
fi
else
if [[ "$swap" = 'yes' ]]; then
swap_num=1
root_num=2
home_num=3
else
root_num=1
home_num=2
fi
fi
fi
## MBR
if [[ "$partition_table" = 'mbr' ]]; then
# DO NOT INSERT WHITESPACE INTO ECHO, OTHERWISE FDISK FAILS
## swap partition
if [[ "$swap" = 'yes' ]]; then
echo -e "n\n\
p\n\
"$swap_num"\n\
\n\
+"$swap_size"\n\
t\n\
82\n\
w" | fdisk "$dest_disk"
sleep 1
fi
## root partition
if [[ "$root_size" = '0' ]]; then
echo -e "n\n\
p\n\
"$root_num"\n\
\n\
\n\
w" | fdisk "$dest_disk"
else
echo -e "n\n\
p\n\
"$root_num"\n\
\n\
+"$root_size"\n\
w" | fdisk "$dest_disk"
fi
sleep 1
## home partition
if [[ "$home" = 'yes' ]]; then
if [[ "$home_size" = '0' ]]; then
echo -e "n\n\
p\n\
"$home_num"\n\
\n\
\n\
w" | fdisk "$dest_disk"
else
echo -e "n\n\
p\n\
"$home_num"\n\
\n\
+"$home_size"\n\
w" | fdisk "$dest_disk"
fi
fi
## GPT
else
## EFI system partition
if [[ "$uefi" = 'yes' ]]; then
sgdisk -n "$esp_num":0:+"$esp_size" -t "$esp_num":EF00 "$dest_disk"
sleep 1
else
## BIOS boot partition
if [[ "$bootloader" = 'grub' ]]; then
sgdisk -n "$bios_num":0:+1007K -t "$bios_num":EF02 "$dest_disk"
sleep 1
fi
fi
## swap partition
if [[ "$swap" = 'yes' ]]; then
sgdisk -n "$swap_num":0:+"$swap_size" -t "$swap_num":8200 "$dest_disk"
sleep 1
fi
## root partition
sgdisk -n "$root_num":0:+"$root_size" -t "$root_num":8300 "$dest_disk"
sleep 1
## home partition
if [[ "$home" = 'yes' ]]; then
sgdisk -n "$home_num":0:+"$home_size" -t "$home_num":8300 "$dest_disk"
fi
fi
# Create and mount filesystems
## root
message 'Formatting root..'
mkfs."$fstype" "$dest_disk""$root_num"
message 'Mounting root..'
mount -t "$fstype" "$dest_disk""$root_num" /mnt
## ESP
if [[ "$uefi" = 'yes' ]]; then
message 'Formatting ESP..'
mkfs.vfat -F32 "$dest_disk""$efi_num"
mkdir -p /mnt/boot
message 'Mounting ESP..'
mount -t vfat "$dest_disk""$efi_num" /mnt/boot
fi
## swap
if [[ "$swap" = 'yes' ]]; then
message 'Formatting swap..'
mkswap "$dest_disk""$swap_num"
swapon "$dest_disk""$swap_num"
fi
## home
if [[ "$home" = 'yes' ]]; then
if [[ "$encrypt_home" = 'yes' ]]; then
## encrypt home
modprobe dm_mod
## erase partition with /dev/zero
message 'Setting up Encryption. Secure erasure of partition..'
dd bs=4M if=/dev/urandom of="$dest_disk""$home_num" || sync
## map physical partition to LUKS
message 'Please enter a new encryption passphrase.'
cryptsetup --use-random -qy -c "$cipher" -h "$hash_alg" -s "$key_size" \
luksFormat "$dest_disk""$home_num"
## open encrypted volume
message 'To unlock the container, enter the passphrase again.'
cryptsetup open --type luks "$dest_disk""$home_num" home
message 'Formatting home..'
mkfs."$fstype" /dev/mapper/home
mkdir /mnt/home
message 'Mounting home..'
mount -t "$fstype" /dev/mapper/home /mnt/home
else
message 'Formatting home..'
mkfs."$fstype" "$dest_disk""$home_num"
mkdir /mnt/home
message 'Mounting home..'
mount -t "$fstype" "$dest_disk""$home_num" /mnt/home
fi
fi
}
pacman_install() {
pacman --noconfirm --needed -r /mnt --cachedir=/mnt/var/cache/pacman/pkg -S $@
}
install_xorg() {
if [[ "$xorg" = 'yes' ]]; then
message 'Installing xorg packages..'
pacman_install xorg-server xorg-server-utils xorg-xinit
# install desktop environment
case "$desktop_environment" in
no) ;;
cinnamon) pacman_install cinnamon;;
enlightenment17) pacman_install enlightenment17;;
gnome) pacman_install gnome gnome-extra;;
kde) pacman_install kde;;
lxde) pacman_install lxde;;
mate) pacman_install mate mate-extra;;
xfce4) pacman_install xfce4 xfce4-goodies;;
esac
# install display manager
case "$display_manager" in
no) ;;
gdm) pacman_install gdm;;
kdm) pacman_install kdebase-workspace;;
lxdm) pacman_install lxdm;;
xdm) pacman_install xorg-xdm;;
esac
fi
}
configure_system() {
message 'Configuring system..'
# crypttab
if [[ "$encrypt_home" = 'yes' ]]; then
home_uuid=$(lsblk -dno UUID "$dest_disk""$home_num")
echo "home UUID=$home_uuid none luks,timeout=60s" >> /mnt/etc/crypttab
[[ "$edit_conf" = 'yes' ]] && "$EDITOR" /mnt/etc/crypttab
fi
# fstab
genfstab -U -p /mnt > /mnt/etc/fstab
[[ "$edit_conf" = 'yes' ]] && "$EDITOR" /mnt/etc/fstab
# locale
[[ "$locale" = 'en_US.UTF-8 UTF-8' ]] || echo 'en_US.UTF-8 UTF-8' >> /mnt/etc/locale.gen
echo "$locale" >> /mnt/etc/locale.gen
echo "LANG=${locale%% *}" > /mnt/etc/locale.conf
arch-chroot /mnt locale-gen
# console font and keymap
cat << EOF > /mnt/etc/vconsole.conf
KEYMAP=$keymap
FONT=$font
EOF
# timezone
ln -s /usr/share/zoneinfo/"$timezone" /mnt/etc/localtime
# hardware clock
hwclock -w --"$hardware_clock"
# kernel modules
if [[ "$configure_modules" = 'yes' ]]; then
for m in ${k_modules[@]}; do
echo "$m" >> /mnt/etc/modules-load.d/modules.conf
done
fi
# hostname
echo "$hostname" > /mnt/etc/hostname
# network service
if [[ "$network" != 'no' ]]; then
## fix wired network interface name to eth0
touch /mnt/etc/udev/rules.d/80-net-name-slot.rules
case "$network" in
dhcpcd) arch-chroot /mnt systemctl enable dhcpcd@eth0.service;;
netctl-dhcp) cp /mnt/etc/netctl/examples/ethernet-dhcp \
/mnt/etc/netctl/ethernet_dynamic
arch-chroot /mnt netctl enable ethernet_dynamic;;
ifplugd) pacman_install ifplugd
arch-chroot /mnt systemctl enable netctl-ifplugd@eth0.service;;
netctl-custom) cp ./"$netctl_profile" /mnt/etc/netctl
arch-chroot /mnt netctl enable "$netctl_profile";;
esac
fi
# mkinitcpio
if [[ "$edit_conf" = 'yes' ]]; then
cp /mnt/etc/mkinitcpio.conf /tmp/mkinitcpio.conf
"$EDITOR" /mnt/etc/mkinitcpio.conf
## only regenerate if modified
cmp -s /mnt/etc/mkinitcpio.conf /tmp/mkinitcpio.conf || arch-chroot /mnt mkinitcpio -p linux
rm -f /tmp/mkinitpcio.conf
fi
# root password
if [[ "$set_password" = 'yes' ]]; then
message 'Setting password for root user..'
## loop if entered passwords do not match
while :; do
passwd -R /mnt root && break
done
fi
# add user
if [[ "$add_user" = 'yes' ]]; then
useradd -R /mnt -m -g users -s /bin/bash "$username"
## set user password
if [[ "$set_password" = 'yes' ]]; then
message "Setting password for $username.."
while :; do
passwd -R /mnt "$username" && break
done
fi
fi
}
install_bootloader() {
message 'Installing bootloader..'
if [[ "$uefi" = 'yes' ]]; then
# UEFI
if [[ "$bootloader" = 'grub' ]]; then
## install grub
pacman_install dosfstools efibootmgr grub
## in special cases, change to: --target=i386-efi
echo 'grub-mkconfig -o /boot/grub/grub.cfg; grub-install --target=x86_64-efi \
--efi-directory=/boot --bootloader-id=arch_grub --recheck' | arch-chroot /mnt
else
## install gummiboot
pacman_install gummiboot
arch-chroot /mnt gummiboot install
## configure gummiboot
cat << EOF > /mnt/boot/loader/loader.conf
default arch
timeout 5
EOF
root_partuuid=$(lsblk -dno PARTUUID "$dest_disk""$root_num")
cat << EOF > /mnt/boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$root_partuuid rw
EOF
[[ "$edit_conf" = 'yes' ]] && "$EDITOR" /mnt/boot/loader/entries/arch.conf
fi
else
# BIOS
if [[ "$bootloader" = 'syslinux' ]]; then
## install syslinux
if [[ "$partition_table" = 'gpt' ]]; then
pacman_install gptfdisk syslinux
else
pacman_install syslinux
fi
arch-chroot /mnt syslinux-install_update -i -a -m
## configure syslinux
root_uuid=$(lsblk -dno UUID "$dest_disk""$root_num")
cat << EOF > /mnt/boot/syslinux/syslinux.cfg
PROMPT 1
TIMEOUT 50
DEFAULT arch
LABEL arch
LINUX ../vmlinuz-linux
APPEND root=UUID=$root_uuid rw
INITRD ../initramfs-linux.img
LABEL archfallback
LINUX ../vmlinuz-linux
APPEND root=UUID=$root_uuid rw
INITRD ../initramfs-linux-fallback.img
EOF
[[ "$edit_conf" = 'yes' ]] && "$EDITOR" /mnt/boot/syslinux/syslinux.cfg
else
## install grub
pacman_install grub
echo "grub-mkconfig -o /boot/grub/grub.cfg; grub-install --target=i386-pc \
--recheck $dest_disk" | arch-chroot /mnt
fi
fi
}
if (( "$#" > 0 )); then
(( "$#" > 1 )) && fail 'too many arguments!'
if [[ "$1" = '-v' || "$1" = '--version' ]]; then
cat << EOF
archinstaller 0.6.4.2
Copyright (C) 2013 Dennis Anfossi
License GPLv2
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Dennis Anfossi & teateawhy.
EOF
exit 0
elif [[ "$1" = '-h' || "$1" = '--help' ]]; then
cat << EOF
Run without arguments to start the installer.
-h --help display this help and exit
-v --version output version information and exit
For the complete documentation see README.
EOF
exit 0
else
fail "invalid option $1"
fi
fi
# check root priviledges
[[ "$EUID" = '0' ]] || fail 'please run as root user!'
# check arch linux
[[ -e /etc/arch-release ]] || fail 'please run on arch linux!'
# ⌘ check apple mac
if [[ "$( < '/sys/class/dmi/id/sys_vendor' )" = 'Apple Inc.' ]] || \
[[ "$( < '/sys/class/dmi/id/sys_vendor' )" = 'Apple Computer, Inc.' ]]; then
fail 'Apple Mac computers are not supported, due to non-compliant firmware!'
fi
# arch-install-scripts required
type pacstrap > /dev/null || fail 'please install the arch-install-scripts package!'
# set defaults
confirm='yes'
edit_conf='yes'
manual_part='no'
esp_size='512M'
home='yes'
home_size='0'
cipher='aes-xts-plain64'
hash_alg='sha1'
key_size='256'
# EDITOR defaults to nano if environment variable EDITOR is unset
[[ -z "$EDITOR" ]] && EDITOR='nano'
# check if configuration file is in the current working directory
[[ -s ./ari.conf ]] || fail "configuration file ari.conf not found in $(pwd) !"
echo -ne '\033[31m'
cat << EOF
---------------------------------------
Welcome to archinstaller!
---------------------------------------
EOF
echo -ne '\033[0m'
# source configuration file
source ./ari.conf
# check configuration
check_conf
# load package list from file pkglist.txt
[[ -s ./pkglist.txt ]] && packages+=( $( < ./pkglist.txt ) )
# avoid errors due to "set -u" and unset variable
## packages
[[ -z "$packages" ]] && install_packages='no' || install_packages='yes'
## kernel modules
[[ -z "$k_modules" ]] && configure_modules='no' || configure_modules='yes'
# check internet connection
echo -e '\033[31m| Checking internet connection..'
curl --retry 3 -m 10 -o /dev/null -s http://mirrors.kernel.org || \
fail 'please check the internet connection!'
echo -e '\033[32m| OK.\033[0m'
# check mirror status
if [[ "$mirror" != 'keep' ]]; then
curl --retry 3 -m 10 -o /dev/null -s "$mirror"lastsync || \
fail 'please check the mirror status and configuration!'
fi
# paranoid shell
set -e -u
# ask for confirmation
[[ "$confirm" = 'yes' ]] && ask_confirm
# create partitions & filesystems, mount filesystems
[[ "$manual_part" = 'no' ]] && make_part
# mirror
if [[ "$mirror" != 'keep' ]]; then
mirror='Server = '"$mirror"'$repo/os/$arch'
echo "$mirror" > /etc/pacman.d/mirrorlist
fi
# pacstrap base packages
message 'Installing base system..'
pacstrap /mnt base
# install xorg packages
install_xorg
# install additional packages
if [[ "$install_packages" = 'yes' ]]; then
message 'Installing additional packages..'
pacman_install ${packages[@]} || :
fi
# configure system
configure_system
# install bootloader
install_bootloader
# unmount filesystems
if [[ "$manual_part" = 'yes' ]]; then
message 'Please unmount the targeted filesystems before rebooting.'
else
umount /mnt/home
umount /mnt
## close encrypted volume
[[ "$encrypt_home" = 'yes' ]] && cryptsetup close home
fi
# finish
echo -e '\033[31m'
cat << EOF
---------------------------------------
Installation completed!
Reboot the computer: # reboot
---------------------------------------
EOF
echo -ne '\033[0m'
exit 0