#!/bin/sh
#
# sybase:       Starts the available Servers
#
# Version:      @(#) /etc/rc.d/init.d/sybase 1.2
#
# chkconfig: 345 85 15
#
# description: This script will browse through the /opt/sybase/install \
#              directory and launch all servers configured from this location.

# Source function library.
#Not in SGL...
#. /etc/rc.d/init.d/functions

# SYBASE should point to the system administrated server area
#
# Check for the correct SYBASE release area below.
# The queryformat should provide the correct setting on the installprefix.
SYBASE=/opt/lunar/sybase
#export SYBASE=`rpm -q --queryformat '%{installprefix}' sybase-ase-11.0.3.3`

if [ -n "${SYBASE}" -a -d "${SYBASE}" ]; then

  PATH="${SYBASE}/bin:${SYBASE}/install:${PATH}"
  export SYBASE PATH

  # See how we were called.
  case "$1" in
    start)
	echo -n "Starting Sybase ASE ... "
	( cd ${SYBASE}/install ; \
	  unset LANG ; unset LC_ALL ; \

	  for run_server in RUN_* ; do \
	      su -c "startserver -f ${run_server}" sybase > /dev/null 2>&1 ; \
	      echo -n "${run_server} " ; \
	  done )
	echo

	touch /var/lock/subsys/sybase
	;;

    stop)
	echo -n "Shuting down Sybase ASE configured servers: "
	killall dataserver
	killall backupserver
	killall monserver

	# Add your own openserver applications.
	echo
	;;

    status)
	showserver
	;;

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

fi

exit 0

