From ebd3d2e90e46ee0fe8fcbe4c1ce58bff856a7c3c Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Tue, 31 Mar 2015 14:57:55 +0200 Subject: Makefile: Remove suspend from clean --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5d6ebb5..eb261d9 100644 --- a/Makefile +++ b/Makefile @@ -41,4 +41,4 @@ install: cp -aP services/* ${DESTDIR}/etc/sv/ clean: - -rm -f halt pause suspend + -rm -f halt pause -- cgit 1.4.1 From dd28b115e62ab5e6253bd5f1fc98da05357e7e52 Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Tue, 31 Mar 2015 14:58:07 +0200 Subject: Makefile: Add .PHONY --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index eb261d9..55a040b 100644 --- a/Makefile +++ b/Makefile @@ -42,3 +42,5 @@ install: clean: -rm -f halt pause + +.PHONY: all install clean -- cgit 1.4.1 From 33589dc9db67d059a1fcd8135ab793fe08b87ad0 Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Tue, 31 Mar 2015 14:58:53 +0200 Subject: shutdown.sh -> shutdown --- Makefile | 2 +- shutdown | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ shutdown.sh | 72 ------------------------------------------------------------- 3 files changed, 73 insertions(+), 73 deletions(-) create mode 100755 shutdown delete mode 100755 shutdown.sh (limited to 'Makefile') diff --git a/Makefile b/Makefile index 55a040b..5747f5f 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ install: install -d ${DESTDIR}/${PREFIX}/sbin install -m755 halt ${DESTDIR}/${PREFIX}/sbin install -m755 pause ${DESTDIR}/${PREFIX}/sbin - install -m755 shutdown.sh ${DESTDIR}/${PREFIX}/sbin/shutdown + install -m755 shutdown ${DESTDIR}/${PREFIX}/sbin/shutdown install -m755 modules-load ${DESTDIR}/${PREFIX}/sbin/modules-load install -m755 zzz ${DESTDIR}/${PREFIX}/sbin ln -sf zzz ${DESTDIR}/${PREFIX}/sbin/ZZZ diff --git a/shutdown b/shutdown new file mode 100755 index 0000000..1fa8a5f --- /dev/null +++ b/shutdown @@ -0,0 +1,72 @@ +#!/bin/sh +# shutdown - shutdown(8) lookalike for runit + +single() { + runsvchdir single +} + +usage() { + echo "Usage: shutdown [-fF] [-kchPr] time [warning message]" >/dev/stderr; exit 1 +} + +action=single + +while getopts akrhPHfFnct: opt; do + case "$opt" in + a|n|H) echo "-$opt is not implemented" >/dev/stderr; exit 1;; + t) ;; + f) touch /fastboot;; + F) touch /forcefsck;; + k) action=true;; + c) action=cancel;; + h|P) action=halt;; + r) action=reboot;; + [?]) usage;; + esac +done +shift $(expr $OPTIND - 1) + +[ $# -eq 0 ] && usage + +time=$1; shift +message="${*:-system is going down}" + +if [ "$action" = "cancel" ]; then + kill $(cat /run/runit/shutdown.pid) + echo "${*:-shutdown cancelled}" | wall + exit +fi + +if ! touch /run/runit/shutdown.pid 2>/dev/null; then + echo "Not enough permissions to execute ${0#*/}" + exit 1 +fi +echo $$ >/run/runit/shutdown.pid + +case "$time" in + now) time=0;; + +*) time=${time#+};; + *:*) echo "absolute time is not implemented" >/dev/stderr; exit 1;; + *) echo "invalid time"; exit 1;; +esac + +if [ "$time" -gt 5 ]; then + echo "$message in $time minutes" | wall + echo -n "shutdown: sleeping for $time minutes... " + sleep $(expr '(' "$time" - 5 ')' '*' 60) + echo + time=5 +fi + +if [ "$time" -gt 0 ]; then + echo "$message in $time minutes" | wall + touch /etc/nologin + echo -n "shutdown: sleeping for $time minutes... " + sleep $(expr "$time" '*' 60) + echo + rm /etc/nologin +fi + +echo "$message NOW" | wall + +$action diff --git a/shutdown.sh b/shutdown.sh deleted file mode 100755 index 1fa8a5f..0000000 --- a/shutdown.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# shutdown - shutdown(8) lookalike for runit - -single() { - runsvchdir single -} - -usage() { - echo "Usage: shutdown [-fF] [-kchPr] time [warning message]" >/dev/stderr; exit 1 -} - -action=single - -while getopts akrhPHfFnct: opt; do - case "$opt" in - a|n|H) echo "-$opt is not implemented" >/dev/stderr; exit 1;; - t) ;; - f) touch /fastboot;; - F) touch /forcefsck;; - k) action=true;; - c) action=cancel;; - h|P) action=halt;; - r) action=reboot;; - [?]) usage;; - esac -done -shift $(expr $OPTIND - 1) - -[ $# -eq 0 ] && usage - -time=$1; shift -message="${*:-system is going down}" - -if [ "$action" = "cancel" ]; then - kill $(cat /run/runit/shutdown.pid) - echo "${*:-shutdown cancelled}" | wall - exit -fi - -if ! touch /run/runit/shutdown.pid 2>/dev/null; then - echo "Not enough permissions to execute ${0#*/}" - exit 1 -fi -echo $$ >/run/runit/shutdown.pid - -case "$time" in - now) time=0;; - +*) time=${time#+};; - *:*) echo "absolute time is not implemented" >/dev/stderr; exit 1;; - *) echo "invalid time"; exit 1;; -esac - -if [ "$time" -gt 5 ]; then - echo "$message in $time minutes" | wall - echo -n "shutdown: sleeping for $time minutes... " - sleep $(expr '(' "$time" - 5 ')' '*' 60) - echo - time=5 -fi - -if [ "$time" -gt 0 ]; then - echo "$message in $time minutes" | wall - touch /etc/nologin - echo -n "shutdown: sleeping for $time minutes... " - sleep $(expr "$time" '*' 60) - echo - rm /etc/nologin -fi - -echo "$message NOW" | wall - -$action -- cgit 1.4.1