在SuSE下,由于SuSE特有的脚本管理方法,Should-Stop和Default-Stop选项被忽略了。同时,在脚本开始处执行/etc/rc.status脚本,可以通过调用rc_status -v检查启动命令的执行结果并彩色显示出来。
#!/bin/bash
#
# /etc/init.d/oracle
#
### BEGIN INIT INFO
# Provides:
# Required-Start: $network $syslog
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Description: Startup/shutdown script for oracle listener and instance;
### END
. /etc/rc.status
rc_reset
start()
{
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
touch /var/lock/subsys/oracle
# start tsnlisnter
echo -n "Start tsnlisnter:"
su - oracle -c "lsnrctl start" >/dev/null 2>/dev/null
rc_status -v
# start database
echo -n "Start Oracle database instance:"
su - oracle -c "echo \"
CONN / AS SYSDBA
STARTUP
exit \"|sqlplus /NOLOG" >/dev/null 2>/dev/null
rc_status -v
# start enterprise manager
echo -n "Start Enterprise Manager:"
su - oracle -c "emctl start dbconsole" >/dev/null 2>/dev/null
rc_status -v
#start isqlplus
echo -n "Start isqlplus"
su - oracle -c "isqlplusctl start">/dev/null 2>/dev/null
rc_status -v
}
stop()
{
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
rm -rf /var/lock/subsys/oracle
# shutdown database
echo -n "Shutdown Oracle database instance:"
su - oracle -c "echo \"
CONN / AS SYSDBA
SHUTDOWN immediate
exit \"|sqlplus /NOLOG">/dev/null 2>/dev/null
rc_status -v
# stop tsnlisnter
echo -n "Stop tsnlisnter:"
su - oracle -c "lsnrctl stop">/dev/null 2>/dev/null
rc_status -v
# stop enterprise manager
echo -n "Stop Enterprise Manager:"
su - oracle -c "emctl stop dbconsole"
rc_status -v
# stop isqlplus
echo -n "Stop isqlplus:"
su - oracle -c "isqlplusctl stop"
rc_status -v
}
case "$1" in
start)
start
echo "Oracle Start at:" `date` >>/var/log/oracle.log
;;
stop)
stop
echo "Oracle Stop at:" `date` >>/var/log/oracle.log
;;
restart)
echo "Oracle Restart at:" `date` >>/var/log/oracle.log
stop
start
;;
*)
echo "Usage: $0 { start | stop| restart }"
exit 1
;;
esac
rc_exit
posted on 2007-06-05 09:50
思考 阅读(1491)
评论(0) 编辑 收藏 所属分类:
Linux