#!/bin/sh
### BEGIN INIT INFO
# Provides:          osmo-pcap-client
# Required-Start:    $network $local_fs
# Should-Start:      
# Required-Stop:     
# Should-Stop:       
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the pcap client
# Description:       PCAP Client for the PCAP aggregation
### END INIT INFO
# vendor prefix.TH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=osmo-pcap-client             # Introduce a short description here
NAME=osmo-pcap-client             # Introduce the short server's name here
DAEMON=/usr/bin/osmo_pcap_client # Introduce the server's location here
DAEMON_ARGS="-D -c /etc/osmo-pcap/osmo-pcap-client.cfg"  # Arguments to run the daemon with
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
 
. /lib/lsb/init-functions
RETVAL=0
 
 
case "$1" in
    start)
	echo -n "Starting osmo-pcap-client "
	start_daemon -p $PIDFILE $DAEMON $DAEMON_ARGS
	RETVAL=$?
	;;
    stop)
	echo -n "Shutting down osmo-pcap-client "
	killproc $DAEMON
	RETVAL=$?
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start
 
	# Remember status and be quiet
	RETVAL=$?
	;;
    status)
        echo -n "Checking for service osmo-pcap-client "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.
 
	# Return value is slightly different for the status command:
	# 0 - service up and running
	# 1 - service dead, but /var/run/  pid  file exists
	# 2 - service dead, but /var/lock/ lock file exists
	# 3 - service not running (unused)
	# 4 - service status unknown :-(
	# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
	
	# NOTE: checkproc returns LSB compliant status values.
	/sbin/checkproc $DAEMON
	RETVAL=$?
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
        ;;
esac
exit $RETVAL
