#!/bin/sh
case "$1" in
halt|poweroff)
	runlevel=0
	;;
reboot)
	runlevel=6
	;;
*)
	echo "Have to use $0 [reboot|halt|poweroff]"
	exit 1
	;;
esac

action="$1"

# this will emulate runlevel for rc-scripts
set -- $runlevel unknown
. /etc/rc.d/rc.shutdown

# as we passed previous runlevel as unknown to rc-scripts,
# we can reboot/shutdown/poweroff ourself.
exec /sbin/system_off "$action"
