#! /bin/bash
#
# psa-health-monitor-notificationd  - Parallels Panel Health Monitor Notification Daemon
#

### BEGIN INIT INFO
# Provides:          Parallels Panel Health Monitor Notification Daemon
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Should-Start:      $network $named $syslog $time
# Should-Stop:       $network $named $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Parallels Panel Health Monitor Notification Daemon
### END INIT INFO

set -efu

PATH=/sbin:/bin:/usr/sbin:/usr/bin

SERVICENAME="PP HM notification daemon"
SERVICE="psa-health-monitor-notificationd"
BINARY=/usr/bin/sw-engine
ARGUMENTS="-c /opt/psa/admin/conf/php.ini /usr/lib/plesk-9.0/psa-health-monitor-notification.php"
PIDFILE=/var/run/psa-health-monitor-notificationd.pid

# Gracefully exit if the package has been removed.
test -x $BINARY -a -s "/usr/lib/plesk-9.0/psa-health-monitor-notification.php" || exit 0

. /lib/lsb/init-functions

case "${1:-}" in
	start)
		log_daemon_msg "Starting $SERVICENAME " $SERVICE
		if start-stop-daemon --start --pidfile $PIDFILE --exec "$BINARY" 			--oknodo -q  -- $ARGUMENTS; then
			log_end_msg 0
		else
			log_end_msg 1
        fi
	;;
	stop)
		log_daemon_msg "Stopping $SERVICENAME" $SERVICE
		if start-stop-daemon --stop --pidfile $PIDFILE --exec $BINARY --oknodo -q; then
			log_end_msg 0
		else
			log_end_msg 1
        fi

	;;
	reload|force-reload|restart)
		$0 stop
		$0 start
	;;
	status)
		status_of_proc -p $PIDFILE $BINARY $SERVICE
	;;
	*)
		log_success_msg "Usage: $0 {start|stop|force-reload|restart|status}"
		exit 1
	;;
esac

exit 0;

# vim: syntax=sh noexpandtab sw=4 ts=4 :

