4
GPROBE="/usr/sbin/grub-probe"
5
NEW_GPROBE="${GPROBE}.new"
6
OLD_GPROBE="${GPROBE}.old"
8
cat <<"PSUEDO_GRUB_PROBE" > ${NEW_GPROBE}
12
Usage: euca-psuedo-grub-probe
13
this is a wrapper around grub-probe to provide the answers for an ec2 guest
16
bad_Usage() { Usage 1>&2; fail "$@"; }
19
long_opts="device-map:,target:,device"
20
getopt_out=$(getopt --name "${0##*/}" \
21
--options "${short_opts}" --long "${long_opts}" -- "$@") &&
22
eval set -- "${getopt_out}" ||
30
while [ $# -ne 0 ]; do
33
--device-map) device_map=${next}; shift;;
35
--target) target=${next}; shift;;
42
case "${target}:${device}:${arg}" in
43
device:*:/*) echo "/dev/sda1"; exit 0;;
44
fs:*:*) echo "ext2"; exit 0;;
46
# older versions of grub (lucid) want 'part_msdos' written
49
grubver=$(dpkg-query --show --showformat '${Version}\n' grub-pc 2>/dev/null) &&
50
dpkg --compare-versions "${grubver}" lt 1.98+20100804-5ubuntu3 &&
52
echo "${legacy_pre}msdos";
54
abstraction:*:*) echo ""; exit 0;;
55
abstraction:*:*) echo ""; exit 0;;
56
drive:*:/dev/sda) echo "(hd0)";;
57
drive:*:/dev/sda*) echo "(hd0,1)";;
64
mv ${GPROBE} ${OLD_GPROBE}
65
mv ${NEW_GPROBE} ${GPROBE}
68
# modify default linux command line for serial console output
69
# change GRUB_CMDLINE_LINUX_DEFAULT="quite splash"
70
# to GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"
71
opt="GRUB_CMDLINE_LINUX_DEFAULT"
72
defstr="console=ttyS0"
73
sed -i "s/\(${opt}=\".*\"\)$/${opt}=\"${defstr}\"/" \
74
"${rootd}/etc/default/grub"
76
# make the debconf values match those stored in /etc/default/grub
77
# above. This means that the user isn't prompted for a merge on
78
# a dpkg-reconfigure grub-pc
79
printf "%s\t%s\t%s\t%s\n%s\t%s\t%s\t%s\n" \
80
grub-pc grub2/linux_cmdline_default string "${defstr}" \
81
grub-pc grub2/linux_cmdline string " " |
82
sudo debconf-set-selections
85
sudo grub-install --grub-setup=/bin/true /dev/sda && /usr/sbin/update-grub
87
mv ${OLD_GPROBE} ${GPROBE}