Skip to content

Commit

Permalink
scripts/shutdown.in: fix sysvinit compatible shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
williamh committed Nov 20, 2020
1 parent 3ed4126 commit 38aaba2
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions 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) ;;
Expand All @@ -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} "$@"

0 comments on commit 38aaba2

Please sign in to comment.