From c1cb34e5f2e155250e6c08fb317b41b1878e7a8d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 27 May 2021 08:15:35 +0200 Subject: new option: -R reboots only if no shutdown was scheduled anyways --- shutdownasap.1.in | 2 ++ shutdownasap.in | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2