summaryrefslogtreecommitdiff
path: root/pm/sleep.d/01grub
blob: 61656a9e5d08860e0054e298e776e7d1466ea97d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

default_resume_kernel()
{
	case $(uname -m) in
		i?86|x86_64|athlon)
	    		;;
		*) # this is only valid for x86 and x86_64
			return $NA
	    		;;
	esac

	[ -x /sbin/grubby -a -x /sbin/grub ] || return $NA
	[ -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 --device-map=/boot/grub/device.map \
		--batch --no-floppy --no-curses >/dev/null

	return 0
}

case "$1" in
	hibernate|suspend_hybrid)
		default_resume_kernel
		;;
	*) exit $NA
		;;
esac