#!/bin/bash

#
# chkconfig: 35 99 10
# description: Starts and stops Oracle processes
#

# ORACLE_HOME=/u01/app/oracle/product/10.2.0
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
SID_LIST='pcarddr'

case "$1" in

'start')
su - $ORA_OWNER -c /home/oracle/bin/dbstart_standby > /dev/null 2>&1 &
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" > /dev/null 2>&1 &

if [ -f $ORACLE_HOME/bin/emctl ]; then
  for sid in $SID_LIST; do
    echo  "Starting EM for $sid"
    su - $ORA_OWNER -c "export ORACLE_SID=$sid; $ORACLE_HOME/bin/emctl start dbconsole &"
  done
fi

#if [ -f $ORACLE_HOME/bin/isqlplusctl ]; then
  #for sid in $SID_LIST; do
    #echo  "Starting iSQL*plus for $sid"
    #su - $ORA_OWNER -c "export ORACLE_SID=$sid; $ORACLE_HOME/bin/isqlplusctl start"
  #done
#fi

touch /var/lock/subsys/dbora
;;

'stop')
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop" > /dev/null 2>&1 &
su - $ORA_OWNER -c $ORACLE_HOME/bin/dbshut > /dev/null 2>&1 &

if [ -f $ORACLE_HOME/bin/emctl ]; then
  for sid in $SID_LIST; do
    echo "Stopping EM for $sid"
    su - $ORA_OWNER -c "export ORACLE_SID=$sid; $ORACLE_HOME/bin/emctl stop dbconsole"
  done
fi

#if [ -f $ORACLE_HOME/bin/isqlplusctl ]; then
  #for sid in $SID_LIST; do
    #echo  "Stopping iSQL*plus for $sid"
    #su - $ORA_OWNER -c "export ORACLE_SID=$sid; $ORACLE_HOME/bin/isqlplusctl stop"
  #done
#fi

rm -f /var/lock/subsys/dbora
;;

esac

# End of script dbora
