#!/bin/sh 
#
# description: Exalt Daemon control script
# probe: true

# /etc/init.d/exalt_daemon
#
### BEGIN INIT INFO
# Provides:          exalt_daemon
# Required-Start:    $remote_fs network
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:
# Description:       Exalt Daemon control script
### END INIT INFO

set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/e17/sbin:/opt/e17/bin
DAEMON=/usr/sbin/exalt-daemon
PIDFILE=/var/run/exaltd.pid

test -x $DAEMON || exit 0

case "$1" in
  start)
	echo -n "Starting Exalt Daemon..."
	if [ -f $PIDFILE ] ; then 
		echo "Running already!"
		exit 0
	else
		set -e
		$DAEMON
	fi
	echo "Done!"
  ;;
  stop)
	echo -n "Stopping Exalt Daemon..."
	if [ -f $PIDFILE ]; then 
		##kill -9 `cat $PIDFILE` 
		killall -9 exalt-daemon
		rm $PIDFILE
	else
		echo -n "Not running..."
	fi
	echo "Done!"
  ;;
  restart)
	$0 stop
	$0 start
  ;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
  ;;
esac

exit 0

