#!/bin/sh

NAME=freepopsd
CONFFILE=@PREFIX@/etc/freepops/config.lua

case "$1" in

start)
	if [ -f $CONFFILE ]; then
		echo "Starting $NAME daemon"
		@PREFIX@/bin/$NAME -l syslog -p 110 -d
	else
		echo "Cannot start $NAME daemon: $CONFFILE does not exist!"
		exit 1
	fi
	;;

stop)
	if [ -f $PIDFILE ]; then
		echo "Stopping $NAME daemon"
		@PREFIX@/bin/$NAME -k
	else
		echo "Cannot stop $NAME daemon: $PIDFILE does not exist!"
		exit 1
	fi
	;;

restart)
	$0 stop
	$0 start
	;;

*)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;

esac

