#!/bin/sh

# ispCP ω (OMEGA) a Virtual Hosting Control Panel
# Copyright (C) 2006-2010 by isp Control Panel - http://ispcp.net
#
# Version: $Id: ispcp_daemon 2505 2010-01-06 20:30:53Z nuxwin $
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is "ispCP ω (OMEGA) a Virtual Hosting Control Panel".
#
# The Initial Developer of the Original Code is ispCP Team.
# Portions created by Initial Developer are Copyright (C) 2006-2010 by
# isp Control Panel. All Rights Reserved.
#
# The ispCP ω Home Page is:
#
#    http://isp-control.net
#

### BEGIN INIT INFO
# Provides:             ispcp_daemon
# Required-Start:       $network $local_fs $remote_fs
# Required-Stop:
# Should-Stop:          $local_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    ispCP GUI-Backend communication Daemon
### END INIT INFO
# Note: do not modify any of these vars here, use /etc/default/$NAME instead

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/var/www/ispcp/daemon/ispcp_daemon
PID=/var/run/ispcp-daemon.pid
NAME=ispcp_daemon
DESC=ispcp_daemon


test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	$DAEMON -p $PID
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	kill -9 `cat $PID`
        rm -f $PID
	echo "$NAME."
	;;
  restart|force-reload)
	$0 stop
	$0 start
	echo "$NAME."
	;;

  *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
