58 lines
1.4 KiB
Bash
Executable File
58 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This is an example script that install and configure grub after installation.
|
|
# To use it put it in your CUSTOMIZE_DIR and make it executable.
|
|
#
|
|
# Do not include grub in EXTRA_PKGS of
|
|
# $sysconfdir/default/ganeti-instance-debootstrap because it will
|
|
# cause error of debootstrap.
|
|
|
|
set -e
|
|
|
|
. common.sh
|
|
|
|
CLEANUP=( )
|
|
|
|
trap cleanup EXIT
|
|
|
|
if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
|
|
echo "Missing target directory"
|
|
exit 1
|
|
fi
|
|
|
|
# install grub
|
|
export LANG=C
|
|
if [ "$PROXY" ]; then
|
|
export http_proxy="$PROXY"
|
|
export https_proxy="$PROXY"
|
|
fi
|
|
|
|
umount_sys_fuse()
|
|
{
|
|
umount $TARGET/sys/fs/fuse/connections 2>/dev/null || true
|
|
}
|
|
|
|
mount --bind /dev $TARGET/dev
|
|
CLEANUP+=("umount $TARGET/dev")
|
|
mount --bind /proc $TARGET/proc
|
|
CLEANUP+=("umount $TARGET/proc")
|
|
mount --bind /sys $TARGET/sys
|
|
CLEANUP+=("umount $TARGET/sys")
|
|
CLEANUP+=("umount_sys_fuse")
|
|
|
|
DEBIAN_FRONTEND=noninteractive chroot "$TARGET" apt-get -y install grub-pc grub-common
|
|
|
|
echo "(hd0) $BLOCKDEV" > $TARGET/boot/grub/device.map
|
|
CLEANUP+=("rm $TARGET/boot/grub/device.map")
|
|
|
|
chroot "$TARGET" sed -Ei 's/^(GRUB_CMDLINE_LINUX=\".*)\"$/\1 net.ifnames=0"/' /etc/default/grub
|
|
chroot "$TARGET" grub-install "(hd0)"
|
|
GRUB_DISABLE_OS_PROBER=true chroot "$TARGET" update-grub
|
|
echo 'grub-pc grub-pc/install_devices multiselect /dev/xvda' | chroot "$TARGET" debconf-set-selections
|
|
|
|
# execute cleanups
|
|
cleanup
|
|
trap - EXIT
|
|
|
|
exit 0
|