#! /bin/bash
# description : Oracle auto start / stop script
# 09/09/2010 auther : Aaron
echo "Please input follow's choose : (eg: 1 / start)"
echo " 1. start "
echo " 2. stop "
echo " 3. restart "
echo " 4. quit"
ORACLE_HOME=/u01/oracle
ORACLE_USER=oracle
read -p "the choose is : " choose
case "$choose" in
start | 1)
if [ ! -e $ORACLE_HOME/bin/dbstart ]; then
echo "Sorry ! dbstart doesn't exist , can't startup oracle "
exit 1
fi
echo "****************** Listener && Oracle Startup ******************"
sleep 3
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart"
echo "****************** Weblogic Startup ******************"
sleep 3
. /etc/profile
if [ ! -e /var/weblogic ]; then
mkdir /var/weblogic
fi
cd /app/bea/user_projects/mydomain/
nohup ./startWebLogic.sh | tee -a /var/weblogic/wl.log &
echo "Congratulations ! Application && Database have started successfully"
;;
stop | 2)
echo "****************** Weblogic Shutdown ******************"
pkill java
pkill startWebLogic
echo "****************** Oracle && Listener shutdown ******************"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
echo "Congratulations ! Application && Database have stoped successfully"
;;
restart | 3)
echo "****************** Listener && Oracle Shutdown *****************"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
echo "****************** Weblogic shutdown ******************"
pkill java
pkill startWeblogic
echo "Congratulations ! Application && Database have stoped successfully"
echo "****************** Listener && Oracle Startup ******************"
sleep 3
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart"
echo "****************** Weblogic Start ******************"
sleep 3
. /etc/profile
if [ ! -e /var/weblogic ]; then
mkdir /var/weblogic
fi
cd /app/bea/user_projects/mydomain/
nohup ./startWebLogic.sh | tee /var/weblogic/wl.log &
echo "Congratulations ! Application && Database have started successfully"
;;
* | quit | 4)
echo "Thank you for using this script. !"
exit 1
;;
esac
exit 1