#!/bin/sh /etc/rc.common
# Copyright (C) 2011 Draytek.com

START=53

start() {			
    if [ -e "/var/run/webportal.pid" ]; then
		echo "[WEB_PORTAL] webportal control applicatiion has started"	
	else	
		echo "[WEB_PORTAL] start webporatl control application ..."  
   		/usr/sbin/webportal &      	
   	fi	  		
}

restart() {
	if [ -e "/var/run/webportal.pid" ]; then
		echo "[WEB_PORTAL] restart webportal control application ..."
		stop
		PID=$(cat /var/run/webportal.pid 2> /dev/null)			  
        while [ -n "$PID" ]   
        do        
            sleep 1 
            PID=$(cat /var/run/webportal.pid 2> /dev/null)	                  
        done
		start
   	else	
		echo "[WEB_PORTAL] no process"
		echo "[WEB_PORTAL] start webporatl control application ..."  
   		/usr/sbin/webportal & 
	fi	
}
	
stop() { 	
	if [ -e "/var/run/webportal.pid" ]; then
		echo "[WEB_PORTAL] stop webportal control application ..."			
   		kill -SIGTERM $(cat /var/run/webportal.pid)				
	else
		echo "[WEB_PORTAL] webportal control applicatiion has stopped"
   	fi	
}
