2018-12-07 13:41:06 -06:00
|
|
|
#!/bin/sh
|
2017-05-31 13:15:32 -05:00
|
|
|
|
2020-11-20 14:55:26 -06:00
|
|
|
do_halt=false
|
2017-07-11 14:41:29 -05:00
|
|
|
while getopts :akrhPHfFnct: opt; do
|
2017-06-12 17:58:18 -05:00
|
|
|
case "$opt" in
|
2017-07-11 14:41:29 -05:00
|
|
|
a) ;;
|
|
|
|
k) ;;
|
2020-11-20 14:55:26 -06:00
|
|
|
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
|
|
|
|
;;
|
2017-07-11 14:41:29 -05:00
|
|
|
f) ;;
|
|
|
|
F) ;;
|
|
|
|
n) ;;
|
|
|
|
c) ;;
|
|
|
|
t) ;;
|
|
|
|
[?]) printf "%s\n" "${0##*/}: invalid command line option" >&2
|
2017-06-12 17:58:18 -05:00
|
|
|
exit 1
|
|
|
|
;;
|
2017-06-12 12:24:18 -05:00
|
|
|
esac
|
|
|
|
done
|
2017-06-12 17:58:18 -05:00
|
|
|
shift $((OPTIND-1))
|
2017-06-12 12:24:18 -05:00
|
|
|
|
2017-07-11 14:41:29 -05:00
|
|
|
if [ -z "${shutdown_arg}" ]; then
|
|
|
|
shutdown_arg=--single
|
2017-06-12 17:58:18 -05:00
|
|
|
fi
|
2017-06-12 12:24:18 -05:00
|
|
|
|
2020-11-20 14:55:26 -06:00
|
|
|
printf "%s %s\n" "@SBINDIR@/openrc-shutdown ${shutdown_arg}" "$@"
|
2017-07-11 14:41:29 -05:00
|
|
|
exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@"
|