Compare commits

..

1 Commits

Author SHA1 Message Date
cef71d557a testing 2022-11-27 15:56:41 -05:00

View File

@ -95,14 +95,6 @@ function create_root_pool () {
rpool "$2"
}
function mirror_grub () {
umount /boot/efi
dd if="${1}-part2" of="${2}-part2"
efibootmgr -c -g -d "$2" -p 2 \
-L "debian-${3}" -l '\EFI\debian\grubx64.efi'
mount /boot/efi
}
################
### Settings ###
################
@ -111,9 +103,8 @@ export DEBIAN_FRONTEND=noninteractive
CODENAME="bullseye"
# Options
while getopts ':gm:p:P:r:' OPTION; do
while getopts ':m:p:P:r:' OPTION; do
case "$OPTION" in
g) GRUB_MIRROR="true";;
m) MIRROR="$OPTARG";;
p) ROOTPW="$OPTARG";;
P) RPOOLPW="$OPTARG";;
@ -129,24 +120,6 @@ shift "$((OPTIND -1))"
DISK=$1
ZFSHOST=$2
# Post-boot grub mirror?
if [ "$GRUB_MIRROR" == "true" ]; then
while true; do
echo -e "ORIGINAL GRUB: $DISK\nMIRROR TO: $MIRROR"
read -r -p "Would you like to mirror GRUB? [y/N]: " yn
case $yn in
[Yy]*)
disk_check "$DISK"
disk_check "$MIRROR"
mirror_grub "$DISK" "$MIRROR" 2
exit 0;;
?)
echo "ABORTED: User did not confirm mirroring"
exit 1;;
esac
done
fi
# Verify variables
[ -z "$ZFSROOT" ] && ZFSROOT="/mnt"
@ -330,22 +303,6 @@ EOF
# Copy DISK/MIRROR vars under ZFSROOT
echo -e "DISK=${DISK}\nROOTPW=${ROOTPW}" > "$ZFSROOT/var/tmp/zfsenv"
# Copy self and GRUB mirror helper script into chroot
if [ -n "$MIRROR" ]; then
cp "$0" "$ZFSROOT/usr/local/bin/debianzfs"
chmod u+x "$ZFSROOT/usr/local/bin/debianzfs"
DDIF=$(find /dev/disk/by-id -lname ../../"$(basename "$DISK")" | tail -n1)
DDOF=$(find /dev/disk/by-id -lname ../../"$(basename "$MIRROR")" | tail -n1)
HELPER_SCRIPT="/root/MIRROR_GRUB_POSTINSTALL.sh"
cat <<-GRUBMIRROR > "${ZFSROOT}${HELPER_SCRIPT}"
#!/bin/bash
# Post-install GRUB mirror helper script
/usr/local/bin/debianzfs \
-gm $DDOF \
$DDIF
GRUBMIRROR
fi
# Bind
mount --make-private --rbind /dev /mnt/dev
mount --make-private --rbind /proc /mnt/proc
@ -480,6 +437,4 @@ mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | \
# 4. If this fails for rpool, mounting it on boot will fail and you will need to
# zpool import -f rpool, then exit in the initamfs prompt
zpool export -a || exit 0
[ -n "$HELPER_SCRIPT" ] && \
echo "NOTICE: A GRUB mirror helper script was placed at $HELPER_SCRIPT"
exit 0