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 | |
parent | a2a1dae5f5472164dc2c2ab45b955a9787fd0afe (diff) | |
download | shutdownasap-c1cb34e5f2e155250e6c08fb317b41b1878e7a8d.tar.xz |
new option: -R reboots only if no shutdown was scheduled anyways
-rw-r--r-- | shutdownasap.1.in | 2 | ||||
-rwxr-xr-x | shutdownasap.in | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/shutdownasap.1.in b/shutdownasap.1.in index 65ee4af..bb327cd 100644 --- a/shutdownasap.1.in +++ b/shutdownasap.1.in @@ -9,6 +9,8 @@ suppress output .TP \fB-r\fR reboot instead of shutdown +\fB-R\fR +reboot instead of shutdown, if there is no shutdown scheduled yet .SH DESCRIPTION \fBshutdownasap\fP shuts down the computer after a certain directory becomes empty and certain processes are not running. For actually shutting down it calls \fBsudo shutdown\fP or \fBsudo reboot\fP for reboot. 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 |