]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-suspend.sh
Allow more than 10 md devices.
[projects/geninitrd.git] / mod-suspend.sh
1 #!/bin/sh
2 #
3 # geninitrd mod: suspend
4 USE_SUSPEND=${USE_SUSPEND:-yes}
5
6 # resume device
7 resume_dev=""
8
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
16
17         resume=$(find_tool $initrd_dir/resume /usr/${_lib}/suspend/resume /usr/sbin/resume)
18
19         if [ ! -x "$resume" ] || [ ! -f /etc/suspend.conf ]; then
20                 USE_SUSPEND=no
21         fi
22 }
23
24 # find modules for for suspend
25 # @access       public
26 find_modules_suspend() {
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() {
43         debug "Setting up suspend..."
44
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 }
This page took 0.024465 seconds and 3 git commands to generate.