#!/bin/bash

### BEGIN INIT INFO
# Provides: ccsserver
# Required-Start: $network
# Required-Stop:
# X-UnitedLinux-Default-Enabled: no
# Default-Start:  3 5
# Default-Stop:   0 2 1 6
# Description:    ClassControl Student Communication Server
### END INIT INFO

CCSSERVER_BIN=/usr/sbin/studentserver
CCS_NAME="ClassControl Student Communication Server"
NAME=studentserver
SSD=/sbin/start-stop-daemon

test -x $CCSSERVER_BIN || exit 5


case $1 in
  start)
     echo -n "Starting $CCS_NAME"
     $SSD --start --quiet --oknodo --exec $CCSSERVER_BIN & >/dev/null
     ;;
 
  stop)
     echo -n "Stoping $CCS_NAME"
     $SSD --stop --quiet --oknodo --exec $CCSSERVER_BIN & >/dev/null
     ;;
 
  restart)
     $0 stop
     $0 start
     ;;
 
  status)
     echo -n "Checking for $CCS_NAME: "
     if [ `pidof $NAME` ]
       then echo -n "Service running"
       else echo -n "Service not running"
     fi
     echo
     ;;
 
  *)
     echo "Use $0 { start | stop | restart | status }"
     ;;
esac
exit 0
