Harald Hoyer 4734ec
From 8064f68d602b45778afc3f32a703b8376609d019 Mon Sep 17 00:00:00 2001
Harald Hoyer 4734ec
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 4734ec
Date: Mon, 2 Dec 2013 11:02:34 +0100
Harald Hoyer 4734ec
Subject: [PATCH] resume: no more autoresume
Harald Hoyer 4734ec
Harald Hoyer 4734ec
---
Harald Hoyer 4734ec
 modules.d/95resume/parse-resume.sh | 76 +++++++++++++++++++++-----------------
Harald Hoyer 4734ec
 1 file changed, 43 insertions(+), 33 deletions(-)
Harald Hoyer 4734ec
Harald Hoyer 4734ec
diff --git a/modules.d/95resume/parse-resume.sh b/modules.d/95resume/parse-resume.sh
Harald Hoyer 4734ec
index bd4bcd3..c84dafb 100755
Harald Hoyer 4734ec
--- a/modules.d/95resume/parse-resume.sh
Harald Hoyer 4734ec
+++ b/modules.d/95resume/parse-resume.sh
Harald Hoyer 4734ec
@@ -36,41 +36,51 @@ case "$splash" in
Harald Hoyer 4734ec
     ;;
Harald Hoyer 4734ec
 esac
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
-if [ -n "$resume" ]; then
Harald Hoyer 4734ec
-    {
Harald Hoyer 4734ec
-        printf "KERNEL==\"%s\", ACTION==\"add|change\", SYMLINK+=\"/dev/resume\"\n" \
Harald Hoyer 4734ec
-            ${resume#/dev/};
Harald Hoyer 4734ec
-        printf "SYMLINK==\"%s\", ACTION==\"add|change\", SYMLINK+=\"/dev/resume\"\n" \
Harald Hoyer 4734ec
-            ${resume#/dev/};
Harald Hoyer 4734ec
-    } >> /etc/udev/rules.d/99-resume-link.rules
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
-    {
Harald Hoyer 4734ec
-        if [ -x /usr/sbin/resume ]; then
Harald Hoyer 4734ec
-            printf "KERNEL==\"%s\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
Harald Hoyer 4734ec
-                ${resume#/dev/} "$a_splash" "$resume";
Harald Hoyer 4734ec
-            printf "SYMLINK==\"%s\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
Harald Hoyer 4734ec
-                ${resume#/dev/} "$a_splash" "$resume";
Harald Hoyer 4734ec
-        fi
Harald Hoyer 4734ec
-        printf "KERNEL==\"%s\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %%M:%%m > /sys/power/resume\"\n" \
Harald Hoyer 4734ec
-            ${resume#/dev/};
Harald Hoyer 4734ec
-        printf "SYMLINK==\"%s\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %%M:%%m  > /sys/power/resume\"\n" \
Harald Hoyer 4734ec
-            ${resume#/dev/};
Harald Hoyer 4734ec
-    } >> /etc/udev/rules.d/99-resume.rules
Harald Hoyer 4734ec
+if ! getarg noresume; then
Harald Hoyer 4734ec
+    if [ -n "$resume" ]; then
Harald Hoyer 4734ec
+        {
Harald Hoyer 4734ec
+            printf "KERNEL==\"%s\", ACTION==\"add|change\", SYMLINK+=\"/dev/resume\"\n" \
Harald Hoyer 4734ec
+                ${resume#/dev/};
Harald Hoyer 4734ec
+            printf "SYMLINK==\"%s\", ACTION==\"add|change\", SYMLINK+=\"/dev/resume\"\n" \
Harald Hoyer 4734ec
+                ${resume#/dev/};
Harald Hoyer 4734ec
+        } >> /etc/udev/rules.d/99-resume-link.rules
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
-    printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm -f -- "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
Harald Hoyer 4734ec
-        "$resume" "$resume" "$hookdir" >> $hookdir/initqueue/settled/resume.sh
Harald Hoyer 4734ec
+        {
Harald Hoyer 4734ec
+            if [ -x /usr/sbin/resume ]; then
Harald Hoyer 4734ec
+                printf -- "KERNEL==\"%s\", " "${resume#/dev/}"
Harald Hoyer 4734ec
+                printf -- "ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+                printf -- " RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
Harald Hoyer 4734ec
+                     "$a_splash" "$resume";
Harald Hoyer 4734ec
+                printf -- "SYMLINK==\"%s\", " "${resume#/dev/}"
Harald Hoyer 4734ec
+                printf -- "ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+                printf -- " RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \'%s\'\"\n" \
Harald Hoyer 4734ec
+                    "$a_splash" "$resume";
Harald Hoyer 4734ec
+            fi
Harald Hoyer 4734ec
+            printf -- "KERNEL==\"%s\", " ${resume#/dev/};
Harald Hoyer 4734ec
+            printf -- "ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+            printf -- "%s" " RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %%M:%%m > /sys/power/resume\"\n"
Harald Hoyer 4734ec
+            printf -- "SYMLINK==\"%s\", " ${resume#/dev/};
Harald Hoyer 4734ec
+            printf -- "%s" "ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+            printf -- "%s" " RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %%M:%%m  > /sys/power/resume\"\n"
Harald Hoyer 4734ec
+        } >> /etc/udev/rules.d/99-resume.rules
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
-    printf 'warn "Cancelling resume operation. Device not found."; cancel_wait_for_dev /dev/resume; rm -f -- "$job" "%s/initqueue/settled/resume.sh";' \
Harald Hoyer 4734ec
-        "$hookdir" >> $hookdir/initqueue/timeout/resume.sh
Harald Hoyer 4734ec
+        printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm -f -- "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
Harald Hoyer 4734ec
+            "$resume" "$resume" "$hookdir" >> $hookdir/initqueue/settled/resume.sh
Harald Hoyer 4734ec
 
Harald Hoyer 4734ec
-    wait_for_dev "/dev/resume"
Harald Hoyer 4734ec
-    mv /lib/dracut/resume.sh /lib/dracut/hooks/pre-mount/10-resume.sh
Harald Hoyer 4734ec
-elif ! getarg noresume; then
Harald Hoyer 4734ec
-    {
Harald Hoyer 4734ec
-        if [ -x /usr/sbin/resume ]; then
Harald Hoyer 4734ec
-            printf "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \$tempnode\"\n" "$a_splash"
Harald Hoyer 4734ec
-        fi
Harald Hoyer 4734ec
-        echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\"," \
Harald Hoyer 4734ec
-            " RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume\"";
Harald Hoyer 4734ec
-    } >> /etc/udev/rules.d/99-resume.rules
Harald Hoyer 4734ec
+        printf -- "%s" 'warn "Cancelling resume operation. Device not found.";'
Harald Hoyer 4734ec
+        printf -- ' cancel_wait_for_dev /dev/resume; rm -f -- "$job" "%s/initqueue/settled/resume.sh";' \
Harald Hoyer 4734ec
+            "$hookdir" >> $hookdir/initqueue/timeout/resume.sh
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+        mv /lib/dracut/resume.sh /lib/dracut/hooks/pre-mount/10-resume.sh
Harald Hoyer 4734ec
+    else
Harald Hoyer 4734ec
+        {
Harald Hoyer 4734ec
+            if [ -x /usr/sbin/resume ]; then
Harald Hoyer 4734ec
+                printf "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+                printf -- " RUN+=\"/sbin/initqueue --finished --unique --name 00resume /usr/sbin/resume %s \$tempnode\"\n" "$a_splash"
Harald Hoyer 4734ec
+            fi
Harald Hoyer 4734ec
+            printf -- "%s" "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\","
Harald Hoyer 4734ec
+            printf -- "%s" " RUN+=\"/sbin/initqueue --finished --unique --name 00resume echo %M:%m > /sys/power/resume\"";
Harald Hoyer 4734ec
+        } >> /etc/udev/rules.d/99-resume.rules
Harald Hoyer 4734ec
+    fi
Harald Hoyer 4734ec
 fi