]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-suspend.sh
no need to mess with magic values, let the "magic" be value
[projects/geninitrd.git] / mod-suspend.sh
1 #!/bin/sh
2 SUSPEND_RCSID='$Revision$ $Date::                            $'
3
4 # geninitrd mod: suspend
5 USE_SUSPEND=${USE_SUSPEND:-yes}
6
7 # resume device
8 resume_dev=""
9
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
17
18         resume=$(find_tool $initrd_dir/resume /usr/${_lib}/suspend/resume /usr/sbin/resume)
19
20         if [ ! -x "$resume" ] || [ ! -f /etc/suspend.conf ]; then
21                 USE_SUSPEND=no
22         fi
23 }
24
25 # find modules for for suspend
26 # @access       public
27 find_modules_suspend() {
28         resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)"
29
30         # save state
31         local vgvolumes=$LVM_VGVOLUMES
32         find_modules_for_devpath $resume_dev
33
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
39                 debug "suspend device is on LVM"
40         fi
41 }
42
43 # generate initrd fragment
44 # @access       public
45 initrd_gen_suspend() {
46         if ! is_yes "$USE_SUSPEND"; then
47                 return
48         fi
49
50         debug "Setting up suspend..."
51
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
67                         resume=${arg##resume=}
68                 fi
69         done
70         if [ "$resume" = "yes" ]; then
71                 resume
72         fi
73         EOF
74 }
This page took 0.086903 seconds and 3 git commands to generate.