#!/bin/bash
#
#	/etc/init.d/pcDpush
#
# Starts the pcDpush.pl program which pushes data to a remote server of interest.  
#  Revised and adapted by M.H. 5/24/11      
#  Adapted to start pcDpush  10/23/14 M.H. 
#
# Source function library. 
. /lib/lsb/init-functions

RETVAL=0
prog=pcDpush   # Name of the program to be started/stopped minus its extention.    

start() {
        echo -n $"Starting $prog: "
        cd /home/ubuntu/cs3code  
        /home/ubuntu/cs3code/pcDpush.pl 1&2> /dev/null  &
	RETVAL=$?
	[ $RETVAL -eq 0 ] 
} #end start()

stop() {
	echo -n $"Stopping $prog: "
	killproc /home/ubuntu/cs3code/pcDpush.pl
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pcDpush #remove lock file
	echo
}   #end stop()

# See how we were called.
case "$1" in
  start)
	start
        echo "$prog started."
	;;
  stop)
	stop
        echo "Quiting $prog "
	;;
  reload|restart) 
        echo "restarting $prog"
	stop
	start
	RETVAL=$?
	;;
  condrestart)  #conditional restart only if already running. 
	if [ -f /var/lock/subsys/pcDpush ]; then
	    stop
	    start
	fi
	;;
  status)
	echo "status not implemented for $prog"
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"
	exit 1
esac
exit $RETVAL

