fix various arch issues
[automated-distro-installer] / arch-init
index d1c554268c3df48e39dafca3cbd0881443389436..a9e5d68c49c38e6f3e5771bd2bdfbb671101712e 100755 (executable)
--- a/arch-init
+++ b/arch-init
@@ -17,7 +17,7 @@ if [[ $hostname == tp ]]; then
     ROOTPW="$TPPASS"
 fi
 
-(( $# >= 2 )) || { echo "error: need 2 arguments"; exit 1; }
+(( $# >= 1 )) || { echo "$0: error: need 1 or 2 arguments"; exit 1; }
 
 mv /root/devbyid /usr/bin
 
@@ -39,7 +39,6 @@ export -f ifclass
 for x in $(bash 50-host-classes); do
     export CLASS_$x=true
 done
-export CLASS_TWO_DISK=true
 export LUKS_DIR=/root/luks
 export HOSTNAME=$hostname
 export DISTRO=arch
@@ -47,6 +46,7 @@ chmod +x partition.DEFAULT
 
 export PARTITION_PROMPT=true
 
+# to be idempotent if we fail after partitioning
 already_partitioned=true
 mount_out=$(mount)
 for dir in /mnt{,/home,/boot,/q}; do
@@ -69,6 +69,7 @@ export rootn=1
 export bootn=3
 export swapn=2
 export BOOT_DEVICE
+export ROOT_PARTITIONS
 sed -ri "/^crypt_dev_\S+$rootn /d" /tmp/fai/crypttab
 
 if ! $already_partitioned; then
@@ -84,64 +85,18 @@ cp /root/luks/host-$hostname /mnt/crypto_keyfile.bin
 chmod 600 /mnt/crypto_keyfile.bin
 
 
-shopt -s extglob
-case $hostname in
-    # todo: these hosts are broken, not updated to new fai hyrbrid scripts.
-    frodo)
-
-        # for this system, no separate /boot, to keep partitions simple,
-        # since we want simpler backup recovery.
-        mount -U $rootid /mnt
-        ;;&
-    treetowl)
-        mount /dev/mapper/vg_treetowl00-lv02 /mnt
-        mount -U $bootid /mnt/boot
-        ;;&
-    frodo|treetowl)
-        rm -rf /mnt/!(a|i|q|f|boot) /mnt/boot/*
-        ;;
-esac
-
-
-
 if [[ $mirror ]]; then
     echo "$0: 404 errors about core.db etc are normal,
 they will succeed using the secodary mirror"
 fi
 pacstrap /mnt base
 cp /tmp/fai/{fstab,crypttab} /mnt/etc
-cp /usr/bin/devbyid /mnt/root
-case $hostname in
-    frodo)
-        # the root .ssh needs to be like this,
-        # because it\'s used to get the key to mount an encrypted filesystem
-        # on top of itself.
-        d=/mnt/q/root/.ssh
-        rm -rf $d # for idempotency
-        mkdir -p $d
-        scp -oStrictHostKeyChecking=no ian@treetowl:/a/c/machine_specific/frodo/subdir_files/.ssh/* $d
-        cp .ssh/* $d
-        ln -s /q/root/.ssh /mnt/root
-        # background: errors=remount-ro is a debian installer thing. seems like
-        # not a bad idea. man mount says: The default is set in the filesystem
-        # superblock, and can be changed using tune2fs(8)
-
-        cat > /mnt/etc/fstab <<'EOF'
-UUID=e9ce7b46-9a21-4e79-b7f7-0b18acb57587  /  ext4  noatime,errors=remount-ro  0  1
-UUID=dd67766f-93c5-4ce3-9877-a1d9841dd4a4  none  swap  sw  0  0
-/dev/sr0  /media/cdrom0  udf,iso9660 user,noauto  0  0
-/dev/mapper/crypta7  /mnt/btrfs_root  btrfs  subvolid=0,noatime,noauto  0  2
-/dev/mapper/crypta7  /a  btrfs  subvol=a,noatime,noauto  0  2
-EOF
-        ;;
-    *)
-        cp -r .ssh /mnt/root
-        cp -r /root/distro-install-common /mnt/root
-        ;;&
-    treetowl)
-        echo "UUID=a9e83bb7-d23d-4de6-ba9f-d88b887f7206  /a  ext4  noatime  0 2" >> /mnt/etc/fstab
-        ;;
-esac
+cp /root/encrypt /mnt/usr/lib/initcpio/hooks
+# not needed anymore
+#cp /usr/bin/devbyid /mnt/root
+
+cp -r .ssh /mnt/root
+cp -r /root/distro-install-common /mnt/root
 
 cp /root/arch-init-chroot /mnt/root
 # for manual commands, arch-chroot /mnt bash
@@ -152,7 +107,7 @@ rm -f /mnt/etc/resolv.conf
 ln -s /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
 
 # not necsesary, but makes reboot go fast.
-umount -R /mnt; sleep 1
+#umount -R /mnt; sleep 1
 
 # causes 255 exit code, so doing this from the caller script.
 # reboot now