]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-suspend.sh
Timeout here is not a good idea. rootfs cannot be mounted and kernel oopses due to...
[projects/geninitrd.git] / mod-suspend.sh
1 #!/bin/sh
2 # geninitrd mod: suspend
3 USE_SUSPEND=${USE_SUSPEND:-yes}
4
5 # resume device
6 resume_dev=""
7
8 # setup geninitrd module
9 # @access       public
10 setup_mod_suspend() {
11         # XXX this needs tuxonice loaded first
12         if is_yes "$USE_SUSPEND" && is_yes "$USE_TUXONICE"; then
13                 warn "Tuxonice and mainline suspend are exclusive!"
14         fi
15
16         resume=$(find_tool $(get_libdir /usr/LIBDIR/suspend/resume) $initrd_dir/resume /usr/sbin/resume)
17
18         if [ ! -x "$resume" ] || [ ! -f /etc/suspend.conf ]; then
19                 USE_SUSPEND=no
20         else
21                 resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)"
22                 if [ -z "$resume_dev" ]; then
23                         warn "Option 'resume device' not found in /etc/suspend.conf. Disabling suspend support."
24                         USE_SUSPEND=no
25                 fi
26         fi
27 }
28
29 # find modules for for suspend
30 # @access       public
31 find_modules_suspend() {
32         resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)"
33
34         # save state
35         local vgvolumes=$LVM_VGVOLUMES
36         find_modules_for_devpath $resume_dev
37
38         # check for saved state, differenciate between rootfs VG
39         if [ "$LVM_VGVOLUMES" != "$vgvolumes" ]; then
40                 # save suspend VG int oseparate var
41                 LVM_SUSPENDVG=$LVM_VGVOLUMES
42                 LVM_VGVOLUMES=$vgvolumes
43                 verbose "suspend device is on LVM"
44         fi
45 }
46
47 # generate initrd fragment
48 # @access       public
49 initrd_gen_suspend() {
50         if ! is_yes "$USE_SUSPEND"; then
51                 return
52         fi
53
54         verbose "Setting up suspend..."
55
56         mknod -m 640 $DESTDIR/dev/snapshot c 10 231
57         mkdir -p $DESTDIR${resume_dev%/*}
58         inst $resume_dev $resume_dev
59
60         inst /etc/suspend.conf /etc/suspend.conf
61         inst_exec $resume /bin/resume
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.276409 seconds and 3 git commands to generate.