aboutsummaryrefslogtreecommitdiff
path: root/fai/config/scripts/GRUB_PC
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-09-19 22:38:13 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-09-19 22:42:12 +0200
commit6ecb19ada66d54cc0afeb3d27d89700473cde70a (patch)
treea3b57044b04aad7613757aa96697f4afa89c1b85 /fai/config/scripts/GRUB_PC
downloaddebian-edu-fai+itzks-6ecb19ada66d54cc0afeb3d27d89700473cde70a.tar.gz
debian-edu-fai+itzks-6ecb19ada66d54cc0afeb3d27d89700473cde70a.tar.bz2
debian-edu-fai+itzks-6ecb19ada66d54cc0afeb3d27d89700473cde70a.zip
initial draft of getting FAI install a Debian Edu system (profile: Minimal)
Diffstat (limited to 'fai/config/scripts/GRUB_PC')
-rwxr-xr-xfai/config/scripts/GRUB_PC/10-setup52
1 files changed, 52 insertions, 0 deletions
diff --git a/fai/config/scripts/GRUB_PC/10-setup b/fai/config/scripts/GRUB_PC/10-setup
new file mode 100755
index 0000000..5563275
--- /dev/null
+++ b/fai/config/scripts/GRUB_PC/10-setup
@@ -0,0 +1,52 @@
+#! /bin/bash
+# support for GRUB version 2
+
+error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
+
+set -a
+
+# do not set up grub during dirinstall
+if [ "$FAI_ACTION" = "dirinstall" ] ; then
+ exit 0
+fi
+# during softupdate use this file
+[ -r $LOGDIR/disk_var.sh ] && . $LOGDIR/disk_var.sh
+
+if [ -z "$BOOT_DEVICE" ]; then
+ exit 189
+fi
+
+# disable os-prober because of #788062
+ainsl /etc/default/grub 'GRUB_DISABLE_OS_PROBER=true'
+
+# skip the rest, if not an initial installation
+if [ $FAI_ACTION != "install" ]; then
+ $ROOTCMD update-grub
+ exit $error
+fi
+
+GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
+
+# handle /boot in lvm-on-md
+_bdev=$(readlink -f $BOOT_DEVICE)
+if [ "${_bdev%%-*}" = "/dev/dm" ]; then
+ BOOT_DEVICE=$( lvs --noheadings -o devices $BOOT_DEVICE | sed -e 's/^*\([^(]*\)(.*$/\1/' )
+fi
+
+# Check if RAID is used for the boot device
+if [[ $BOOT_DEVICE =~ '/dev/md' ]]; then
+ raiddev=${BOOT_DEVICE#/dev/}
+ # install grub on all members of RAID
+ for device in `LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat`; do
+ echo Install grub on /dev/$device
+ $ROOTCMD grub-install --no-floppy "/dev/$device"
+ done
+else
+ $ROOTCMD grub-install --no-floppy "$GROOT"
+ if [ $? -eq 0 ]; then
+ echo "Grub installed on $BOOT_DEVICE = $GROOT"
+ fi
+fi
+$ROOTCMD update-grub
+
+exit $error