#!/bin/bash #Path for the script is /etc/init.d/script_db.sh . /etc/rc.d/init.d/functions start(){ echo "Starting Database" su -l orainfra -c "sh /etc/init.d/startdb.sh" RETVAL=$? return $RETVAL } stop(){ echo "Stopping Database" su -l orainfra -c "sh /etc/init.d/stopdb.sh" RETVAL=$? return $RETVAL } status() { DBUP=`ps -ef | grep orainfra | grep -v grep | grep -c ora_pmon ` LSNRUP=` ps -ef | grep orainfra | grep oradb| grep -v grep | grep -c LISTENER* ` if [ ${DBUP} -ge 1 ] then if [ ${LSNRUP} -ge 1 ] then echo "Database Running" return 0 fi fi echo "Database Not Running" return 1 } case "$1" in start) start echo "Start Database complete" ;; stop) stop echo "Database Stopped" ;; restart) stop start ;; status) status ;; *) echo $" Not Applicable" exit 1 esac echo "exiting script" exit $RETVAL