lots: shellcheck, streaming stuff, fixes
[distro-setup] / zboot
diff --git a/zboot b/zboot
index 3a0a46a74b33be8da8b6ceb4e53b05db326b1966..082afb5b4e03f5cff318637a7b0e6c276823d13a 100755 (executable)
--- a/zboot
+++ b/zboot
@@ -1,9 +1,8 @@
 #!/bin/bash
 
-script=$(readlink -f -- "$BASH_SOURCE")
-[[ $EUID == 0 ]] || exec sudo -E "$script" "$@"
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 
-source /usr/local/lib/err
+set -e; . /usr/local/lib/bash-bear; set +e
 
 
 # Explaining this whole thing. The host amy is used by someone else,
@@ -19,6 +18,11 @@ source /usr/local/lib/err
 
 set -x
 
+if [[ ! -e /mnt/root/root2-fstab || ! -e /mnt/root/root2-crypttab ]]; then
+  echo $0: "error: create /mnt/root/root2-fstab & /mnt/root/root2-crypttab from running /a/bin/fai/fai/config/hooks/partition.DEFAULT mkroot2 or mkroot2tab"
+  exit 1
+fi
+
 mount -o bind /mnt/root2/root_ubuntubionic /mnt/1
 cd /mnt/1
 /b/ds/gen-amy-fstab ubuntubionic .
@@ -28,7 +32,7 @@ mount -o bind /dev dev
 mount -o bind /proc proc
 mount -o bind /sys sys
 mkdir -p boot/efi
-mount $(awk '$2 == "/boot/efi" {print $1}' /etc/mtab) boot/efi
+mount "$(awk '$2 == "/boot/efi" {print $1}' /etc/mtab)" boot/efi
 
 cp /b/ds/zboot-chroot ./root