On Thursday 30 September 2004 15:37, Miguel Albuquerque wrote:
Thank you very much, works great ! So should I assume that with grub i can't do the same ? :-[
Here is a small script that I bashed together a few months ago:
----8<----8<--[bootonce]--8<----8<----8<----
#! /bin/bash
# BASH script to use GRUB's boot-once feature
GRUB_ENTRY_COUNT=`grep "^[[:blank:]]*title\>" /boot/grub/menu.lst | wc --lines`
function is_number()
{
echo "$1" | egrep -q '^[0-9]+$'
}
function is_entry()
{
is_number $1 && [ $1 -ge 0 -a $1 -lt $GRUB_ENTRY_COUNT ]
}
function usage()
{
local i
echo "Usage: ${0##*/} [0..$[ GRUB_ENTRY_COUNT - 1 ]]"
grep "^[[:blank:]]*title\>" /boot/grub/menu.lst |
sed 's:^[[:blank:]]*[Tt][Ii][Tt][Ll][Ee][[[:blank:]]\+::' |
while read S; do
echo "$[ i ]: $S"
(( i++ ))
done
exit 1
}
# See if there's a --stage2= option in /etc/grub.conf:
[ -f "/etc/SuSE-release" ] && STAGE2="`sed -n '/--stage2=/ s/^.*--stage2=\([^[:blank:]]*\).*$/\1/p' /etc/grub.conf`"
# If the file does not exist, remove the STAGE2 variable
[ -f "$STAGE2" ] || unset STAGE2
# For debugging put a comment sign in front of the next line:
GRUB="grub --batch"
# Allow only one parameter
is_entry $1 || usage
${GRUB-cat} <