diff options
author | Till Maas <opensource@till.name> | 2008-04-28 03:00:22 +0200 |
---|---|---|
committer | Till Maas <opensource@till.name> | 2008-04-28 03:00:22 +0200 |
commit | a068f3fbc7c522bba62991dd7ffc7a2eb4aeee2e (patch) | |
tree | ad36fbc5dd5b9df523bc4c5e66cb39a09cdd3d32 /src | |
parent | 3c12201486d6470e6f3596704f8d305e71a143ea (diff) |
- do not run hooks if do_$METHOD does not exist
- log it when it does not exist
- log abortion because of $INHIBIT
Diffstat (limited to 'src')
-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 |