#!/bin/bash
# wang_xiaoyu@qq.com
# 2009-06-19 21:05:49
# 2009-06-19 22:54:24
LOG_PATH=$HOME/oracle_initing.log
log() {
if [ $# -lt 1 -a $# -gt 1 ];then
exit 5
fi
case "$@" in
success)
echo `date +%b" "%d" "%T`" "$PRO": Oracle instence \"$ORACLE_SID\" starting up succefully" >> $LOG_PATH;;
failed)
echo `date +%b" "%d" "%T`" "$PRO": Oracle instence \"$ORACLE_SID\" starting up FAILED" >> $LOG_PATH;;
*)
echo `date +%b" "%d" "%T`" "$PRO": "$@ >> $LOG_PATH;;
esac
}
lsstart() {
# stop stopping
# start starting
lsnrctl >> $LOG_PATH <
status
start
exit
EOF
}
init_oracle() {
#lsstart stop the listen
# lsstart
HOSTNAME=`hostname |awk -F. '{print $1}'`
PRO=$0
ORACLE_SIDS=`sed -rn '/^([^#].*):/!d;p' /etc/oratab |awk -F: '{printf $1" "}'`
if [ -z "$ORACLE_SIDS" ] ;then
exit 2
else
echo $ORACLE_SIDS
for ORACLE_SID in $ORACLE_SIDS
do
# echo $ORACLE_SID
#start or stop the oracle databases
# startup
# shutdown immediate
if sqlplus -S /nolog >> $LOG_PATH <
conn / as sysdba
startup
EOF
then
log success
continue
else
log failed
exit 3
fi
done
fi
}
if [ $"$UID" -eq 0 ] ;then
su - oracle
init_oracle
#lsstart start the listen
# lsstart
exit 0
elif [ "$USER" = "oracle" ] ;then
init_oracle
#lsstart start the listen
# lsstart
exit 0
else
exit 4
fi