#! /bin/sh -e

. /etc/init.d/functions.sh

DESC="PoE class detection"

detect_poe_class() {
	local file=/var/run/poeclass

	begin "$1 $DESC"

	poeclass=$(readbits -a D14) || return 1

	echo $(($poeclass + 2)) > $file ||
		warning "Failed to edit poeclass file!"
}

case "$1" in
	start)
		detect_poe_class Starting
		end $?
		;;
	stop)
		;;
	restart)
		detect_poe_class Restarting
		end $?
		;;
	*)
		error "Usage: $0 start|stop|restart"
		;;
esac

exit 0
