#!/bin/bash

let DRAIN=-1

while getopts "10jyntfh" opt;  do
    case "$opt" in

	0)  let DRAIN=0
	    ;;

        n)  let DRAIN=0
            ;;

        f)  let DRAIN=0
            ;;

        1)  let DRAIN=1
            ;;

        j)  let DRAIN=1
            ;;

        y)  let DRAIN=1
            ;;

        t)  let DRAIN=1
            ;;

	h)  echo "Usage: $0"
	    echo "    clear/set draining"
	    echo "    -y set draining"
	    echo "    -n clear draining"
            echo "    -h gives this message"
	    exit 1;;
        
	*)
	    echo "See $0 -h for usage"
	    exit 1;;
    esac
done

if [ ${DRAIN} -eq 1 ] ; then
    echo "set draining..."
    touch /tmp/drain
    exit 1
elif [ ${DRAIN} -eq 0 ] ; then
    echo "clear draining..."
    rm -f /tmp/drain
    exit 0
else
    if [ -e /tmp/drain ] ; then
        echo "draining is set"
        exit 1
    else
        echo "draining is not set"
        exit 0
    fi
fi
