File: 10-setup

package info (click to toggle)
fai 4.3.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,740 kB
  • sloc: perl: 5,115; sh: 4,272; makefile: 157
file content (44 lines) | stat: -rwxr-xr-x 1,208 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
# support for GRUB version 2

error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code

set -a
# during softupdate use this file
[ -r $LOGDIR/disk_var.sh ] && . $LOGDIR/disk_var.sh

[ -z "$BOOT_DEVICE" ]    && exit 701

$ROOTCMD update-grub

# skip the rest, if not an initial installation
if [ $FAI_ACTION != "install" ]; then
    exit $error
fi

# check if mdadm has been forgotten
if grep -q active /proc/mdstat 2>/dev/null; then
    if [ ! -d $target/etc/mdadm ]; then
	echo WARNING: Found Software RAID, but mdadm was not installed
    fi
fi

$ROOTCMD grub-mkdevicemap --no-floppy
GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)

# 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

exit $error