diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 44 | ||||
-rw-r--r-- | shutdownasap.8.in | 36 | ||||
-rwxr-xr-x | shutdownasap.conf.in (renamed from shutdownasap.conf) | 8 | ||||
-rwxr-xr-x | shutdownasap.in (renamed from shutdownasap) | 4 |
5 files changed, 94 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03c8959 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +shutdownasap +shutdownasap.8 +shutdownasap.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2eb0c1e --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# +# shutdownasap - simple script for shutdown waiting for certain processes and files to disapear +# +# Copyright (c) 2015-2016 Erich Eckner <opensource at eckner dot net> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. +# + +DESTDIR = +ETCDIR = /etc +BINDIR = /usr/bin +MANDIR = /usr/share/man + +VERSION = 0.2 + +all: shutdownasap shutdownasap.conf shutdownasap.8 + +%: %.in + sed "s/#VERSION#/$(VERSION)/; s@#BINDIR#@$(BINDIR)@; s@#ETCDIR#@$(ETCDIR)@" $< > $@ + +.PHONY: install clean + +install: all + install -D -m0755 -t $(DESTDIR)$(BINDIR) shutdownasap + install -D -m0644 -t $(DESTDIR)$(MANDIR)/man8 shutdownasap.8 + install -D -m0644 -t $(DESTDIR)$(ETCDIR) shutdownasap.conf + +clean: + rm -f shutdownasap{,.8,.conf} + +# End of file diff --git a/shutdownasap.8.in b/shutdownasap.8.in new file mode 100644 index 0000000..34e3aad --- /dev/null +++ b/shutdownasap.8.in @@ -0,0 +1,36 @@ +.TH shutdownasap 8 "" "shutdownasap #VERSION#" "" +.SH NAME +shutdownasap \- simple script for \fBshutdown\fP waiting for certain processes and files to disapear +.SH SYNOPSIS +\fBshutdownasap\fP +.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. +.SH CONFIGURATION +The configfile \fB#ETCDIR#/shutdownasap.conf\fP is a bash script, which defines the following variables and routines: +.TP +.B "pidFile" +file to store pid in +.TP +.B "waitForDir" +directory which must be empty before shutting down +.TP +.B "shutDownNoGos" +list of processes which must not be running before shutting down +.TP +.B "beforeWatchHook" +routine which is called after start of \fBshutdownasap\fP, before watching above conditions +.TP +.B "beforeShutDownHook" +routine which is called before shutting down +.SH FILES +.TP +.B "#BINDIR#/shutdownasap" +program file +.TP +.B "#ETCDIR#/shutdownasap.conf" +contains configuration +.SH AUTHOR +.nf +Erich Eckner <opensource at eckner dot net> +.fi diff --git a/shutdownasap.conf b/shutdownasap.conf.in index 50d32eb..cb8e603 100755 --- a/shutdownasap.conf +++ b/shutdownasap.conf.in @@ -1,9 +1,15 @@ #!/bin/bash +# configuration file for shutdownasap version #VERSION# +# it should be named #ETCDIR#/shutdownasap.conf +# shutdownasap's pid pidFile="/tmp/shutdownasap.pid" + +# directory must be empty before shutdown waitForDir="/home/shutdown/.warteauf" +# list of processes which must not be running before shutdown declare -A shutDownNoGos shutDownNoGos["backup"]="[^/ ]*backup" @@ -15,10 +21,12 @@ shutDownNoGos["rsync"]="rsync" shutDownNoGos["wget"]="wget" shutDownNoGos["wetter"]="/tmp/wetter.pid" +# hook to execute after start of shutdownasap, before watching above conditions beforeWatchHook() { true } +# hook to execute before shutting down beforeShutDownHook() { true } diff --git a/shutdownasap b/shutdownasap.in index 027511b..0afd586 100755 --- a/shutdownasap +++ b/shutdownasap.in @@ -1,6 +1,8 @@ #!/bin/bash -. /etc/shutdownasap.conf +# shutdownasap version #VERSION# + +. #ETCDIR#/shutdownasap.conf [ -r "${pidFile}" ] && ps aux | grep -q "^\S\+\s\+$(cat "${pidFile}") " && exit |