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