From fe3d0a401c90030ffdbf0b9e6d3db9dc2543c304 Mon Sep 17 00:00:00 2001 From: Rick Balocca Date: Wed, 6 Aug 2008 15:29:06 -0700 Subject: Fix for http://bugzilla.vyatta.com/show_bug.cgi?id=3520 --- scripts/grub-setup | 173 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/install-system | 129 +++--------------------------------- 2 files changed, 182 insertions(+), 120 deletions(-) create mode 100755 scripts/grub-setup (limited to 'scripts') diff --git a/scripts/grub-setup b/scripts/grub-setup new file mode 100755 index 00000000..10b1c936 --- /dev/null +++ b/scripts/grub-setup @@ -0,0 +1,173 @@ +#!/bin/sh +# +# Module: grup-setup +# +# **** License **** +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# This code was originally developed by Vyatta, Inc. +# Portions created by Vyatta are Copyright (C) 2006, 2007 Vyatta, Inc. +# All Rights Reserved. +# +# Author: Robert Bays +# Date: 2006 +# Description: +# +# **** End License **** +# +# Vyatta grub customization setup script. +# +# + +ROOT_PARTITION="$1" +GRUB_OPTIONS="$2" +ROOTFSDIR="$3" + +[ "$ROOT_PARTITION" ] || exit 1 + +# Grub options +GRUB_OPTIONS="$GRUB_OPTIONS quiet" + +# Path to standalone root password reset script +pass_reset=/opt/vyatta/sbin/standalone_root_pw_reset + +# Output to both console (last device is /dev/console) +vty_console="console=ttyS0,9600 console=tty0" +serial_console="console=tty0 console=ttyS0,9600" + +# If vga_logo is set, enable use of the VGA monitor for displaying the +# logo during boot. The "vga=" boot command specifies a VGA mode that +# is encoded as shown below. We pick a value that is likely to work +# on most systems: +# +# Color depth | 640x480 | 800x600 | 1024x768 | 1280x1024 +# -----------------+---------+---------+----------+---------- +# 256 (8bit) | 769 771 773 775 +# 32000 (15bit) | 784 787 790 793 +# 65000 (16bit) | 785 788 791 794 +# 16.7 Mill.(24bit)| 786 789 792 795 +# + #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) + + # 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) + + # Figure out whether we are running on the serial or KVM console: + if [ "`tty`" == "/dev/ttyS0" ]; then + # Since user is running on serial console, make that the default. + default_console=1 + else + # Since user is running on KVM console, make that the default + 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 + # TODO: use /proc/mount if dumpe2fs fails + echo "Unable to read filesystem UUID. Exiting." + exit 1 + else + GRUB_OPTIONS="$GRUB_OPTIONS root=UUID=$uuid ro" + fi + +( + # create the grub.cfg file for grub + # The "default=" line selects which boot option will be used by default. + # Numbering starts at 0 for the first option. + echo -e "set default=$default_console" + echo "set timeout=5" + # set serial console options + echo -e "serial --unit=0 --speed=9600" + echo "terminal serial" + + echo "" + echo "echo -n Press ESC to enter the Grub menu..." + echo "if sleep --verbose --interruptible 5 ; then" + echo -e "\tterminal console" + echo -e "\techo -n Press the ESC key to enter the Grub menu..." + echo -e "\tif sleep --verbose --interruptible 5 ; then" + echo -e "\t\tterminal serial" + echo -e "\t\tset timeout=0" + echo -e "\tfi" + echo "fi" + echo "" + + if [ -f "/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" + echo -e "\tinitrd /boot/initrd.img" + echo -e "}" + + # Set the second system boot option. Make the serial port be the default + # console in this one. + echo + echo -e "menuentry \"Vyatta OFR (Serial console)\" {" + echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $serial_console" + echo -e "\tinitrd /boot/initrd.img" + 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 $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 + echo + echo -e "menuentry \"Vyatta OFR linux$kversion (KVM console)\" {" + echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $vty_console" + echo -e "\tinitrd /boot/initrd.img$kversion" + echo -e "}" + echo + echo -e "menuentry \"Vyatta OFR linux$kversion (Serial console)\" {" + echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $serial_console" + echo -e "\tinitrd /boot/initrd.img$kversion" + echo -e "}" + done + fi + + # Set options for root password reset. Offer + # options for both serial and KVM console. + + echo + echo -e "menuentry \"Root password reset to factory (KVM console)\" {" + echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $vty_console init=$pass_reset" + echo -e "\tinitrd /boot/initrd.img" + echo -e "}" + + echo + echo -e "menuentry \"Root password reset to factory (Serial console)\" {" + echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $serial_console init=$pass_reset" + echo -e "\tinitrd /boot/initrd.img" + echo -e "}" +) >"$ROOTFSDIR"/boot/grub/grub.cfg + +( [ -s /boot/grub/menu.lst ] && + upgrade-from-grub-legacy && + rm -f /boot/grub/menu.lst* +) || true diff --git a/scripts/install-system b/scripts/install-system index d6ea9b74..a704d4a7 100755 --- a/scripts/install-system +++ b/scripts/install-system @@ -612,131 +612,20 @@ install_grub () { grub-install --no-floppy --root-directory=$rootfsdir /dev/$INSTALL_DRIVE >>$INSTALL_LOG 2>&1 progress_indicator stop - # TODO: This needs to be changed to map to the correct drive - part=$(echo $ROOT_PARTITION | sed 's/[^0-9]//g') - if [ "$(cat /sys/block/$orig_install_drive/removable)" == 0 ]; then - root=$(grep $orig_install_drive $rootfsdir/boot/grub/device.map | /usr/bin/awk -F')' '{ print $1 }') - root="$root,$part)" - else - root="(hd0,$part)" - echo "This looks like a removable device. Setting root grub device to $root." - echo "This looks like a removable device. Setting root grub device to $root." >> $INSTALL_LOG - fi - - # get list of kernels, except Xen - kernel_versions=$(ls /boot/vmlinuz-* 2> /dev/null | grep -v xen | sed 's:/boot/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) - - # Figure out whether we are running on the serial or KVM console: - if [ "`tty`" == "/dev/ttyS0" ]; then - # Since user is running on serial console, make that the default. - DEFAULT_CONSOLE="1" - else - # Since user is running on KVM console, make that the default - DEFAULT_CONSOLE="0" + # Assume no dma if the disk is smaller than 10G (such as a CF drive) + size=$(get_drive_size $INSTALL_DRIVE) + if [[ $size -lt 11000 && ! $grub_options =~ 'ide=nodma' ]] + then + grub_options="ide=nodma" 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 - local rootdev="/dev/$ROOT_PARTITION"; - uuid=$(dumpe2fs -h $rootdev 2>/dev/null | awk '/^Filesystem UUID/ {print $3}') - if [ -z "$uuid" ] + if /opt/vyatta/sbin/grub-setup "$ROOT_PARTITION" "$grub_options" /mnt/rootfs >>$INSTALL_LOG then - echo "Unable to read filesystem UUID. Exiting." - exit 1 + echo "OK" else - GRUB_ROOT="root=UUID=$uuid ro" + echo Grub failed to install! + exit 1 fi - - ( - # create the grub.cfg file for grub - # The "default=" line selects which boot option will be used by default. - # Numbering starts at 0 for the first option. - echo -e "set default=$DEFAULT_CONSOLE" - echo "set timeout=5" - #echo "#set splashimage=(hd0,0)/grub/splash.xpm.gz" - # set serial console options - echo -e "serial --unit=0 --speed=9600" - echo "terminal serial" - echo "set root=$root" - - echo "" - echo "echo -n Press ESC to enter the Grub menu..." - echo "if sleep --verbose --interruptible 5 ; then" - echo -e "\tterminal console" - echo -e "\techo -n Press the ESC key to enter the Grub menu..." - echo -e "\tif sleep --verbose --interruptible 5 ; then" - echo -e "\t\tterminal serial" - echo -e "\t\tset timeout=0" - echo -e "\tfi" - echo "fi" - echo "" - - if [ -f "/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_ROOT $GRUB_OPTIONS $VGA_LOGO $VTY_CONSOLE" - echo -e "\tinitrd /boot/initrd.img" - echo -e "}" - - # Set the second system boot option. Make the serial port be the default - # console in this one. - echo - echo -e "menuentry \"Vyatta OFR (Serial console)\" {" - echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE" - echo -e "\tinitrd /boot/initrd.img" - 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_ROOT $GRUB_OPTIONS $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 - echo - echo -e "menuentry \"Vyatta OFR linux$kversion (KVM console)\" {" - echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE" - echo -e "\tinitrd /boot/initrd.img$kversion" - echo -e "}" - echo - echo -e "menuentry \"Vyatta OFR linux$kversion (Serial console)\" {" - echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE" - echo -e "\tinitrd /boot/initrd.img$kversion" - echo -e "}" - done - fi - - # Set options for root password reset. Offer - # options for both serial and KVM console. - - echo - echo -e "menuentry \"Root password reset to factory (KVM console)\" {" - echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE init=$PWRESET" - echo -e "\tinitrd /boot/initrd.img" - echo -e "}" - - echo - echo -e "menuentry \"Root password reset to factory (Serial console)\" {" - echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE init=$PWRESET" - echo -e "\tinitrd /boot/initrd.img" - echo -e "}" - ) >"$rootfsdir/boot/grub/grub.cfg" - - echo "OK" } # ask for user input on the parted and skip setup methods -- cgit v1.2.3 From 2a49a4affae63864797a473b14def10824e2bc83 Mon Sep 17 00:00:00 2001 From: Rick Balocca Date: Wed, 6 Aug 2008 15:51:21 -0700 Subject: Merge from islavista --- debian/vyatta-cfg-system.postinst.in | 16 +++++++++------- scripts/standalone_root_pw_reset | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/debian/vyatta-cfg-system.postinst.in b/debian/vyatta-cfg-system.postinst.in index b21437a5..0dd6248f 100644 --- a/debian/vyatta-cfg-system.postinst.in +++ b/debian/vyatta-cfg-system.postinst.in @@ -23,6 +23,7 @@ esac ln -sf ../vyatta-net.rules /etc/udev/rules.d/$vyatta_net_rules if [ "$sysconfdir" != "/etc" ]; then + touch /etc/sudoers cp -p /etc/sudoers /etc/sudoers.bak # for "admin" level @@ -32,13 +33,12 @@ if [ "$sysconfdir" != "/etc" ]; then fi # cleanup any old entries from previous versions - ed - /etc/sudoers <>/etc/sudoers ### BEGIN VYATTA @@ -85,6 +85,8 @@ if [ ! -f /etc/bash_completion ]; then echo "source /etc/bash_completion.d/20vyatta-cfg" >> /etc/bash_completion fi +sed -i 's/^set /builtin set /' /etc/bash_completion + # Local Variables: # mode: shell-script # sh-indentation: 4 diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset index b173f22d..336d534d 100755 --- a/scripts/standalone_root_pw_reset +++ b/scripts/standalone_root_pw_reset @@ -70,13 +70,13 @@ cp $CF ${CF}.before_pwrecovery echo "Reseting the root password..." # change system first -newpwd=$(mkpasswd -H md5 vyatta) +newpwd=`mkpasswd -H md5 vyatta` usermod --password "$newpwd" root # escape / in encrypted passwd pw=$(echo $newpwd | sed 's:/:\\/:g') sed -i \ - -e "/^.* user root {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$pw\"/" \ + -e "/^.* user root {/,/}/s/encrypted-password .*\$/encrypted-password \"$pw\"/" \ $CF echo $(date "+%b%e %T") $(hostname) "Root password reset to factory value" \ -- cgit v1.2.3 From d2da6d1177bb0cb1922c2f2b73b8a4f557cece28 Mon Sep 17 00:00:00 2001 From: rbalocca Date: Thu, 7 Aug 2008 18:18:12 -0700 Subject: Fixes for bugs: http://bugzilla.vyatta.com/show_bug.cgi?id=3549 and http://bugzilla.vyatta.com/show_bug.cgi?id=3552 This fix involves removing multiple spaces between args on the kernel command line. This fixes the symptom, but the root cause is an uninitialized variable in the grub-pc code, so there is absolutely no guarrantee that this problem will not arrise again. The correct fix is either to return to grub (V1) or to have the developers find and fix the unitialized memory. --- scripts/grub-setup | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/grub-setup b/scripts/grub-setup index 10b1c936..be1e60f0 100755 --- a/scripts/grub-setup +++ b/scripts/grub-setup @@ -34,6 +34,12 @@ ROOTFSDIR="$3" # Grub options GRUB_OPTIONS="$GRUB_OPTIONS quiet" +if [ "$GRUB_OPTIONS" ] +then + GRUB_OPTIONS="$GRUB_OPTIONS quiet" +else + GRUB_OPTIONS=quiet +fi # Path to standalone root password reset script pass_reset=/opt/vyatta/sbin/standalone_root_pw_reset @@ -81,7 +87,12 @@ serial_console="console=tty0 console=ttyS0,9600" echo "Unable to read filesystem UUID. Exiting." exit 1 else - GRUB_OPTIONS="$GRUB_OPTIONS root=UUID=$uuid ro" + if [ "$GRUB_OPTIONS" ] + then + GRUB_OPTIONS="$GRUB_OPTIONS root=UUID=$uuid ro" + else + GRUB_OPTIONS="root=UUID=$uuid ro" + fi fi ( -- cgit v1.2.3 From dc94c5c8e77817df8908c2b6aad08d70b1e142d3 Mon Sep 17 00:00:00 2001 From: rbalocca Date: Thu, 7 Aug 2008 18:27:18 -0700 Subject: More spaces (bugs http://bugzilla.vyatta.com/show_bug.cgi?id=3549 and http://bugzilla.vyatta.com/show_bug.cgi?id=3552) --- scripts/grub-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/grub-setup b/scripts/grub-setup index be1e60f0..7baa43fd 100755 --- a/scripts/grub-setup +++ b/scripts/grub-setup @@ -120,7 +120,7 @@ serial_console="console=tty0 console=ttyS0,9600" if [ -f "/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" + echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $vty_console" echo -e "\tinitrd /boot/initrd.img" echo -e "}" -- cgit v1.2.3 From 883737f620c6e0e95b1f92d2e24e9375efb20910 Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Mon, 11 Aug 2008 14:24:02 -0700 Subject: Bugfix: 1292 Re-enable the Vyatta logo on boot. --- scripts/grub-setup | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/grub-setup b/scripts/grub-setup index 7baa43fd..1e6751d9 100755 --- a/scripts/grub-setup +++ b/scripts/grub-setup @@ -33,7 +33,6 @@ ROOTFSDIR="$3" [ "$ROOT_PARTITION" ] || exit 1 # Grub options -GRUB_OPTIONS="$GRUB_OPTIONS quiet" if [ "$GRUB_OPTIONS" ] then GRUB_OPTIONS="$GRUB_OPTIONS quiet" @@ -60,7 +59,7 @@ serial_console="console=tty0 console=ttyS0,9600" # 65000 (16bit) | 785 788 791 794 # 16.7 Mill.(24bit)| 786 789 792 795 # - #vga_logo="vga=785" +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) @@ -120,7 +119,7 @@ serial_console="console=tty0 console=ttyS0,9600" if [ -f "/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 $vty_console" + echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $vga_logo $vty_console" echo -e "\tinitrd /boot/initrd.img" echo -e "}" -- cgit v1.2.3