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"))
12 TPPASS
="$(cat /root/shadow/traci-simple)"
14 (( $# >= 1 )) ||
{ echo "$0: error: need 1 or 2 arguments"; exit 1; }
16 mv /root
/devbyid
/usr
/bin
18 rm -f /etc
/pacman.d
/mirrorlist
19 # https://wiki.archlinux.org/index.php/Mirrors#Sorting_mirrors
21 if [[ $mirror ]]; then
22 echo "Server = $mirror" >> /etc
/pacman.d
/mirrorlist
24 curl
-s 'https://www.archlinux.org/mirrorlist/?country=US&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' |
25 sed -r 's/^[ #]*(Server *=)/\1/' >> /etc
/pacman.d
/mirrorlist
27 .
/a
/bin
/fai
/fai-wrapper
28 export LUKS_DIR
=/root
/luks
29 export HOSTNAME
=$hostname
31 partition_script
=/a
/bin
/fai
/fai
/config
/hooks
/partition.DEFAULT
32 chmod +x
$partition_script
34 export PARTITION_PROMPT
=true
36 # to be idempotent if we fail after partitioning
37 already_partitioned
=true
39 for dir
in /mnt
{,/home
,/boot
,/q
}; do
41 if [[ ! $mount_out =~
$regex ]]; then
42 already_partitioned
=false
47 if ! $already_partitioned; then
48 /a
/bin
/fai
/fai
/config
/hooks
/partition.DEFAULT
51 .
/tmp
/fai
/disk_var.sh
54 # arch doesn't need crypttab entries for initramfs crypt partititions
59 export ROOT_PARTITIONS
60 sed -ri "/^crypt_dev_\S+$rootn /d" /tmp
/fai
/crypttab
62 if ! $already_partitioned; then
63 mount
-o subvol
=root_
$DISTRO $ROOT_PARTITION /mnt
64 mkdir
-p /mnt
/{q
,home
,boot
}
65 mount
-o subvol
=q
$ROOT_PARTITION /mnt
/q
66 mount
-o subvol
=boot_
$DISTRO $BOOT_PARTITION /mnt
/boot
69 # https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Keyfiles
70 cp /root
/luks
/host-
$hostname /mnt
/crypto_keyfile.bin
71 chmod 600 /mnt
/crypto_keyfile.bin
74 if [[ $mirror ]]; then
75 echo "$0: 404 errors about core.db etc are normal,
76 they will succeed using the secodary mirror"
79 cp /tmp
/fai
/{fstab
,crypttab
} /mnt
/etc
80 cp /a
/bin
/fai
/encrypt
/mnt
/usr
/lib
/initcpio
/hooks
82 #cp /usr/bin/devbyid /mnt/root
84 cp -r /root
/.
ssh /mnt
/root
90 mount
-o bind $source $mountpoint
93 bindmount
/root
/shadow
/mnt
/q
/root
/shadow
96 cp /etc
/ssh
/ssh_host_
* /mnt
/etc
/ssh
98 cp /a
/bin
/fai
/arch-init-chroot
/mnt
/root
99 # for manual commands, arch-chroot /mnt bash
100 arch-chroot
/mnt
/root
/arch-init-chroot
102 # this gets mounted in chroot so we have to do it outside
103 rm -f /mnt
/etc
/resolv.conf
104 ln -s /run
/systemd
/resolve
/resolv.conf
/mnt
/etc
/resolv.conf
106 # not necsesary, but makes reboot go fast.
107 #umount -R /mnt; sleep 1
109 # causes 255 exit code, so doing this from the caller script.