On Monday 28 June 2004 16:02, Robert Millan wrote: > Uhm. I think it's quite hard to support all possible variations of > menu.lst in a script that sets the proper setdefault options, while > ensuring there's no collateral effect. Do you have a particular > scheme in mind for modifying it from the script?
It's quite trivial for me. Here is an example to set up a menu.lst (not complete or not tested): #! /bin/bash # Arguments. boot=$0 # Obtain the current entry number. current=0 default=`grep ^default /boot/grub/menu.lst | sed -e 's/default *\(saved|[0-9]*\)/\1/'` case "$default" in saved) line=`head -1 /boot/grub/menu.lst` if echo $line | grep -q; then current=`echo $line | sed -e 's/^\([0-9][0-9]*\).*/\1/'` fi ;; [0-9]*) current=$default ;; esac # Make a temporary file to set fallback and default correctly. tmp=/tmp/menu.lst.$$ cat <<EOF >$tmp default saved fallback $current EOF in_entry=0 num=0 while read line; do if test $in_entry = 0; then # Skip default and fallback in the original. if cat $line | grep -q ^default; then : elif cat $line | grep -q ^fallback; then : elif cat $line | grep -q ^title; then in_entry=1 echo $line >> $tmp else echo $line >> $tmp fi else # Count entries. if cat $line | grep -q ^title; then num=`expr $num + 1` fi # If this is the target entry, insert savedefault and ignore it in the original. if test $boot -eq $num; then if cat $line | grep -q ^title; then echo $line >> $tmp echo "savedefault fallback" >> $tmp elif cat $line | grep -q ^savedefault; then : else echo $line >> $tmp fi else echo $line >> $tmp fi fi done < /boot/grub/menu.lst # Finish. mv -f $tmp /boot/grub/menu.lst exit 0 Probably it is necessary to add more code, for example, because this does not take it into account that the user might run this script more than once. And, it is better to restore the original menu.lst at next boot time. Maybe using an init script. Okuji _______________________________________________ Bug-grub mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-grub