summaryrefslogtreecommitdiff
path: root/pm/sleep.d/01grub
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2008-01-26 18:06:26 +0000
committerRichard Hughes <richard@hughsie.com>2008-01-26 18:06:26 +0000
commitde1ace906a3c99b01996b7a0e8dfabcabf0262c9 (patch)
tree505d9702a4f38c0dafced0157307ae67b0e7f736 /pm/sleep.d/01grub
parent67645abd5351105a1d18f8615e789c4234e0d480 (diff)
rename hooks into sleep.d -- this is something we have wanted to
do for a long time, but CVS made it hard
Diffstat (limited to 'pm/sleep.d/01grub')
-rw-r--r--pm/sleep.d/01grub33
1 files changed, 33 insertions, 0 deletions
diff --git a/pm/sleep.d/01grub b/pm/sleep.d/01grub
new file mode 100644
index 0000000..0dac5a1
--- /dev/null
+++ b/pm/sleep.d/01grub
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+default_resume_kernel()
+{
+ case $(uname -m) in
+ i?86|x86_64|athlon)
+ ;;
+ *) # this is only valid for x86 and x86_64
+ return 1
+ esac
+
+ [ -x /sbin/grubby -a -x /sbin/grub ] || return 1
+ [ -e /boot/vmlinuz-$(uname -r) ] || return 1
+
+ out=$(/sbin/grubby --info /boot/vmlinuz-$(uname -r) |grep index)
+ [ -n "${out}" ] || return 1
+ current=${out#index=}
+ echo "savedefault --default=${current} --once" | /sbin/grub --batch --no-floppy --device-map=/boot/grub/device.map --no-curses >/dev/null
+
+ return 0
+}
+
+RETVAL=0
+case "$1" in
+ hibernate)
+ default_resume_kernel
+ RETVAL=$?
+ ;;
+ *)
+ ;;
+esac
+
+exit $RETVAL