source: npl/system/grub/syn3-install-grub @ 66e7a2c

perl-5.22
Last change on this file since 66e7a2c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#!/bin/bash
2#syn-3 grub installer (C)DatuX
3#Fully automaticly install grub in the MBR of all discs in /dev/md0
4
5
6#mount boot als hij nog niet gemount is
7mount /boot
8ERR=$?
9[ "$ERR" != "0" ] && [ "$ERR" != "32" ] && exit 1
10
11#kopieer eenmalig, zorg dat stage2 NOOIT meer veranderd
12#ivm secondary DRBD node!
13if ! [ -f /boot/grub/stage2 ]; then
14        mkdir /boot/grub &>/dev/null
15        cp -a /usr/lib/grub/i386-pc/* /boot/grub || exit 1
16fi
17
18#bepaal welke partities we hebben in onze boot raid array md0
19PARTS=`
20    mdadm --detail /dev/md0|
21    grep -v /dev/md0|
22    grep /dev|
23    sed 's#^[^/]*##g' #remove spaces
24` || exit 1
25
26
27#bepaal bijbehorende discs
28for PART in $PARTS; do
29        DISCS="$DISCS `getdisk $PART`"
30done
31
32#unmount boot, omdat grub de schijf rechstreeks benaderd
33umount /boot || exit 1
34
35#installeer grub
36touch /tmp/device.map
37ERROR=
38for DISC in $DISCS; do
39    echo "Installing grub on $DISC..."
40    echo -e "device (hd0) $DISC\nroot (hd0,0)\nsetup (hd0)\nquit" > /tmp/grub.$$
41    if ! grub --device-map=/tmp/device.map --batch < /tmp/grub.$$ ; then
42        echo error
43        ERROR=1
44    fi
45done
46rm /tmp/grub.$$
47
48#mount boot weer
49mount /boot || exit 1
50
51#default keuze is normaal 0
52grub-set-default 0 || exit 1
53
54[ "$ERROR" ] && exit 1
55
56exit 0
57
Note: See TracBrowser for help on using the repository browser.