#!/bin/sh
PIDWOLPROXY_PLUGIN="/var/run/WOLProxy.pid"
WOLPROXY_PLUGIN="/bin/pcb_plugin -vv -n WOLProxy -c /usr/lib/wolproxy/wolproxy.odl"

start() {

    if [ -e ${PIDWOLPROXY_PLUGIN} ]; then
        echo "Wake On LAN Proxy plug-in already started"
    else
        ${WOLPROXY_PLUGIN};
    fi
}

stop() {
    if [ -e ${PIDWOLPROXY_PLUGIN} ]; then
        kill $(cat ${PIDWOLPROXY_PLUGIN});
    else
        echo "Wake On LAN Proxy stopped"
    fi
}

restart() {
    stop
    while test -e ${PIDWOLPROXY_PLUGIN}; do
        sleep 1
    done
    start
}

case $1 in
    start)
        start
	;;
    stop)
        stop
	;;
    restart)
        restart
        ;;
    backup)
	;;
    restore)
	;;
    *)
        ;;
esac

