summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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