#!/bin/bash #syn-3 grub installer (C)DatuX #Fully automaticly install grub in the MBR of all discs in /dev/md0 #mount boot als hij nog niet gemount is mount /boot ERR=$? [ "$ERR" != "0" ] && [ "$ERR" != "32" ] && exit 1 #kopieer eenmalig, zorg dat stage2 NOOIT meer veranderd #ivm secondary DRBD node! if ! [ -f /boot/grub/stage2 ]; then mkdir /boot/grub &>/dev/null cp -a /usr/lib/grub/i386-pc/* /boot/grub || exit 1 fi #bepaal welke partities we hebben in onze boot raid array md0 PARTS=` mdadm --detail /dev/md0| grep -v /dev/md0| grep /dev| sed 's#^[^/]*##g' #remove spaces ` || exit 1 #bepaal bijbehorende discs for PART in $PARTS; do DISCS="$DISCS `getdisk $PART`" done #unmount boot, omdat grub de schijf rechstreeks benaderd umount /boot || exit 1 #installeer grub touch /tmp/device.map ERROR= for DISC in $DISCS; do echo "Installing grub on $DISC..." echo -e "device (hd0) $DISC\nroot (hd0,0)\nsetup (hd0)\nquit" > /tmp/grub.$$ if ! grub --device-map=/tmp/device.map --batch < /tmp/grub.$$ ; then echo error ERROR=1 fi done rm /tmp/grub.$$ #mount boot weer mount /boot || exit 1 #default keuze is normaal 0 grub-set-default 0 || exit 1 [ "$ERROR" ] && exit 1 exit 0