2018-12-08 01:11:06 +05:30
|
|
|
#!/bin/sh
|
2017-05-31 23:45:32 +05:30
|
|
|
|
2020-11-21 02:25:26 +05:30
|
|
|
do_halt=false
|
2017-07-12 01:11:29 +05:30
|
|
|
while getopts :akrhPHfFnct: opt; do
|
2017-06-13 04:28:18 +05:30
|
|
|
case "$opt" in
|
2017-07-12 01:11:29 +05:30
|
|
|
a) ;;
|
|
|
|
k) ;;
|
2020-11-21 02:25:26 +05:30
|
|
|
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-12 01:11:29 +05:30
|
|
|
f) ;;
|
|
|
|
F) ;;
|
|
|
|
n) ;;
|
|
|
|
c) ;;
|
|
|
|
t) ;;
|
|
|
|
[?]) printf "%s\n" "${0##*/}: invalid command line option" >&2
|
2017-06-13 04:28:18 +05:30
|
|
|
exit 1
|
|
|
|
;;
|
2017-06-12 22:54:18 +05:30
|
|
|
esac
|
|
|
|
done
|
2017-06-13 04:28:18 +05:30
|
|
|
shift $((OPTIND-1))
|
2017-06-12 22:54:18 +05:30
|
|
|
|
2017-07-12 01:11:29 +05:30
|
|
|
if [ -z "${shutdown_arg}" ]; then
|
|
|
|
shutdown_arg=--single
|
2017-06-13 04:28:18 +05:30
|
|
|
fi
|
2017-06-12 22:54:18 +05:30
|
|
|
|
2020-11-21 02:25:26 +05:30
|
|
|
printf "%s %s\n" "@SBINDIR@/openrc-shutdown ${shutdown_arg}" "$@"
|
2017-07-12 01:11:29 +05:30
|
|
|
exec @SBINDIR@/openrc-shutdown ${shutdown_arg} "$@"
|