#!/bin/bash
#
# chkconfig: 35 92 12
# description: Ejudge server
#
# Get function from functions library
#. /etc/init.d/functions
# Start the service Ejudge

### BEGIN INIT INFO
# Provides:          ejudge
# Required-Start:    mysqld $local_fs
# Required-Stop:     
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
# Short-Description: ejudge programming contest management system
### END INIT INFO

# $Id$

USER="ejudge"
NAME="ejudge"
EJUDGE_CTR="ejudge-control" 

start() {
        exec su -c "$EJUDGE_CTR start" - $USER
        ### Create the lock file ###
        touch /var/lock/subsys/$NAME
        success $"Ejudge server startup"
        echo
}
# Restart the service FOO
stop() {
        exec su -c "$EJUDGE_CTR stop" - $USER
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/$NAME
        success $"Ejudge server stop"
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        echo -n "Non implemented"
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0
