aboutsummaryrefslogtreecommitdiff
path: root/scripts/shutdown.in
blob: 69a4a12a09d5bb2f1d15fce89392c58f68a917c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!@SHELL@

poweroff_arg=
while getopts :HhPr opt; do
	case "$opt" in
		h|P) poweroff_arg=--poweroff ;;
		H) poweroff_arg=--halt ;;
		r) poweroff_arg=--reboot ;;
		\?) printf "${0##*/}: invalid option ${optarg}\n" >&2
		exit 1
		;;
	esac
done
shift $((OPTIND-1))

if [ -z "${poweroff_arg}" ]; then
	poweroff_arg=--single
fi

echo @SBINDIR@/openrc-shutdown ${poweroff_arg} ${@}
exec @SBINDIR@/openrc-shutdown ${poweroff_arg} ${@}