From acadd862152c0c6978d97ed5737db88c36a7f485 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 26 Apr 2020 01:11:22 +0200 Subject: can now reboot with -r --- shutdownasap.1.in | 7 +++++-- shutdownasap.in | 28 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/shutdownasap.1.in b/shutdownasap.1.in index d8d9138..51c804c 100644 --- a/shutdownasap.1.in +++ b/shutdownasap.1.in @@ -2,13 +2,16 @@ .SH NAME shutdownasap \- simple script for \fBshutdown\fP waiting for certain processes and files to disapear .SH SYNOPSIS -\fBshutdownasap [-q]\fP +\fBshutdownasap [-q] [-r]\fP .TP \fB-q\fR suppress output +.TP +\fB-r\fR +reboot instead of shutdown .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. +For actually shutting down it calls \fBsudo shutdown\fP or \fBsudo reboot\fP for reboot. .SH CONFIGURATION The configfile \fB#ETCDIR#/shutdownasap.conf\fP is a bash script, which defines the following variables and routines: .TP diff --git a/shutdownasap.in b/shutdownasap.in index 146725a..4bcd2e8 100755 --- a/shutdownasap.in +++ b/shutdownasap.in @@ -11,12 +11,22 @@ set -e echo $$ > "${pidFile}" quiet=false -if [ $# -eq 1 ] && [ "x$1" = 'x-q' ]; then - quiet=true -elif [ $# -ne 0 ]; then - >&2 echo 'usage: shutdownasap [-q]' - exit 1 -fi +reboot=false +while [ $# -gt 0 ]; do + case "$1" in + '-q') + quiet=true + ;; + '-r') + reboot=true + ;; + *) + >&2 echo 'usage: shutdownasap [-q] [-r]' + exit 1 + ;; + esac + shift +done beforeWatchHook @@ -109,4 +119,8 @@ done beforeShutDownHook -sudo /sbin/poweroff +if ${reboot}; then + sudo /sbin/reboot +else + sudo /sbin/poweroff +fi -- cgit v1.2.3-54-g00ecf