15 March 2006

Automatic starting of Oracle components on Unix

General instructions:

Additional instructions forHP:
#!/sbin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/usr/local/bin
PATH=$ORACLE_HOME/bin:$PATH
export PATH ORACLE_HOME

rval=0

set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script Failed
fi
}

case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the "start" argument; this message appears as part of the checklist.
echo "Starting the Oracle components"
;;

'stop_msg')
# Emit a _short_ message relating to running this script with
# the "stop" argument; this message appears as part of the checklist.
echo "Stopping the Oracle components"
;;

'start')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$ORACLE_CONTROL_VARIABLE" != 1 ]; then
rval=2
else
su - oracle -c dbstart
set_return
if [ $rval -eq 1 ]; then
echo "Oracle startup failed"
exit $rval
fi
su - oracle -c "$ORA_HOME/bin/lsnrctl start listener_oemp"
set_return
if [ $rval -eq 1 ]; then
echo "Oracle startup failed"
exit $rval
fi
fi
;;

'stop')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$ORACLE_CONTROL_VARIABLE" != 1 ]; then
rval=2
else
su - oracle -c dbshut; #Only db, listener is protected with pwd
set_return
if [ $rval -eq 1 ]; then
echo "Oracle shutdown failed"
exit $rval
fi
fi
;;

*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac

exit $rval

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?