todo comment
[distro-setup] / zboot-chroot
1 #!/bin/bash
2
3 [[ $EUID == 0 ]] || exec sudo -E "$script" "$@"
4
5 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
6 shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
7 set -eE -o pipefail
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
9
10 set -x
11
12 apt install grub-efi
13
14 # this is taken from partition.DEFAULT
15 ssds=()
16 for disk in $(lsblk -do name,tran -n | awk '$2 ~ "^(sata|nvme)$" { print $1 }'); do
17 case $(cat /sys/block/$disk/queue/rotational) in
18 0) ssds+=(/dev/$disk) ;;
19 1) : ;; # hdd
20 *) echo "$0: error: unknown /sys/block/$disk/queue/rotational: \
21 $(cat $disk/queue/rotational)" ;;
22 esac
23 done
24
25 # this is from /a/bin/fai/fai/config/scripts/GRUB_EFI/10-setup
26 GROOT=$(grub-probe -tdrive -d ${ssds[@]})
27 echo "GROOT=$GROOT"
28 grub-install --no-floppy --modules=part_gpt "$GROOT"
29 update-grub
30 update-initramfs -u