#!/bin/bash

printAd() {
	cat << EOS
HibernationSupportedStates = "S5"
HibernationMethod = "halt"
HibernationRawMask = 16
CurrentTime = time()
EOS
}

setState(){
	case "$1" in
		"S5"| "5"| "SHUTDOWN"| "OFF")
			echo setting state $1
			/sbin/halt
			;;
	esac
}

printHelp() {
	echo "usage: $0 [OPTIONS] (ad|set <level>)"
	echo "$0 - shutdown machine"
	echo "-h|--help		This message"
	echo "ad		Output capabilities ad"
	echo "set <state>	Switch to <state>, only S5 is supported"
}

case "$1" in
	ad)	
		printAd
		;;
	set)
        	shift
		setState $@
	        ;;
	-h|--help)
		printHelp
		;;
esac
