#! /bin/sh
### entry for chkconfig on Redhat and Debian or for sysv-rc-conf on Ubuntu.
### RPM instalator uses it
#
# LG-connect  Script to start and stop LG_Connect
#
# chkconfig: 2345 78 31
# description: License Generator 4 Kerio Connect
# processname: LG_Connect
#
### entry for update-rc.d on Debian and Ubuntu
### DEB instalator uses it
#
### BEGIN INIT INFO
# Provides:          LC-connect
# Required-Start:    $network $local_fs $remote_fs $time
# Required-Stop:     $network $local_fs $remote_fs $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start and stop LG_Connect daemon 
### END INIT INFO

#
# Start/stops the LG_Connect daemon .
#

DESC="License Generator 4 Kerio Connect"           # this name is write to console
MAINDIR=/opt/kerio/mailserver
LG=LG_Connect

unset TMPDIR

case "$1" in
	start)
		echo -n "Starting "$DESC

		if ! $MAINDIR/$LG -daemon; then
			echo "[FAIL]"
			exit 1
		fi
		echo " [OK]"
		;;
	stop)
		echo -n "Stopping "$DESC
		killall -s 9 $LG
                echo " [OK]"
		;;
	restart|force-reload)
		$0 stop
		sleep 1
		$0 start
		;;
	*)
		echo "Usage: /etc/init.d/mirrorkc {start|stop|restart|force-reload}"
		exit 1
		;;
esac

exit 0
