#!/bin/sh

# Config file for /etc/init.d/sancp

# Interface to listen on
IFACE="eth0"

# Pid number
PIDFILE="/var/run/mysancp.pid"

# Directory to log in 
LOGDIR="/var/log/sancp"

# Default config file
CONF="/etc/sancp/sancp.conf"

# You could add more options :)
SANCP_OPTS="-D -d $LOGDIR/today -i $IFACE -c $CONF -u sancp -g sancp -p $PIDFILE"

SANCP_BIN="/usr/local/bin/sancp"

SANCPPID=`cat $PIDFILE`

case "$1" in
 start)
  	$SANCP_BIN $SANCP_OPTS 
	;;

 hup)
	kill -HUP $SANCPPID
	;;

 stop)
	kill $SANCPPID
	;;

 usr1)
	kill -USR1 $SANCPPID
	;;

 usr2)
	kill -USR2 $SANCPPID
	;;

 status)
	if [ `ps | grep "$SANCPPID" | wc -l ` -gt "0"  ]; then

		echo "sancp is running"
	else
		echo "sancp is stopped"
	
	fi 
	;;
esac
