aboutsummaryrefslogtreecommitdiff
path: root/scripts/shutdown.in
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2020-11-20 14:55:26 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2020-11-20 14:57:04 -0600
commit38aaba28ee86602e29d8a31f155dfa72f5481e68 (patch)
treefa3329b4271fcdfecb238cefb2c26b1176b764ad /scripts/shutdown.in
parent3ed4126a31406124ae8042fc3d4c0bf963d6961e (diff)
scripts/shutdown.in: fix sysvinit compatible shutdown
X-Gentoo-Bug: https://bugs.gentoo.org/755422
Diffstat (limited to 'scripts/shutdown.in')
-rw-r--r--scripts/shutdown.in29
1 files changed, 23 insertions, 6 deletions
diff --git a/scripts/shutdown.in b/scripts/shutdown.in
index af3ea2b3..23e5e31d 100644
--- a/scripts/shutdown.in
+++ b/scripts/shutdown.in
@@ -1,14 +1,31 @@
#!/bin/sh
-shutdown_arg=
+do_halt=false
while getopts :akrhPHfFnct: opt; do
case "$opt" in
a) ;;
k) ;;
- r) shutdown_arg=--reboot ;;
- h) shutdown_arg=--halt ;;
- P) shutdown_arg=--poweroff ;;
- H) shutdown_arg=--halt ;;
+ r)
+ shutdown_arg=--reboot
+ ;;
+ h)
+ do_halt=true
+ shutdown_arg=--poweroff
+ ;;
+ P)
+ if ! ${do_halt}; then
+ printf "%s\n" "The -P flag requires the -h flag" >&2
+ exit 1
+ fi
+ shutdown_arg=--poweroff
+ ;;
+ H)
+ if ! ${do_halt}; then
+ printf "%s\n" "The -H flag requires the -h flag" >&2
+ exit 1
+ fi
+ shutdown_arg=--halt
+ ;;
f) ;;
F) ;;
n) ;;
@@ -25,5 +42,5 @@ if [ -z "${shutdown_arg}" ]; then
shutdown_arg=--single
fi
-echo @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@"
+printf "%s %s\n" "@SBINDIR@/openrc-shutdown ${shutdown_arg}" "$@"
exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@"