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 (( $# >= 2 )) ||
{ echo "error: need 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 CLASS_TWO_DISK
=true
43 export LUKS_DIR
=/root
/luks
44 export HOSTNAME
=$hostname
46 chmod +x partition.DEFAULT
48 export PARTITION_PROMPT
=true
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 sed -ri "/^crypt_dev_\S+$rootn /d" /tmp
/fai
/crypttab
74 if ! $already_partitioned; then
75 mount
-o subvol
=root_
$DISTRO $ROOT_PARTITION /mnt
76 mkdir
-p /mnt
/{q
,home
,boot
}
77 mount
-o subvol
=q
$ROOT_PARTITION /mnt
/q
78 mount
-o subvol
=home_
$DISTRO $ROOT_PARTITION /mnt
/home
79 mount
-o subvol
=boot_
$DISTRO $BOOT_PARTITION /mnt
/boot
82 # https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Keyfiles
83 cp /root
/luks
/host-
$hostname /mnt
/crypto_keyfile.bin
84 chmod 600 /mnt
/crypto_keyfile.bin
89 # todo: these hosts are broken, not updated to new fai hyrbrid scripts.
92 # for this system, no separate /boot, to keep partitions simple,
93 # since we want simpler backup recovery.
97 mount
/dev
/mapper
/vg_treetowl00-lv02
/mnt
98 mount
-U $bootid /mnt
/boot
101 rm -rf /mnt
/!(a|i|q|f|boot
) /mnt
/boot
/*
107 if [[ $mirror ]]; then
108 echo "$0: 404 errors about core.db etc are normal,
109 they will succeed using the secodary mirror"
112 cp /tmp
/fai
/{fstab
,crypttab
} /mnt
/etc
113 cp /usr
/bin
/devbyid
/mnt
/root
116 # the root .ssh needs to be like this,
117 # because it\'s used to get the key to mount an encrypted filesystem
120 rm -rf $d # for idempotency
122 scp
-oStrictHostKeyChecking=no ian@treetowl
:/a
/c
/machine_specific
/frodo
/subdir_files
/.ssh
/* $d
124 ln -s /q
/root
/.
ssh /mnt
/root
125 # background: errors=remount-ro is a debian installer thing. seems like
126 # not a bad idea. man mount says: The default is set in the filesystem
127 # superblock, and can be changed using tune2fs(8)
129 cat > /mnt
/etc
/fstab
<<'EOF'
130 UUID=e9ce7b46-9a21-4e79-b7f7-0b18acb57587 / ext4 noatime,errors=remount-ro 0 1
131 UUID=dd67766f-93c5-4ce3-9877-a1d9841dd4a4 none swap sw 0 0
132 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
133 /dev/mapper/crypta7 /mnt/btrfs_root btrfs subvolid=0,noatime,noauto 0 2
134 /dev/mapper/crypta7 /a btrfs subvol=a,noatime,noauto 0 2
139 cp -r /root
/distro-install-common
/mnt
/root
142 echo "UUID=a9e83bb7-d23d-4de6-ba9f-d88b887f7206 /a ext4 noatime 0 2" >> /mnt
/etc
/fstab
146 cp /root
/arch-init-chroot
/mnt
/root
147 # for manual commands, arch-chroot /mnt bash
148 arch-chroot
/mnt
/root
/arch-init-chroot
150 # this gets mounted in chroot so we have to do it outside
151 rm -f /mnt
/etc
/resolv.conf
152 ln -s /run
/systemd
/resolve
/resolv.conf
/mnt
/etc
/resolv.conf
154 # not necsesary, but makes reboot go fast.
155 umount
-R /mnt
; sleep 1
157 # causes 255 exit code, so doing this from the caller script.