bunch of fixes, change sy host, deploy some new stuff
[distro-setup] / zboot-chroot
diff --git a/zboot-chroot b/zboot-chroot
new file mode 100755 (executable)
index 0000000..4411cc4
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+[[ $EUID == 0 ]] || exec sudo -E "$script" "$@"
+
+if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
+shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
+
+set -x
+
+apt install grub-efi
+
+# this is taken from partition.DEFAULT
+ssds=()
+for disk in $(lsblk -do name,tran -n | awk '$2 ~ "^(sata|nvme)$" { print $1 }'); do
+  case $(cat /sys/block/$disk/queue/rotational) in
+    0) ssds+=(/dev/$disk) ;;
+    1) : ;; # hdd
+    *) echo "$0: error: unknown /sys/block/$disk/queue/rotational: \
+$(cat $disk/queue/rotational)" ;;
+  esac
+done
+
+# this is from /a/bin/fai/fai/config/scripts/GRUB_EFI/10-setup
+GROOT=$(grub-probe -tdrive -d ${ssds[@]})
+echo "GROOT=$GROOT"
+grub-install --no-floppy --modules=part_gpt "$GROOT"
+update-grub
+update-initramfs -u