diff options
-rw-r--r-- | src/pm-action.in | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/pm-action.in b/src/pm-action.in index af67263..bc6715e 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -1,5 +1,5 @@ #!/bin/sh -# +# vim: noexpandtab # Simple suspend script # # Copyright 2006 Red Hat, Inc. @@ -72,15 +72,24 @@ load_hook_parameters # Make sure we are not inhibited before we start. rm -f "${INHIBIT}" -# run the sleep hooks -log "$(date): Running hooks for $ACTION." -run_hooks sleep "$ACTION" -log "$(date): ${METHOD}ing" -# Sleep only if we know how and if a hook did not inhibit us. -command_exists "do_$METHOD" && [ ! -e "$INHIBIT" ] && { sync; "do_$METHOD"; } -log "$(date): Awake." -log "$(date): Running hooks for $REVERSE" -# run the sleep hooks in reverse with the wakeup action -run_hooks sleep "$REVERSE" reverse -log "$(date): Finished." - +if [ command_exists "do_$METHOD" ]; then + # run the sleep hooks + log "$(date): Running hooks for $ACTION." + run_hooks sleep "$ACTION" + # Sleep only if we know how and if a hook did not inhibit us. + if [ ! -e "$INHIBIT" ]; then + log "$(date): performing $METHOD" + sync + "do_$METHOD" + log "$(date): Awake." + else + log "$(date): Inhibit found, will not perform $METHOD" + fi + log "$(date): Running hooks for $REVERSE" + # run the sleep hooks in reverse with the wakeup action + run_hooks sleep "$REVERSE" reverse + log "$(date): Finished." +else + log "$(date): Missing module to perform $METHOD - abort." + exit 1 +fi |