#!/bin/bash
# chkconfig:2345 99 10
# description: Startup Script for oracle Database
# /etc/init.d/oracle
# time 2017-08-11 by justzhi
export ORACLE_BASE="/oracle/ora11g"
export ORACLE_HOME="$ORACLE_BASE/app"
export ORACLE_OWNER=oracle
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup:cannot start "
exit 1
fi
#depending on parameter -- start,stop,restart,
#of the instance and listener or usage display
case "$1" in
start)
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
echo "Starting Oracle:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch /var/lock/subsys/oracle11g
echo "OK"
;;
stop)
#oracle listener and instance shutdown
echo -n "Shutdown Oracle"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut "
rm -f /var/lock/subsys/oracle11g
echo "ok"
;;
status)
if ( pgrep "tnslsnr" && netstat -anpt | grep ":1521") &> /dev/null
then
echo " Oracle 11g Net Listener is running."
else
echo "Oracle 11g Net listener is not running"
fi
if (netstat -anpt|grep ":1158" && netstat -anpt |grep ":5520") &> /dev/null
then
echo "Oralce 11g Enterprise Mannager is running"
else
echo "Oracle 11g Enerprise Mannager is not running"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0