File: grub

package info (click to toggle)
ganeti-instance-debootstrap 0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: sh: 488; makefile: 54
file content (58 lines) | stat: -rwxr-xr-x 1,220 bytes parent folder | download | duplicates (10)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/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
export DEBIAN_FRONTEND=noninteractive
chroot "$TARGET" apt-get -y --force-yes install grub grub-common

# make /dev/sda
mknod $TARGET/dev/sda b $(stat -L -c "0x%t 0x%T" $BLOCKDEV)
CLEANUP+=("rm -f $TARGET/dev/sda")

# make /dev/sda1
mknod $TARGET/dev/sda1 b $(stat -L -c "0x%t 0x%T" $FSYSDEV)
CLEANUP+=("rm -f $TARGET/dev/sda1")

# create grub directory
mkdir -p "$TARGET/boot/grub"

# create device.map
cat > "$TARGET/boot/grub/device.map" <<EOF
(hd0) /dev/sda
EOF

# execute update-grub
chroot "$TARGET" update-grub

# install grub to the block device
grub-install --no-floppy --root-directory="$TARGET" "$BLOCKDEV"

# execute cleanups
cleanup
trap - EXIT

exit 0