#!/bin/sh

##
# TBUPDDWU
##

. /etc/rc.common

StartService ()
{
    ConsoleMessage "Starting TBUPDDWU"

    while [ 1 ]
    do
	killall tbupddwu
	#sleep 10
    	/tbupddmx/tbupddwu 
	sleep 1
    done
}

StopService ()
{
    pid=`ps ax | awk '{if ($5 == "/tbupddmx/tbupddwu") print $1}'`
    if test "$pid" != ""; then
	ConsoleMessage "Stopping TBUPDDWU"
        kill -TERM "${pid}"
    else
        echo "TBUPDDWU is not running."
    fi
}

RestartService ()
{
    if pid=$(GetPID tbupddmx); then
        ConsoleMessage "Restarting TBUPDDWU"
        kill -HUP "${pid}"
    fi 

    StartService
}

RunService "$1"
