]>
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() { | |
94b9755a ER |
43 | debug "Setting up suspend..." |
44 | ||
dea07ca3 ER |
45 | mknod $DESTDIR/dev/snapshot c 10 231 |
46 | mkdir -p $DESTDIR${resume_dev%/*} | |
47 | inst $resume_dev $resume_dev | |
48 | ||
49 | inst /etc/suspend.conf /etc/suspend.conf | |
50 | if [ -x /usr/${_lib}/suspend/resume ]; then | |
51 | inst_exec /usr/${_lib}/suspend/resume /bin/resume | |
52 | else | |
53 | inst_exec /usr/sbin/resume /bin/resume | |
54 | fi | |
55 | ||
56 | add_linuxrc <<-'EOF' | |
57 | resume=no | |
58 | for arg in $CMDLINE; do | |
59 | if [ "${arg##resume=}" != "${arg}" ]; then | |
60 | resume=yes | |
61 | fi | |
62 | done | |
63 | if [ "$resume" = "yes" ]; then | |
64 | resume | |
65 | fi | |
66 | EOF | |
67 | } |