diff options
author | Erich Eckner <git@eckner.net> | 2020-04-26 01:11:22 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-04-26 01:11:22 +0200 |
commit | acadd862152c0c6978d97ed5737db88c36a7f485 (patch) | |
tree | 4e623b54ea048c855926e16613a8b39a604501af /shutdownasap.in | |
parent | 2410bc7ffc775ec49e6e7913e0b5e37118c1f02a (diff) | |
download | shutdownasap-acadd862152c0c6978d97ed5737db88c36a7f485.tar.xz |
can now reboot with -r
Diffstat (limited to 'shutdownasap.in')
-rwxr-xr-x | shutdownasap.in | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/shutdownasap.in b/shutdownasap.in index 146725a..4bcd2e8 100755 --- a/shutdownasap.in +++ b/shutdownasap.in @@ -11,12 +11,22 @@ set -e echo $$ > "${pidFile}" quiet=false -if [ $# -eq 1 ] && [ "x$1" = 'x-q' ]; then - quiet=true -elif [ $# -ne 0 ]; then - >&2 echo 'usage: shutdownasap [-q]' - exit 1 -fi +reboot=false +while [ $# -gt 0 ]; do + case "$1" in + '-q') + quiet=true + ;; + '-r') + reboot=true + ;; + *) + >&2 echo 'usage: shutdownasap [-q] [-r]' + exit 1 + ;; + esac + shift +done beforeWatchHook @@ -109,4 +119,8 @@ done beforeShutDownHook -sudo /sbin/poweroff +if ${reboot}; then + sudo /sbin/reboot +else + sudo /sbin/poweroff +fi |