#!/bin/sh

# chkconfig: 2345 98 02
# description: EnterpriseDB RDBMS

# This is a Sys-V startup script for the 
# EnterpriseDB Database Server

# This script will automatically start or stop EnterpriseDB clusters
# if an entry in /etc/edbtab specifies that the cluster should
# be started at system boot time.
#
# All entries in the /etc/edbtab file with a Y will be started or shutdown
# during system boot or shutdown.
#
# This script can be manually run to start or stop all clusters listed in
# the /etc/edbtab file, i.e ./edb_autostart start|stop

#Installation prefix(e.g /opt/PostgresPlus/9.3AS)
prefix=/opt/PostgresPlus/9.3AS

#User who runs postmaster process.  Typically "enterprisedb". Never "root"
EDBUSER=enterprisedb

#path to EnterpriseDB home
EDBHOME=$prefix/

# Print to screen function
# echo does not behave the same across all
# platforms, use printf
ECHO_N="printf"


# The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# Path to postmaster
DAEMON="$prefix/bin/edb-postmaster"

#set -e
set +x

# Start/Stop

# Parse command line parameters.
case $1 in
start)
		su $EDBUSER -c "$EDBHOME/scripts/server/autostart/edbstart"
		;;
stop)
		su $EDBUSER -c "$EDBHOME/scripts/server/autostart/edbstop"
		;;
  
  *)
	# Print help
	echo "Usage: $0 {start|stop}" 1>&2 
	exit 1
		;;
esac

exit 0
