]>
Commit | Line | Data |
---|---|---|
dea07ca3 | 1 | #!/bin/sh |
c34c6a69 | 2 | SUSPEND_RCSID='$Revision$ $Date:: $' |
05c474b5 | 3 | |
dea07ca3 | 4 | # geninitrd mod: suspend |
6e49b0b1 | 5 | USE_SUSPEND=${USE_SUSPEND:-yes} |
dea07ca3 ER |
6 | |
7 | # resume device | |
8 | resume_dev="" | |
9 | ||
dea07ca3 ER |
10 | # setup geninitrd module |
11 | # @access public | |
12 | setup_mod_suspend() { | |
13 | # XXX this needs tuxonice loaded first | |
14 | if is_yes "$USE_SUSPEND" && is_yes "$USE_TUXONICE"; then | |
15 | warn "Tuxonice and mainline suspend are exclusive!" | |
16 | fi | |
347ce740 ER |
17 | |
18 | resume=$(find_tool $initrd_dir/resume /usr/${_lib}/suspend/resume /usr/sbin/resume) | |
19 | ||
6e49b0b1 | 20 | if [ ! -x "$resume" ] || [ ! -f /etc/suspend.conf ]; then |
347ce740 ER |
21 | USE_SUSPEND=no |
22 | fi | |
dea07ca3 ER |
23 | } |
24 | ||
25 | # find modules for for suspend | |
26 | # @access public | |
27 | find_modules_suspend() { | |
dea07ca3 ER |
28 | resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)" |
29 | ||
00afc695 ER |
30 | # save state |
31 | local vgvolumes=$LVM_VGVOLUMES | |
dea07ca3 ER |
32 | find_modules_for_devpath $resume_dev |
33 | ||
00afc695 ER |
34 | # check for saved state, differenciate between rootfs VG |
35 | if [ "$LVM_VGVOLUMES" != "$vgvolumes" ]; then | |
36 | # save suspend VG int oseparate var | |
37 | LVM_SUSPENDVG=$LVM_VGVOLUMES | |
38 | LVM_VGVOLUMES=$vgvolumes | |
dea07ca3 ER |
39 | debug "suspend device is on LVM" |
40 | fi | |
41 | } | |
42 | ||
43 | # generate initrd fragment | |
44 | # @access public | |
45 | initrd_gen_suspend() { | |
1b481849 ER |
46 | if ! is_yes "$USE_SUSPEND"; then |
47 | return | |
48 | fi | |
49 | ||
94b9755a ER |
50 | debug "Setting up suspend..." |
51 | ||
dea07ca3 ER |
52 | mknod $DESTDIR/dev/snapshot c 10 231 |
53 | mkdir -p $DESTDIR${resume_dev%/*} | |
54 | inst $resume_dev $resume_dev | |
55 | ||
56 | inst /etc/suspend.conf /etc/suspend.conf | |
57 | if [ -x /usr/${_lib}/suspend/resume ]; then | |
58 | inst_exec /usr/${_lib}/suspend/resume /bin/resume | |
59 | else | |
60 | inst_exec /usr/sbin/resume /bin/resume | |
61 | fi | |
62 | ||
63 | add_linuxrc <<-'EOF' | |
64 | resume=no | |
65 | for arg in $CMDLINE; do | |
66 | if [ "${arg##resume=}" != "${arg}" ]; then | |
6796940d | 67 | resume=${arg##resume=} |
dea07ca3 ER |
68 | fi |
69 | done | |
70 | if [ "$resume" = "yes" ]; then | |
71 | resume | |
72 | fi | |
73 | EOF | |
74 | } |