scripts/shutdown.in: fix sysvinit compatible shutdown

X-Gentoo-Bug: https://bugs.gentoo.org/755422
This commit is contained in:
William Hubbs 2020-11-20 14:55:26 -06:00
parent 3ed4126a31
commit 38aaba28ee

View File

@ -1,14 +1,31 @@
#!/bin/sh #!/bin/sh
shutdown_arg= do_halt=false
while getopts :akrhPHfFnct: opt; do while getopts :akrhPHfFnct: opt; do
case "$opt" in case "$opt" in
a) ;; a) ;;
k) ;; k) ;;
r) shutdown_arg=--reboot ;; r)
h) shutdown_arg=--halt ;; shutdown_arg=--reboot
P) shutdown_arg=--poweroff ;; ;;
H) shutdown_arg=--halt ;; 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) ;;
F) ;; F) ;;
n) ;; n) ;;
@ -25,5 +42,5 @@ if [ -z "${shutdown_arg}" ]; then
shutdown_arg=--single shutdown_arg=--single
fi fi
echo @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@" printf "%s %s\n" "@SBINDIR@/openrc-shutdown ${shutdown_arg}" "$@"
exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@" exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@"