main fai scripts can run outside of fai, fixup stuff
[automated-distro-installer] / arch-init
index af649b2676640c481a7aed76836194f41842ae52..007780771eeb2a08bdb0ea33f71379a35712980e 100755 (executable)
--- a/arch-init
+++ b/arch-init
@@ -7,15 +7,9 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 cd $(dirname $(readlink -f "$BASH_SOURCE"))
 
-ROOTPW="$(cat /root/shadow/standard)"
-export ROOTPW
 export hostname="$1"
 mirror=$2
 TPPASS="$(cat /root/shadow/traci-simple)"
-export TPPASS
-if [[ $hostname == tp ]]; then
-    ROOTPW="$TPPASS"
-fi
 
 (( $# >= 1 )) || { echo "$0: error: need 1 or 2 arguments"; exit 1; }
 
@@ -30,19 +24,12 @@ fi
 curl -s 'https://www.archlinux.org/mirrorlist/?country=US&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' |
     sed -r 's/^[ #]*(Server *=)/\1/' >> /etc/pacman.d/mirrorlist
 
-# export class vars with CLASS_ in front to avoid name colissions.
-ifclass() {
-    local var=${1/#/CLASS_}
-    [[ $hostname == $1 || ${!var} ]]
-}
-export -f ifclass
-for x in $(bash 50-host-classes); do
-    export CLASS_$x=true
-done
+. /a/bin/fai/fai-wrapper
 export LUKS_DIR=/root/luks
 export HOSTNAME=$hostname
 export DISTRO=arch
-chmod +x partition.DEFAULT
+partition_script=/a/bin/fai/fai/config/hooks/partition.DEFAULT
+chmod +x $partition_script
 
 export PARTITION_PROMPT=true
 
@@ -58,7 +45,7 @@ for dir in /mnt{,/home,/boot,/q}; do
 done
 
 if ! $already_partitioned; then
-    ./partition.DEFAULT
+    /a/bin/fai/fai/config/hooks/partition.DEFAULT
 fi
 
 . /tmp/fai/disk_var.sh
@@ -76,7 +63,6 @@ if ! $already_partitioned; then
     mount -o subvol=root_$DISTRO $ROOT_PARTITION /mnt
     mkdir -p /mnt/{q,home,boot}
     mount -o subvol=q $ROOT_PARTITION /mnt/q
-    mount -o subvol=home_$DISTRO $ROOT_PARTITION /mnt/home
     mount -o subvol=boot_$DISTRO $BOOT_PARTITION /mnt/boot
 fi
 
@@ -91,16 +77,25 @@ they will succeed using the secodary mirror"
 fi
 pacstrap /mnt base
 cp /tmp/fai/{fstab,crypttab} /mnt/etc
-cp /root/encrypt /mnt/usr/lib/initcpio/hooks
+cp /a/bin/fai/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 -r /root/.ssh /mnt/root
+
+bindmount() {
+    local mountpoint=$2
+    local source=$1
+    mkdir -p $mountpoint
+    mount -o bind $source $mountpoint
+}
+bindmount /a /mnt/a
+bindmount /root/shadow /mnt/q/root/shadow
+
 mkdir -p /mnt/etc/ssh
-cp /etc/ssh/host_* /mnt/etc/ssh
+cp /etc/ssh/ssh_host_* /mnt/etc/ssh
 
-cp /root/arch-init-chroot /mnt/root
+cp /a/bin/fai/arch-init-chroot /mnt/root
 # for manual commands, arch-chroot /mnt bash
 arch-chroot /mnt /root/arch-init-chroot