summaryrefslogtreecommitdiff
path: root/scripts/grub-setup
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/grub-setup')
-rwxr-xr-xscripts/grub-setup68
1 files changed, 38 insertions, 30 deletions
diff --git a/scripts/grub-setup b/scripts/grub-setup
index e03020b4..cfa9fecc 100755
--- a/scripts/grub-setup
+++ b/scripts/grub-setup
@@ -26,6 +26,15 @@
#
#
+UNION="false"
+while getopts u c
+do
+ case $c in
+ u) UNION=true;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
ROOT_PARTITION="$1"
GRUB_OPTIONS="$2"
ROOTFSDIR="$3"
@@ -62,11 +71,11 @@ serial_console="console=tty0 console=ttyS0,9600"
vga_logo="vga=785"
# get list of kernels, except Xen
- kernel_versions=$(ls /boot/vmlinuz-* 2> /dev/null | grep -v xen | sed 's:/boot/vmlinuz::g' | sort -r)
+ kernel_versions=$(ls $ROOTFSDIR/boot/vmlinuz-* 2> /dev/null | grep -v xen | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
# get xen kernel info
- xen_kernel_version=$(ls /boot/vmlinuz*xen 2> /dev/null | sed 's:/boot/vmlinuz::g' | sort -r)
- xen_version=$(ls /boot/ | grep xen- | sort -r)
+ xen_kernel_version=$(ls $ROOTFSDIR/boot/vmlinuz*xen 2> /dev/null | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
+ xen_version=$(ls $ROOTFSDIR/boot/ | awk -F/ '{ print $5 }' | grep xen- | sort -r)
# Figure out whether we are running on the serial or KVM console:
if [ "`tty`" == "/dev/ttyS0" ]; then
@@ -77,21 +86,20 @@ vga_logo="vga=785"
default_console=0
fi
- # Read UUID off of filesystem and use it to tell GRUB where to mount drive
- # This allows device to move around and grub will still find it
- uuid=$(dumpe2fs -h /dev/${ROOT_PARTITION} 2>/dev/null | awk '/^Filesystem UUID/ {print $3}')
- if [ -z "$uuid" ]
- then
+ if eval "$UNION"; then
+ GRUB_OPTIONS="boot=live live-media-path=/vyatta-live module=vc4 persistent noautologin nonetworking nouser hostname=vyatta"
+ else
+ # Read UUID off of filesystem and use it to tell GRUB where to mount drive
+ # This allows device to move around and grub will still find it
+ uuid=$(dumpe2fs -h /dev/${ROOT_PARTITION} 2>/dev/null | awk '/^Filesystem UUID/ {print $3}')
+ if [ -z "$uuid" ]
+ then
# TODO: use /proc/mount if dumpe2fs fails
- echo "Unable to read filesystem UUID. Exiting."
- exit 1
- else
- if [ "$GRUB_OPTIONS" ]
- then
+ echo "Unable to read filesystem UUID. Exiting."
+ exit 1
+ else
GRUB_OPTIONS="$GRUB_OPTIONS root=UUID=$uuid ro"
- else
- GRUB_OPTIONS="root=UUID=$uuid ro"
- fi
+ fi
fi
(
@@ -123,7 +131,20 @@ vga_logo="vga=785"
echo "fi"
echo ""
- if [ -f "/boot/vmlinuz" ]; then
+ # create xen kernels if they exist
+ if [ -n "$xen_kernel_version" ]; then
+ for xversion in $xen_kernel_version; do
+ echo
+ echo
+ echo -e "menuentry \"Vyatta Xen linux$xversion dom0\" {"
+ echo -e "\tmultiboot /boot/$xen_version "
+ echo -e "\tmodule /boot/vmlinuz$xversion $GRUB_OPTIONS $vga_logo $vty_console"
+ echo -e "\tmodule /boot/initrd.img$xversion"
+ echo -e "}"
+ done
+ fi
+
+ if [ -f "$ROOTFSDIR/boot/vmlinuz" ]; then
# Set first system boot option. Make KVM the default console in this one.
echo -e "menuentry \"Vyatta OFR (KVM console)\" {"
echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $vga_logo $vty_console"
@@ -139,19 +160,6 @@ vga_logo="vga=785"
echo -e "}"
fi
- # create xen kernels if they exist
- if [ -n "$xen_kernel_version" ]; then
- for xversion in $xen_kernel_version; do
- echo
- echo
- echo -e "menuentry \"Vyatta Xen linux$xversion dom0\" {"
- echo -e "\tmultiboot /boot/$xen_version "
- echo -e "\tmodule /boot/vmlinuz$xversion $GRUB_OPTIONS $vga_logo $vty_console"
- echo -e "\tmodule /boot/initrd.img$xversion"
- echo -e "}"
- done
- fi
-
# create other kernels if they exist
if [ -n "$kernel_versions" ]; then
for kversion in $kernel_versions; do