#!/bin/sh
# erserver	Simple eRServer startup/shutdown script
#
# chkconfig: 345 81 14
# description: A commercial Master to Multi-Slave database \
#              replication solution for PostgreSQL, used \
#              in high transaction volume environments.

ERSERVER_HOME=/opt/erserver

# Test if eRServer has been configured after installation
if [ ! -f "$ERSERVER_HOME"/etc/replication.cfg ] ; then
  exit 0
fi

case "$1" in
	*start)
		rm -f "$ERSERVER_HOME"/erserver.pid
		su - erserver -c "cd $ERSERVER_HOME/bin; ERS_QUIET=y; export ERS_QUIET; ./ers_ctl start"
		;;
	*stop)
		su - erserver -c "cd $ERSERVER_HOME/bin; ERS_QUIET=y; export ERS_QUIET; ./ers_ctl stop"
		sleep 10
		;;
	*)
		echo "Usage: $0 { start | stop }"
		exit 1
		;;
esac

exit 0
