-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquarchinstaller
2243 lines (1902 loc) · 61.6 KB
/
quarchinstaller
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
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
### vitamins/archinstaller + archmind script 2.1
###preview version
declare -r VERSION='0.test-preview'
# colors
unset ALL_OFF GREEN RED
ALL_OFF='\e[1;0m'
GREEN='\e[1;32m'
RED='\e[1;31m'
readonly ALL_OFF GREEN RED
# functions
# {{{
config_fail() {
printf "$RED"
printf '%s\n' "| Error in variable ${1}."
printf "$ALL_OFF"
exit 1
}
fail() {
printf "$RED"
printf '%s\n' "| Error, ${1}."
printf "$ALL_OFF"
exit 1
}
# wait 2 seconds for the user to read the message, if confirm is set to yes
message() {
printf "${RED}\n"
printf '%s\n' '| archinstaller:'
printf '%s\n' "| ${1}"
printf "${ALL_OFF}\n"
[[ "$confirm" = 'yes' ]] && sleep 2
return 0
}
check_conf() {
printf "$RED"
printf '%s\n' '| Checking configuration..'
printf "$ALL_OFF"
# 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
# unmount
[[ "$unmount" = 'yes' || "$unmount" = 'no' ]] || config_fail 'unmount'
# manual_part
if [[ "$manual_part" = 'yes' ]]; then
mountpoint -q /mnt || fail 'no mounted filesystem found at target /mnt'
[[ -z "$cmdline" ]] && config_fail 'cmdline'
if [[ "$bootloader" = 'grub' && "$uefi" = 'no' ]]; then
# dest_disk
[[ -z "$dest_disk" ]] && config_fail 'dest_disk'
## check if dest_disk is really a disk
[[ $(lsblk -dno TYPE "$dest_disk") = 'disk' ]] || config_fail 'dest_disk'
fi
else
[[ "$manual_part" = 'no' ]] || config_fail 'manual_part'
# dest_disk
[[ -z "$dest_disk" ]] && config_fail 'dest_disk'
## check if dest_disk is really a disk
[[ $(lsblk -dno TYPE "$dest_disk") = 'disk' ]] || config_fail 'dest_disk'
# check /mnt for availability
mountpoint -q /mnt && 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'
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'
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'
fi
## encrypt_home
if [[ "$encrypt_home" = 'yes' ]]; then
[[ -z "$cryptsetup_options" ]] && config_fail 'cryptsetup_options'
else
[[ "$encrypt_home" = 'no' ]] || config_fail 'encrypt_home'
fi
else
[[ "$home" = 'no' ]] || config_fail 'home'
fi
# fstype
## check if mkfs utilities are installed
## set options for overwriting existing filesystems
case "$fstype" in
btrfs) type mkfs.btrfs > /dev/null || fail 'missing package: btrfs-progs'
packages+=( 'btrfs-progs' )
mkfs_options="$fstype";;
ext2|ext3|ext4)
type mkfs.ext4 > /dev/null || fail 'missing package: e2fsprogs'
mkfs_options="${fstype} -q";;
f2fs) type mkfs.f2fs > /dev/null || fail 'missing package: f2fs-tools'
packages+=( 'f2fs-tools' )
mkfs_options="$fstype";;
jfs) type mkfs.jfs > /dev/null || fail 'missing package: jfsutils'
mkfs_options="${fstype} -q";;
nilfs2) type mkfs.nilfs2 > /dev/null || fail 'missing package: nilfs-utils'
packages+=( 'nilfs-utils' )
mkfs_options="${fstype} -f -q";;
reiserfs)
type mkfs.reiserfs > /dev/null || fail 'missing package: reiserfsprogs'
mkfs_options="${fstype} -q";;
xfs) type mkfs.xfs > /dev/null || fail 'missing package: xfsprogs'
mkfs_options="${fstype} -f -q";;
*) config_fail 'fstype';;
esac
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 > /dev/null ||
config_fail 'uefi'
fi
efivar -l > /dev/null || config_fail 'uefi'
## bootloader
[[ "$bootloader" = 'grub' || "$bootloader" = 'gummiboot' ]] || config_fail 'bootloader'
if [[ "$manual_part" = 'no' ]]; then
type mkfs.vfat > /dev/null || fail 'missing package: dosfstools'
fi
[[ -z "$esp_size" ]] && config_fail 'esp_size'
[[ "$esp_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'esp_size'
else
[[ "$uefi" = 'no' ]] || config_fail 'uefi'
## bootloader
[[ "$bootloader" = 'syslinux' || "$bootloader" = 'grub' ]] || config_fail 'bootloader'
# boot_size
[[ -z "$boot_size" ]] && config_fail 'boot_size'
[[ "$boot_size" =~ ^[0-9]+[K,M,G,T]$ ]] || config_fail 'boot_size'
fi
# mirror
## online status is checked after internet connection was tested successfully
[[ -z "$mirror" ]] && config_fail 'mirror'
[[ "$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|ifplugd) ;;
netctl) [[ -z "$netctl_profile" ]] && config_fail 'netctl_profile'
[[ -s ./"$netctl_profile" ]] || config_fail 'netctl_profile';;
*) config_fail 'network';;
esac
# hooks
[[ -z "$hooks" ]] && configure_hooks='no' || configure_hooks='yes'
# set_password
if [[ "$set_password" = 'yes' ]]; then
## root password
[[ -z "$root_password" ]] && ask_root_password='yes' || ask_root_password='no'
else
[[ "$set_password" = 'no' ]] || config_fail 'set_password'
fi
# add_user
if [[ "$add_user" = 'yes' ]]; then
## username
[[ -z "$username" ]] && config_fail 'username'
[[ "$username" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]] || config_fail 'username'
## user password
if [[ "$set_password" = 'yes' ]]; then
[[ -z "$user_password" ]] && ask_user_password='yes' || ask_user_password='no'
fi
else
[[ "$add_user" = 'no' ]] || config_fail 'add_user'
fi
# no config_fail beyond this point
printf "$GREEN"
printf '%s\n' '| OK.'
printf "$ALL_OFF"
}
ask_confirm() {
printf "$RED"
printf '%s\n' '---------------------------------------'
if [[ "$manual_part" = 'no' ]]; then
printf '%s\n' 'The following drive will be formatted.'
lsblk -o NAME,TYPE,MODEL,SIZE,FSTYPE "$dest_disk"
else
printf '%s\n' 'The following filesystems are targeted.'
findmnt -l -o TARGET,SOURCE -R /mnt
fi
printf '%s\n' '---------------------------------------'
printf "$ALL_OFF"
local answer='x'
while [[ "$answer" != 'Y' ]]; do
printf '%s' 'Continue? (Y/n) '
read -n 2 -r answer
[[ "$answer" = 'n' ]] && fail 'script cancelled'
printf '\n'
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
# first partition is ESP
if [[ "$swap" = 'yes' ]]; then
swap_num=2
root_num=3
home_num=4
else
root_num=2
home_num=3
fi
else
if [[ "$bootloader" = 'grub' ]]; then
# first partition is BIOS boot
if [[ "$swap" = 'yes' ]]; then
boot_num=2
swap_num=3
root_num=4
home_num=5
else
boot_num=2
root_num=3
home_num=4
fi
else
if [[ "$swap" = 'yes' ]]; then
boot_num=1
swap_num=2
root_num=3
home_num=4
else
boot_num=1
root_num=2
home_num=3
fi
fi
fi
## EFI system partition
if [[ "$uefi" = 'yes' ]]; then
sgdisk -n 1:0:+"$esp_size" -t 1:EF00 "$dest_disk"
sleep 1
else
## BIOS boot partition
if [[ "$bootloader" = 'grub' ]]; then
sgdisk -n 1:0:+1007K -t 1:EF02 "$dest_disk"
sleep 1
fi
## boot partition
sgdisk -n "$boot_num":0:+"$boot_size" -t "$boot_num":8300 "$dest_disk"
sleep 1
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
# create and mount filesystems
## root
message 'Formatting root..'
mkfs.${mkfs_options} "$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"1
mkdir -p /mnt/boot
message 'Mounting ESP..'
mount -o nodev,nosuid,noexec -t vfat "$dest_disk"1 /mnt/boot
else
message 'Formatting /boot..'
mkfs.ext2 -q "$dest_disk""$boot_num"
mkdir -p /mnt/boot
message 'Mounting /boot..'
mount -o nodev,nosuid,noexec -t ext2 "$dest_disk""$boot_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
## overwrite partition with zeroes
message 'Setting up Encryption. Secure erasure of partition..'
dd bs=4M iflag=nocache oflag=direct if=/dev/zero of="$dest_disk""$home_num" || sync
## map physical partition to LUKS
message 'Please enter a new encryption passphrase.'
cryptsetup ${cryptsetup_options} 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.${mkfs_options} /dev/mapper/home
mkdir /mnt/home
message 'Mounting /home..'
mount -o nodev,nosuid -t "$fstype" /dev/mapper/home /mnt/home
else
message 'Formatting /home..'
mkfs.${mkfs_options} "$dest_disk""$home_num"
mkdir /mnt/home
message 'Mounting /home..'
mount -o nodev,nosuid -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() {
message 'Installing xorg packages..'
pacman_install xorg-server xorg-server-utils xorg-xinit
configure_system() {
message 'Configuring system..'
if [[ "$manual_part" = 'yes' ]]; then
# crypttab
# check if there are any encrypted containers opened before editing crypttab
if [[ "$edit_conf" = 'yes' && -n "$(dmsetup ls --target crypt)" ]]; then
"$EDITOR" /mnt/etc/crypttab
clear
fi
# mdadm.conf
if [[ -e /proc/mdstat ]] && grep '^md' /proc/mdstat > /dev/null; then
mdadm -Ds >> /mnt/etc/mdadm.conf
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/mdadm.conf
clear
fi
fi
else
# crypttab
if [[ "$home" = 'yes' && "$encrypt_home" = 'yes' ]]; then
local home_uuid=$(lsblk -dno UUID "$dest_disk""$home_num")
printf '%s\n' "home UUID=${home_uuid} none luks,timeout=60s" >> /mnt/etc/crypttab
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/crypttab
clear
fi
fi
fi
# fstab
genfstab -U -p /mnt > /mnt/etc/fstab
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/fstab
clear
fi
# locale
[[ "$locale" = 'en_US.UTF-8 UTF-8' ]] || printf '%s\n' 'en_US.UTF-8 UTF-8' >> /mnt/etc/locale.gen
printf '%s\n' "$locale" >> /mnt/etc/locale.gen
printf '%s\n' "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 --adjfile=/mnt/etc/adjtime -w --"$hardware_clock"
# kernel modules
if [[ "$configure_modules" = 'yes' ]]; then
for m in ${k_modules[@]}; do
printf '%s\n' "$m" >> /mnt/etc/modules-load.d/modules.conf
done
fi
# hostname
printf '%s\n' "$hostname" > /mnt/etc/hostname
sed -i '/^127.0.0.1/ s/$/\t'"$hostname"'/' /mnt/etc/hosts
# network service
if [[ "$network" != 'no' ]]; then
## fix wired network interface name to eth0
touch /mnt/etc/udev/rules.d/80-net-setup-link.rules
case "$network" in
dhcpcd) systemctl -q --root=/mnt enable [email protected];;
ifplugd)
pacman_install ifplugd
systemctl -q --root=/mnt enable [email protected];;
netctl) cp ./"$netctl_profile" /mnt/etc/netctl
arch-chroot /mnt netctl enable "$netctl_profile";;
esac
fi
# mkinitcpio
if [[ "$configure_hooks" = 'yes' || "$edit_conf" = 'yes' ]]; then
cp /mnt/etc/mkinitcpio.conf /tmp/mkinitcpio.conf
if [[ "$configure_hooks" = 'yes' ]]; then
sed -i '/^HOOKS="/ c \HOOKS="'"$hooks"'"' /mnt/etc/mkinitcpio.conf
fi
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/mkinitcpio.conf
clear
fi
## 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
if [[ "$ask_root_password" = 'yes' ]]; then
message 'Setting password for root user..'
## loop if entered passwords do not match
while :; do
if passwd -R /mnt root; then
break
else
(( "$?" == 10 )) || break
fi
done
else
printf '%s\n' "root:${root_password}" | chpasswd -R /mnt
fi
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
if [[ "$ask_user_password" = 'yes' ]]; then
message "Setting password for ${username}.."
while :; do
if passwd -R /mnt "$username"; then
break
else
(( "$?" == 10 )) || break
fi
done
else
printf '%s\n' "${username}:${user_password}" | chpasswd -R /mnt
fi
fi
fi
}
install_bootloader() {
message 'Installing bootloader..'
if [[ "$uefi" = 'yes' ]]; then
# UEFI
if [[ "$bootloader" = 'grub' ]]; then
## install grub package
pacman_install dosfstools efibootmgr grub
## configure grub
if [[ "$manual_part" = 'yes' ]]; then
sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT="/ s/quiet/'"$cmdline"'/' \
/mnt/etc/default/grub
fi
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/default/grub
clear
fi
## run grub-mkconfig and grub-install
printf '%s\n' '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 package
pacman_install gummiboot
## run gummiboot install
arch-chroot /mnt gummiboot install
## configure gummiboot
cat << EOF > /mnt/boot/loader/loader.conf
default arch
timeout 5
EOF
if [[ "$manual_part" = 'no' ]]; then
local root_partuuid=$(lsblk -dno PARTUUID "$dest_disk""$root_num")
local cmdline="root=PARTUUID=${root_partuuid} rw"
fi
cat << EOF > /mnt/boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options ${cmdline}
EOF
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/boot/loader/entries/arch.conf
clear
fi
fi
else
# BIOS
if [[ "$bootloader" = 'syslinux' ]]; then
## install syslinux package
pacman_install gptfdisk syslinux
## run syslinux-install_update
arch-chroot /mnt syslinux-install_update -i -a -m
## configure syslinux
if [[ "$manual_part" = 'no' ]]; then
local root_partuuid=$(lsblk -dno PARTUUID "$dest_disk""$root_num")
local cmdline="root=PARTUUID=${root_partuuid} rw"
fi
cat << EOF > /mnt/boot/syslinux/syslinux.cfg
PROMPT 1
TIMEOUT 50
DEFAULT arch
LABEL arch
LINUX ../vmlinuz-linux
APPEND ${cmdline}
INITRD ../initramfs-linux.img
LABEL archfallback
LINUX ../vmlinuz-linux
APPEND ${cmdline}
INITRD ../initramfs-linux-fallback.img
EOF
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/boot/syslinux/syslinux.cfg
clear
fi
else
## install grub package
pacman_install grub
## configure grub
if [[ "$manual_part" = 'yes' ]]; then
sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT="/ s/quiet/'"$cmdline"'/' \
/mnt/etc/default/grub
fi
if [[ "$edit_conf" = 'yes' ]]; then
"$EDITOR" /mnt/etc/default/grub
clear
fi
## run grub-mkconfig and grub-install
printf '%s\n' "grub-mkconfig -o /boot/grub/grub.cfg; grub-install \
--target=i386-pc --recheck ${dest_disk}" | arch-chroot /mnt
fi
fi
}
# }}}
# parse commandline
# {{{
if (( "$#" > 0 )); then
(( "$#" > 1 )) && fail 'too many arguments'
if [[ "$1" = '-v' || "$1" = '--version' ]]; then
cat << EOF
archinstaller ${VERSION}
Copyright (C) 2014 Dennis Anfossi, Lukas B.
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 & Lukas B.
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
# }}}
# test requirements
# {{{
# check root user id
[[ "$EUID" = '0' ]] || fail 'please run as root user'
# check arch linux
[[ -e /etc/arch-release ]] || fail 'please run on arch linux'
# arch-install-scripts required
type pacstrap > /dev/null || fail 'missing package: arch-install-scripts'
# gdisk required
type gdisk > /dev/null || fail 'missing package: gptfdisk'
# }}}
# set defaults
# {{{
confirm='yes'
edit_conf='yes'
unmount='yes'
manual_part='no'
esp_size='512M'
boot_size='128M'
cryptsetup_options='-qy -c aes-xts-plain64 -h sha1 -s 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)"
printf "$RED"
cat << EOF
---------------------------------------
archinstaller ${VERSION}
---------------------------------------
EOF
printf "$ALL_OFF"
# 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
printf "$RED"
printf '%s\n' '| Checking internet connection..'
curl -f --retry 3 -m 10 -o /dev/null -s http://mirrors.kernel.org ||
fail 'please check the internet connection'
printf "$GREEN"
printf '%s\n' '| OK.'
printf "$ALL_OFF"
# check mirror status
if [[ "$mirror" != 'keep' ]]; then
curl -f --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'
printf '%s\n' "$mirror" > /etc/pacman.d/mirrorlist
fi
# pacstrap base packages
message 'Installing base system..'
pacstrap /mnt base
# install xorg packages
[[ "$xorg" = 'yes' ]] && install_xorg
######noob experience
#!/bin/bash
##
####
clear
echo "Starting. . .
Premere un tasto per continuare oppure \"e\" per uscire"
read -n1 a
a=`echo $a | tr '[A-Z]' '[a-z]'`
if [ "$a" = "e" ]; then
clear
exit 0
fi
######00######
clear
echo"Scegliere su che ambiente andremo ad operare:
1.Home Desktop / Workstation
2.Pentesting
Scegliendo 1, avrete la possibilità di costruire il vostro ambiente desktop archlinux
Scegliendo 2, avrete la posiibilità di installare BlackArch
Digitare scelta e poi premere invio"
read scelta
case $scelta in
'1') echo""
;;
'2') echo " è stato scelto di installare BlackArch, premere invio per continuare"
curl -O http://blackarch.org/strap.sh
./strap.sh
exit 0
;;
esac
clear
##### 11 #######
clear
echo "INSTALLARE DRIVER SCHEDA VIDEO---------------11
E' indispensabile l'installazione di un driver per la scheda video se si vuole usare l'interfaccia grafica. Potete installare i soli driver della scheda che possiedi.
L'installazione della scheda video può creare problemi (soprattutto con ATI e SIS), leggere in caso di problemi il wiki di arch
ATTENZIONE:Per installare i driver proprietari,è necessario un procedimento più complesso rispetto a quelli liberi.Per questo ora si potranno installare solo i liberi
(ad eccezione dei driver nvidia per le serie GeForce 6 e superiori).Per installare i proprietari,in caso di bisogno,consultare il wiki di Arch dopo l'installazione.
1) per scheda video intel (liberi)
2) per scheda video ATI (liberi)
3) per scheda video Nvidia (liberi)
4) per scheda video Nvidia (proprietari.ATTENZIONE:SOLO serie GeForce 6 e superiori [NV40 e nuovi] )
5) per scheda video SIS (supporto incerto)
6) per scheda video savage
INFORMAZIONI AVANZATE
Verranno installati i seguenti pacchetti:
1)'xf86-video-intel' e 'lib32-intel-dri'
2)'xf86-video-ati' e 'lib32-ati-dri'
3)'xf86-video-nouveau' e 'lib32-nouveau-dri'
4)'nvidia' e 'lib32-nvidia-utils'
5)'xf86-video-sis'
6)'xf86-video-savage'
Digitare il numero corrispondente all'alternativa scelta e Premere invio per installarla oppure Premere \"j\" e \"invio\"
per saltare questo passaggio "
read scelta
case $scelta in
#installazione dei vari driver
'1')
pacman -S xf86-video-intel --needed
pacman -S lib32-intel-dri --needed
echo ""
;;
'2')
pacman -S xf86-video-ati --needed
pacman -S lib32-ati-dri --needed
echo ""
;;
'3')
pacman -S xf86-video-nouveau --needed
pacman -S lib32-nouveau-dri --needed
echo ""
;;
'4')
pacman -S nvidia --needed
pacman -S lib32-nvidia-utils --needed
echo ""
;;
'5')
pacman -S xf86-video-sis --needed
echo ""
;;
'6')
pacman -S xf86-video-savage --needed
echo ""
;;
'j')
echo ""
;;
*)
echo ""
;;
esac
read -p "Premere invio per continuare"
##### 12 #######
clear
echo "INSTALLARE DRIVER TOUCHPAD E CONFIGURARE TOUCHPAD---------------12
Il computer è dotato di touchpad? Occorre installare synaptics.
1)Installare synaptics
2)Installare synaptic e abilitare lo scrolling verticale del touchpad
In questo modo potrai usare il touchpad e,se hai scelto l'alternativa 2 e se il tuo touchpad lo supporta, lo scrolling verticale del touchpad
INFORMAZIONI AVANZATE
Verrà installato il pacchetto 'synaptics' e , nel caso della scelta '2', verranno aggiunte delle strinche a /etc/X11/xorg.conf.d/10-synaptics.conf
Digitare il numero corrispondente all'alternativa scelta e Premere invio per installarla oppure Premere \"j\" e \"invio\"
per saltare questo passaggio "
read scelta
case $scelta in
'1')
pacman -S xf86-input-synaptics --needed #installazione di synaptics
echo ""
;;
'2')
pacman -S xf86-input-synaptics --needed
echo "Section \"InputClass\"
Identifier \"touchpad catchall\"
Driver \"synaptics\"
MatchIsTouchpad \"on\"
MatchDevicePath \"/dev/input/event*\"
Option \"TapButton1\" \"1\"
Option \"TapButton2\" \"2\"
Option \"TapButton3\" \"3\"
Option \"VertEdgeScroll\" \"on\"
EndSection" | tee /etc/X11/xorg.conf.d/10-synaptics.conf #abilitazone dello scrolling verticale
echo ""
;;
'j')
echo ""
;;
*)
echo ""
;;
esac
read -p "Premere invio per continuare"
######### 13 ########
clear
echo "INSTALLARE YAOURT---------13
Vuoi installare Yaourt per la gestione dei pacchetti presenti in AUR?
AUR (Arch User Repository) è un repository gestito dagli utenti,non ufficiale, (simile ai ppa di ubuntu)
Grazie a yaourt si potranno installare facilmente pacchetti presenti in quel repository.
Da ora in poi,lo script si comporterà come se yaourt fosse installato.Se si salta questo passaggio,non si potranno eseguire diverse parti dello script.
INFORMAZIONI AVANZATE
Verrà aggiunto il repo 'archlinuxfr' a /etc/pacman.conf e da li sarà installato il pacchetto 'yaourt'
Premere un tasto per continuare oppure \"j\" per saltare il passaggio."
read -n1 a
a=`echo $a | tr '[A-Z]' '[a-z]'`
if [ "$a" != "j" ]; then
echo "
[archlinuxfr]
Server = http://repo.archlinux.fr/\$arch" | tee -a /etc/pacman.conf #Aggiunta del repo "archlinuxfr"
pacman -Syy #aggiornamento repository
pacman -S yaourt --needed #installazione di yaourt
read -p "Premere un tasto per continuare"
fi
############## AVVISO ####################
clear
echo "AVVISO
D'ora in poi,spesso verrà usato il tool 'yaourt' per scaricare e installare da AUR.
L'opzione '--noconfirm'permette di evitare le moltissime richieste di conferma da parte di yaourt,che talvolta sono davvero fastidiose.
Mettere l'opzione --noconfirm quindi aumenta notevolmente la comodità di yaourt, ma va contro i principi 'K.I.S.S.' di Arch,in quanto non permette di modificare i file di installazione dei vari tool al momento del download (cosa necessaria un numero irrisorio di volte,comunque).
Si è scelto quindi di far scegliere all'utente se usare tale opzione o meno ,in tutti i passaggi.
Quando sarà possibile usare l'opzione \"noconfirm\",verrete avvisati.Sarà necessario aggiungere 'a' alla scelta, ad esempio '1a'
ATTENZIONE: gli apici (' ') NON vanno messi.Quindi non si digiterà \"'1a'\" ma \"1a\" (senza gli apici).Gli apici sono usati quindi solo per evidenziare delle parti del testo e NON vanno digitati.
Premere un tasto per continuare."
read -n1 a
a=`echo $a | tr '[A-Z]' '[a-z]'`
if [ "$a" != "j" ]; then
echo "
Grazie per l'attenzione"
read -p "Premere un tasto per continuare"
fi
####14 Scelta Desktop
clear
echo " Scegliere Ambiente Desktop
1.Xfce
2.KDE
3.Gnome
Digita scelta e premere invio."
read desktop
if [ $desktop = 1 ];
then
echo "Xfce è disponibile:
1.completo
2.medio
3.minimale
4.xfce core
INFORMAZIONI AGGIUNTIVE (pacchetti installati)
1.completo: xfce4 gnome-icon-theme fortune-mod dbus gamin xfce4-goodies gvfs gvfs-afc thunar-volman #2
2.medio: xfce4 gnome-icon-theme fortune-mod dbus gamin gvfs gvfs-afc thunar-volman #1
3.minimale: xfce4
4.xfce-core: xfwm4 xfce4-panel xfdesktop thunar xfce4-session xfce4-settings xfce4-appfinder xfce-utils xfconf
I pacchetti 'gvfs gvfs-afc thunar-volman' provengono da AUR
Digitare un opzione e premere invio ....."
read subdesktop
case $subdesktop in
'1') pacman -S xfce4 gnome-icon-theme fortune-mod dbus gamin xfce4-goodies --needed
yaourt -S gvfs gvfs-afc thunar-volman --needed
echo "exec dbus-launch --exit-with-session startxfce4" | tee /home/${nome_utente}/.xinitrc
pacman -S slim archlinux-themes-slim --needed
systemctl enable slim.service #con "enable", i login manager vengono lanciati all'avvio del sistema in automatico.
echo ""
;;
'2') pacman -S xfce4 gnome-icon-theme fortune-mod dbus gamin --needed
yaourt -S gvfs gvfs-afc thunar-volman --needed
echo "exec dbus-launch --exit-with-session
startxfce4" | tee /home/${nome_utente}/.xinitrc
pacman -S slim archlinux-themes-slim --needed
systemctl enable slim.service #con "enable", i login manager vengono lanciati all'avvio del sistema in automatico.
echo ""
;;
'3') pacman -S xfce4 --needed
echo "exec dbus-launch --exit-with-session startxfce4" | tee /home/${nome_utente}/.xinitrc
echo ""
pacman -S slim archlinux-themes-slim --needed
systemctl enable slim.service #con "enable", i login manager vengono lanciati all'avvio del sistema in automatico.
echo ""
;;
'4') Pacman -S xfwm4 xfce4-panel xfdesktop thunar xfce4-session xfce4-settings xfce4-appfinder xfce-utils xfconf #i "core packages" di xfce
echo "exec dbus-launch --exit-with-session startxfce4" | tee /home/${nome_utente}/.xinitrc
pacman -S slim archlinux-themes-slim --needed
systemctl enable slim.service #con "enable", i login manager vengono lanciati all'avvio del sistema in automatico.
echo ""
;;
'j')
echo ""
;;
*)
echo ""
;;
esac
read -p "Premere invio per continuare"
elif [ $desktop = 2 ];
then
echo"Kde è disponibile