diff options
author | Britney Fransen <brfransen@gmail.com> | 2014-04-05 19:49:18 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2014-04-05 19:49:18 (GMT) |
commit | bdefc1e81c89dbb12e7e914a9f1f220ee5ed1714 (patch) | |
tree | f8ed2037e4dab50bf0cdb4cdcb6a8b28d5f00694 /abs/core/poweroff-scripts/shutdown.script | |
parent | de6718e325ed5fdcb2b15cb567732321ecb14790 (diff) | |
download | linhes_pkgbuild-bdefc1e81c89dbb12e7e914a9f1f220ee5ed1714.zip linhes_pkgbuild-bdefc1e81c89dbb12e7e914a9f1f220ee5ed1714.tar.gz linhes_pkgbuild-bdefc1e81c89dbb12e7e914a9f1f220ee5ed1714.tar.bz2 |
poweroff-scripts: fix shutdown/reboot issue with /usr/bin move. refs #961
Diffstat (limited to 'abs/core/poweroff-scripts/shutdown.script')
-rw-r--r-- | abs/core/poweroff-scripts/shutdown.script | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/abs/core/poweroff-scripts/shutdown.script b/abs/core/poweroff-scripts/shutdown.script index b87b52f..ffc4056 100644 --- a/abs/core/poweroff-scripts/shutdown.script +++ b/abs/core/poweroff-scripts/shutdown.script @@ -1,46 +1,50 @@ #!/bin/bash MYTH_RUN_STATUS="1" . /etc/profile + +usage() { echo "Usage: $0 [-h | -r] [-t <delay> (opt)]" 1>&2; exit 1; } + INIT=`ps -p 1 -o comm=` if [ x$INIT = xrunit ] then - reboot="" - halt="" - delay="" - while getopts rht: name - do - case $name in - r) reboot=1 ;; - h) halt=1 ;; - t) delay="$OPTARG" - if [ x$delay = "xnow" ] - then - delay=0 - fi - ;; - *) - exit 2;; - esac - done - if [ x$delay = x ] - then - delay=0 + halt="" + reboot="" + delay="" + while getopts hrt: name + do + case $name in + h) halt=1 ;; + r) reboot=1 ;; + t) delay="$OPTARG" + if [ x$delay = "xnow" ] + then + delay=0 + fi + ;; + *) usage ;; + esac + done + if [ x$delay = x ] + then + delay=0 fi - - if [ x$reboot = x1 ] - then - echo "System will reboot in $delay seconds" | wall - sleep $delay - /sbin/runit-init 6 - fi - - if [ x$halt = x1 ] - then - echo "System will poweroff in $delay seconds" | wall - sleep $delay - /sbin/runit-init 0 - fi - + if [ x$halt = x1 ] + then + chvt 1 + echo "System will shutdown in $delay seconds..." | wall + sleep $delay + runit-init 0 + exit 0 + fi + if [ x$reboot = x1 ] + then + chvt 1 + echo "System will reboot in $delay seconds..." | wall + sleep $delay + runit-init 6 + exit 0 + fi + usage else - /sbin/shutdown.init $@ + systemctl poweroff $@ fi |