]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-suspend.sh
Warn about missing firmware instead of failing. Some modules specify firmware files...
[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         local vgvolumes=$VGVOLUMES
31         find_modules_for_devpath $resume_dev
32
33         if [ "$VGVOLUMES" != "$vgvolumes" ]; then
34                 # save our VG to be able to differenciate between rootfs VG
35                 SUSPENDVG=$VGVOLUMES
36                 VGVOLUMES=$vgvolumes
37                 debug "suspend device is on LVM"
38         fi
39 }
40
41 # generate initrd fragment
42 # @access       public
43 initrd_gen_suspend() {
44         if ! is_yes "$USE_SUSPEND"; then
45                 return
46         fi
47
48         debug "Setting up suspend..."
49
50         mknod $DESTDIR/dev/snapshot c 10 231
51         mkdir -p $DESTDIR${resume_dev%/*}
52         inst $resume_dev $resume_dev
53
54         inst /etc/suspend.conf /etc/suspend.conf
55         if [ -x /usr/${_lib}/suspend/resume ]; then
56                 inst_exec /usr/${_lib}/suspend/resume /bin/resume
57         else
58                 inst_exec /usr/sbin/resume /bin/resume
59         fi
60
61         add_linuxrc <<-'EOF'
62         resume=no
63         for arg in $CMDLINE; do
64                 if [ "${arg##resume=}" != "${arg}" ]; then
65                         resume=yes
66                 fi
67         done
68         if [ "$resume" = "yes" ]; then
69                 resume
70         fi
71         EOF
72 }
This page took 0.056271 seconds and 3 git commands to generate.