3 # see t.org for how to call
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
8 cd $
(dirname $
(readlink
-f "$BASH_SOURCE"))
10 ROOTPW
="$(cat /root/shadow/standard)"
14 TPPASS
="$(cat /root/shadow/traci-simple)"
16 if [[ $hostname == tp
]]; then
20 (( $# >= 1 )) ||
{ echo "$0: error: need 1 or 2 arguments"; exit 1; }
22 mv /root
/devbyid
/usr
/bin
24 rm -f /etc
/pacman.d
/mirrorlist
25 # https://wiki.archlinux.org/index.php/Mirrors#Sorting_mirrors
27 if [[ $mirror ]]; then
28 echo "Server = $mirror" >> /etc
/pacman.d
/mirrorlist
30 curl
-s 'https://www.archlinux.org/mirrorlist/?country=US&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' |
31 sed -r 's/^[ #]*(Server *=)/\1/' >> /etc
/pacman.d
/mirrorlist
33 # export class vars with CLASS_ in front to avoid name colissions.
35 local var
=${1/#/CLASS_}
36 [[ $hostname == $1 ||
${!var} ]]
39 for x
in $
(bash
50-host-classes); do
42 export LUKS_DIR
=/root
/luks
43 export HOSTNAME
=$hostname
45 chmod +x partition.DEFAULT
47 export PARTITION_PROMPT
=true
49 # to be idempotent if we fail after partitioning
50 already_partitioned
=true
52 for dir
in /mnt
{,/home
,/boot
,/q
}; do
54 if [[ ! $mount_out =~
$regex ]]; then
55 already_partitioned
=false
60 if ! $already_partitioned; then
64 .
/tmp
/fai
/disk_var.sh
67 # arch doesn't need crypttab entries for initramfs crypt partititions
72 export ROOT_PARTITIONS
73 sed -ri "/^crypt_dev_\S+$rootn /d" /tmp
/fai
/crypttab
75 if ! $already_partitioned; then
76 mount
-o subvol
=root_
$DISTRO $ROOT_PARTITION /mnt
77 mkdir
-p /mnt
/{q
,home
,boot
}
78 mount
-o subvol
=q
$ROOT_PARTITION /mnt
/q
79 mount
-o subvol
=home_
$DISTRO $ROOT_PARTITION /mnt
/home
80 mount
-o subvol
=boot_
$DISTRO $BOOT_PARTITION /mnt
/boot
83 # https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Keyfiles
84 cp /root
/luks
/host-
$hostname /mnt
/crypto_keyfile.bin
85 chmod 600 /mnt
/crypto_keyfile.bin
88 if [[ $mirror ]]; then
89 echo "$0: 404 errors about core.db etc are normal,
90 they will succeed using the secodary mirror"
93 cp /tmp
/fai
/{fstab
,crypttab
} /mnt
/etc
94 cp /root
/encrypt
/mnt
/usr
/lib
/initcpio
/hooks
96 #cp /usr/bin/devbyid /mnt/root
99 cp -r /root
/distro-install-common
/mnt
/root
100 mkdir
-p /mnt
/etc
/ssh
101 cp /etc
/ssh
/host_
* /mnt
/etc
/ssh
103 cp /root
/arch-init-chroot
/mnt
/root
104 # for manual commands, arch-chroot /mnt bash
105 arch-chroot
/mnt
/root
/arch-init-chroot
107 # this gets mounted in chroot so we have to do it outside
108 rm -f /mnt
/etc
/resolv.conf
109 ln -s /run
/systemd
/resolve
/resolv.conf
/mnt
/etc
/resolv.conf
111 # not necsesary, but makes reboot go fast.
112 #umount -R /mnt; sleep 1
114 # causes 255 exit code, so doing this from the caller script.