diff options
author | Erich Eckner <git@eckner.net> | 2021-05-27 08:15:35 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2021-05-27 08:15:35 +0200 |
commit | c1cb34e5f2e155250e6c08fb317b41b1878e7a8d (patch) | |
tree | 008c0d24fead88161fa5beb1abeb38e51de865d6 /shutdownasap.in | |
parent | a2a1dae5f5472164dc2c2ab45b955a9787fd0afe (diff) | |
download | shutdownasap-c1cb34e5f2e155250e6c08fb317b41b1878e7a8d.tar.xz |
new option: -R reboots only if no shutdown was scheduled anyways
Diffstat (limited to 'shutdownasap.in')
-rwxr-xr-x | shutdownasap.in | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/shutdownasap.in b/shutdownasap.in index 7cce77e..a902cbf 100755 --- a/shutdownasap.in +++ b/shutdownasap.in @@ -24,8 +24,18 @@ while [ $# -gt 0 ]; do echo 'reboot' >"${tmpDir}/intention" intentionSet=true ;; + '-R') + if [ -r "${tmpDir}/intention" ] \ + && grep -qxF 'shutdown' "${tmpDir}/intention" \ + && [ -r "${tmpDir}/pid" ] \ + && kill -0 "$(cat "${tmpDir}/pid")"; then + exit + fi + echo 'reboot' >"${tmpDir}/intention" + intentionSet=true + ;; *) - >&2 echo 'usage: shutdownasap [-q] [-a|-r]' + >&2 echo 'usage: shutdownasap [-q] [-a|-r|-R]' exit 1 ;; esac |