summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-05-27 08:15:35 +0200
committerErich Eckner <git@eckner.net>2021-05-27 08:15:35 +0200
commitc1cb34e5f2e155250e6c08fb317b41b1878e7a8d (patch)
tree008c0d24fead88161fa5beb1abeb38e51de865d6
parenta2a1dae5f5472164dc2c2ab45b955a9787fd0afe (diff)
downloadshutdownasap-c1cb34e5f2e155250e6c08fb317b41b1878e7a8d.tar.xz
new option: -R reboots only if no shutdown was scheduled anyways
-rw-r--r--shutdownasap.1.in2
-rwxr-xr-xshutdownasap.in12
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