CREATE OR REPLACE #!/bin/sh # # lin-srvctl # # chkconfig: 35 80 20 # description: Oracle Instance (no Clusterware) startup script. \ # It has been written for an instance named ORCL. \ # It is intended to be placed in the /etc/init.d \ # directory as root and used by a linux service \ # processname: ora_smon_XXXX # # Copyright (C) 2007 ArKZoYd - arkzoyd@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # To contact us, send an email to arkzoyd@gmail.com # # lin-srvtl version beta-1, Copyright (C) 2007 ArkZoYd # lin-srvtl comes with ABSOLUTELY NO WARRANTY; # # history # 6/29/2007 - gguillou - creation # # # Instructions # ------------ # To adapt this script to your needs : # 1- Make sure you have put the lin-srvctl in the $ORACLE_HOME/bin of the # database software # 2- Change the rights so that you can execute lin-srvctl as an Oracle DBA # (e.g. as the oracle user) # 3- Name the file so that it is unique and self explicit. Use a name like # oradb- # 4- Put this file in the /etc/init.d directory # 5- Change the right so that you can read, write and execute the script # as the root user # 6- Modify the ORACLE_HOME, LISTENER and USER value so that it fit your # Configuration # 7- Register the script with chkconfig as root with the command below # chkconfig --add oradb- # 8- Test the script with the commands below # chkconfig --list oradb- # /sbin/service oradb- status # /sbin/service oradb- start # /sbin/service oradb- status # /sbin/service oradb- stop # /sbin/service oradb- status # 9- Set the service to be started we needed # 10- Give me your feedback by email : arkzoyd@gmail.com # or on my blog http://arkzoyd.blogspot.com # # Known issues # ------------ # * It is suppose only to work with 10g and 11g # export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 export ORACLE_SID=ORCL export USER=oracle # Source function library. . /etc/rc.d/init.d/functions # start() { echo -n "Starting $ORACLE_SID: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 initlog $INITLOG_ARGS -c \ "runuser ${USER} -c \"$ORACLE_HOME/bin/lin-srvctl start instance $ORACLE_SID\" >/dev/null 2>&1" RETVAL=$? [ "$RETVAL" -eq 0 ] && success $"oracle $ORACLE_SID startup" || \ failure $"oracle $ORACLE_SID startup" echo } stop() { echo -n "Stopping $ORACLE_SID: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 initlog $INITLOG_ARGS -c \ "runuser ${USER} -c \"$ORACLE_HOME/bin/lin-srvctl stop instance $ORACLE_SID\" >/dev/null 2>&1" RETVAL=$? [ "$RETVAL" -eq 0 ] && success $"oracle $ORACLE_SID shutdown" || \ failure $"oracle $ORACLE_SID shutdown" echo } stat() { initlog $INITLOG_ARGS -c \ "runuser ${USER} -c \"$ORACLE_HOME/bin/lin-srvctl status instance $ORACLE_SID\" >stdout 2>&1" } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop sleep 3 start ;; condrestart) stat RETVAL=$? if [ $"RETVAL" -eq 0 ]; then stop sleep 3 start fi ;; status) stat ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac /