Package: hibernate Version: 1.05-1 Severity: wishlist Tags: patch I found the handling of changes to the grub menu file to be brittle. The following patch makes it more robust by using a different means. I also introduce a new configuration option in the hope that we can either get rid of the backup file by default, or use e.g. /tmp as its location, not /boot.
Thanks for your consideration.
--- /tmp/grub 2005-03-19 16:56:08.361358109 +0100
+++ grub 2005-03-19 17:07:32.553469762 +0100
@@ -5,6 +5,7 @@
AddConfigHelp "ChangeGrubMenu <boolean>" "Change grub's config file to show
system is suspended before suspending and restore after resume."
AddConfigHelp "GrubMenuFile <filename>" "Filename of grub's config file.
Default is /boot/grub/grub.conf."
AddConfigHelp "AlternateGrubMenuFile <filename>" "Filename of the grub config
file to put in place when the machine is suspended. If this is not specified,
the script will add a small header to the existing grub menu."
+AddConfigHelp "GrubMenuBackupFile <filename>" "Name of the backup file of the
grub menu. Defaults to the current grub menu file with '.hibernate.bak'
appended."
AddOptionHandler GrubCmdlineOptions
AddShortOption 'g'
@@ -13,6 +14,9 @@
GRUB_MENU_FILE="/boot/grub/grub.conf"
+GRUB_BEGIN_SENTINEL="### BEGIN HIBERNATE SENTINEL"
+GRUB_END_SENTINEL="### END HIBERNATE SENTINEL"
+
ChangeGrubMenu() {
if [ x"$CHANGE_GRUB_MENU" = "x1" ] ; then
if [ -f $GRUB_MENU_FILE ] ;then
@@ -21,7 +25,7 @@
vecho 2 "Changing grub menu..."
# Make a backup, and abort if we fail to.
- if ! cp "$GRUB_MENU_FILE" "$GRUB_MENU_FILE.hibernate.bak" ; then
+ if ! cp "$GRUB_MENU_FILE"
"${GRUB_MENU_BACKUP_FILE:-$GRUB_MENU_FILE.hibernate.bak}" ; then
vecho 0 "Could not make backup of grub menu. Not changing!"
return 1 # abort if not forced
fi
@@ -33,11 +37,16 @@
return 1 # abort if not forced
fi
else
- echo >> "$GRUB_MENU_FILE"
- echo "title
_____________________________________________________________________" >>
"$GRUB_MENU_FILE"
- echo "configfile dummy" >> "$GRUB_MENU_FILE"
- echo "title WARNING: "`uname -s -r` "is suspended via Software Suspend!" >>
"$GRUB_MENU_FILE"
- echo "configfile dummy" >> "$GRUB_MENU_FILE"
+ RestoreGrubMenu
+ cat <<-EOF >> $GRUB_MENU_FILE
+ $GRUB_BEGIN_SENTINEL
+
+ title _____________________________________________________________________
+ configfile dummy
+ title WARNING: "`uname -s -r` "is suspended via Software Suspend!"
+ configfile dummy
+ $GRUB_END_SENTINEL
+ EOF
fi
# Call sync to ensure it is written to disk (do we still need
# double/triple syncs?)
@@ -51,10 +60,9 @@
RestoreGrubMenu() {
if [ x"$CHANGE_GRUB_MENU" = "x1" ] ; then
- if [ -f $GRUB_MENU_FILE.hibernate.bak ] ; then
- vecho 2 "Restoring grub menu..."
- mv -f "$GRUB_MENU_FILE.hibernate.bak" "$GRUB_MENU_FILE"
- fi
+ sed -e "/^$GRUB_BEGIN_SENTINEL/,/^$GRUB_END_SENTINEL/d" \
+ $GRUB_MENU_FILE > $GRUB_MENU_FILE.new \
+ && mv $GRUB_MENU_FILE.new $GRUB_MENU_FILE
fi
}
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (600, 'testing'), (98, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-wing
Locale: LANG=en_GB, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
-- no debconf information
--
.''`. martin f. krafft <[EMAIL PROTECTED]>
: :' : proud Debian developer, admin, user, and author
`. `'`
`- Debian - when you have better things to do than fixing a system
Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver!
"perhaps debian is concerned more about technical excellence rather
than ease of use by breaking software. in the former we may excel.
in the latter we have to concede the field to microsoft. guess
where i want to go today?"
-- manoj srivastava
signature.asc
Description: Digital signature

