]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add user suspend support
authorAndrey Borzenkov <arvidjaar@mail.ru>
Wed, 13 Jan 2010 15:07:13 +0000 (16:07 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 13 Jan 2010 15:08:22 +0000 (16:08 +0100)
This patch adds support for user mode suspend to disk. It is installed
in parallel to kernel mode suspend module; either will fail if
system was not suspended using correct tool so next one can be tried.

Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>
dracut.spec
modules.d/95uswsusp/check [new file with mode: 0755]
modules.d/95uswsusp/install [new file with mode: 0755]
modules.d/95uswsusp/parse-uswsusp.sh [new file with mode: 0755]
modules.d/95uswsusp/resume-uswsusp.sh [new file with mode: 0755]

index 326a3e7b5bbadac1a13d793090f64bc3619d4b09..99446720e343c9e25a1da0899b2eb3786236d24f 100644 (file)
@@ -186,6 +186,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_datadir}/dracut/modules.d/95znet
 %{_datadir}/dracut/modules.d/95terminfo
 %{_datadir}/dracut/modules.d/95udev-rules
+%{_datadir}/dracut/modules.d/95uswsusp
 %{_datadir}/dracut/modules.d/98syslog
 %{_datadir}/dracut/modules.d/99base
 %attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
diff --git a/modules.d/95uswsusp/check b/modules.d/95uswsusp/check
new file mode 100755 (executable)
index 0000000..ba95479
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ -x /usr/sbin/resume ]
diff --git a/modules.d/95uswsusp/install b/modules.d/95uswsusp/install
new file mode 100755 (executable)
index 0000000..f8afe3a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+inst /usr/sbin/resume
+[ -f /etc/suspend.conf ] && inst /etc/suspend.conf
+
+inst_hook cmdline 10 "$moddir/parse-uswsusp.sh"
+inst_hook mount 10 "$moddir/resume-uswsusp.sh"
diff --git a/modules.d/95uswsusp/parse-uswsusp.sh b/modules.d/95uswsusp/parse-uswsusp.sh
new file mode 100755 (executable)
index 0000000..7a0925f
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+if resume=$(getarg resume=) && ! getarg noresume; then 
+    export resume
+else
+    unset resume
+fi
+
+case "$resume" in
+    LABEL=*)
+       resume="$(echo $resume | sed 's,/,\\x2f,g')"
+       resume="/dev/disk/by-label/${resume#LABEL=}" ;;
+    UUID=*)
+       resume="/dev/disk/by-uuid/${resume#UUID=}" ;;
+esac
+
+if splash=$(getarg splash=); then
+    export splash
+else
+    unset splash
+fi
diff --git a/modules.d/95uswsusp/resume-uswsusp.sh b/modules.d/95uswsusp/resume-uswsusp.sh
new file mode 100755 (executable)
index 0000000..9b18567
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+case "$splash" in
+    quiet )
+       a_splash="-P splash=y"
+    ;;
+    * )
+       a_splash="-P splash=n"
+    ;;
+esac
+
+/usr/sbin/resume $a_splash "$resume"