#!/bin/bash

source /etc/profile

action=$1
# delay=$2
# program=`which $action`
# usage="usage: $0 [reboot|poweroff] [delay=3]\n"
# [ -z "$action" -o -z "$program" ] && {
# 	echo $usage
# 	exit 1
# }
# [ ! -e "$program" ] && {
# 	echo "$action not found\n"
# 	exit 1
# }
# [ -z "$delay" ] && delay=5
#
# if grep -v '^[[:digit:]]*$' <<< "$delay"; then
# 	delay=5
# fi
#
# sleep $delay
#
# exec "$program"

usage="usage: $0 [reboot|poweroff]"

if [ "$action" = "reboot" ] || [ "$action" = "poweroff" ]; then
    "$action"
else
    echo "$usage"
fi
