#! /bin/sh # Copyright (c)1995 SuSE GmbH Nuernberg, Germany. # # Author: SuSE Oracle Team # ### BEGIN INIT INFO # Provides: oracle # Required-Start: $network $syslog $remote_fs $netdaemons # Required-Stop: # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Description: Start the Oracle database ### END INIT INFO # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status # rc_status -v ditto but be verbose in local rc status # rc_status -v -r ditto and clear the local rc status # rc_failed set local and overall rc status to failed # rc_reset clear local rc status (overall remains) # rc_exit exit appropriate to overall rc status . /etc/rc.status function print_begin () { echo echo "#########################################################################" echo "# Begin of O R A C L E startup/shutdown section #" echo "#########################################################################" echo return 0 } function print_end () { echo echo "#########################################################################" echo "# End of O R A C L E startup/shutdown section #" echo "#########################################################################" echo return 0 } # Get settings, if file(s) exist(s). If not, we simply use defaults. if test -f /etc/sysconfig/oracle; then # new location as of SL 8.0 is directory /etc/sysconfig/ . /etc/sysconfig/oracle else if test -f /etc/rc.config.d/oracle.rc.config; then # new location is directory /etc/rc.config.d/ . /etc/rc.config.d/oracle.rc.config else if test -f /etc/rc.config; then # old location was to have everything in one file . /etc/rc.config fi fi fi print_begin # Kernel parameters for Oracle. This comes before the tests for # START_ORACLE_DB so that this can be used # even when those values are "no". if [ "${SET_ORACLE_KERNEL_PARAMETERS:-no}" == "yes" -a "${1:-stop}" == "start" ]; then echo echo "Attempting to set kernel parameters for Oracle." if test -f /etc/sysconfig/oracle; then echo "See file /etc/sysconfig/oracle for explanations." else echo "See file /etc/rc.config.d/oracle.rc.config for explanations." fi if [ ! -d /proc/sys/kernel ]; then echo; echo "No sysctl kernel interface - cannot set kernel parameters."; echo rc_failed else # Set shared memory parameters echo "Shared memory" test -f /proc/sys/kernel/shmmax || (echo; echo "Detected a 2.2 kernel, can only set SHMMAX."; echo) test -f /proc/sys/kernel/shmmax && echo " SHMMAX: ${SHMMAX:-2147483647}" test -f /proc/sys/kernel/shmmax && echo ${SHMMAX:-2147483647} > /proc/sys/kernel/shmmax test -f /proc/sys/kernel/shmmni && echo " SHMMNI: ${SHMMNI:-4096}" test -f /proc/sys/kernel/shmmni && echo ${SHMMNI:-4096} > /proc/sys/kernel/shmmni test -f /proc/sys/kernel/shmall && echo " SHMALL: ${SHMALL:-2097152}" test -f /proc/sys/kernel/shmall && echo ${SHMALL:-2097152} > /proc/sys/kernel/shmall # Set the semaphore parameters: # see Oracle release notes for Linux for how to set these values # SEMMSL, SEMMNS, SEMOPM, SEMMNI echo "Semaphore values" test -f /proc/sys/kernel/sem && echo " SEMMSL: ${SEMMSL:-250}" test -f /proc/sys/kernel/sem && echo " SEMMNS: ${SEMMNS:-32000}" test -f /proc/sys/kernel/sem && echo " SEMOPM: ${SEMOPM:-100}" test -f /proc/sys/kernel/sem && echo " SEMMNI: ${SEMMNI:-256}" test -f /proc/sys/kernel/sem && echo ${SEMMSL:-250} ${SEMMNS:-32000} ${SEMOPM:-100} ${SEMMNI:-128} > /proc/sys/kernel/sem fi echo -n "Kernel parameters are set for Oracle: " rc_status -v echo echo " #################################################################" echo fi rc_reset # Set reasonable defaults if nothing has been set by now. if [ -z "$ORACLE_OWNER" ]; then ORACLE_OWNER=oracle START_ORACLE_DB="no" START_ORACLE_DB_LISTENER="yes" START_ORACLE_DB_AGENT="no" START_ORACLE_DB_APACHE="no" START_ORACLE_DB_CMANAGER="no" START_ORACLE_DB_IFS="no" START_ORACLE_DB_OID="no" fi # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START_ORACLE_DB="yes" test "${START_ORACLE_DB:-no}" = "yes" || exit 0 # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status # rc_status -v ditto but be verbose in local rc status # rc_status -v -r ditto and clear the local rc status # rc_failed set local and overall rc status to failed # rc_reset clear local rc status (overall remains) # rc_exit exit appropriate to overall rc status # First reset status of this service rc_reset # THIS IS A WORKAROUND (for JServ in 9i and iAS 9i) # In file $ORACLE_HOME/Apache/Jserv/etc/jserv.properties # Oracle insists on making available a DISPLAY variable. # Because of this starting/stopping of Apache fails # if DISPLAY is not set, so we set it to some dummy value. # It does not hurt anything else. test -z "$DISPLAY" && export DISPLAY=":42.0" # get and check environment (e.g. ORACLE_HOME) test -f /etc/profile.d/oracle.sh && . /etc/profile.d/oracle.sh if [ -z "$ORACLE_HOME" -o ! -d $ORACLE_HOME -o -z "$ORACLE_SID" ]; then echo "Cannot find ORACLE_HOME directory, or ORACLE_SID not set." echo -n "Environment settings are wrong? Check /etc/profile.d/oracle.sh" rc_failed rc_status -v print_end rc_exit exit 1 fi # the database will not start if the entry in /etc/oratab is "N" grep -s -q "$ORACLE_SID:$ORACLE_HOME:Y" /etc/oratab >&/dev/null || { echo -n "No start entry for this ORACLE_SID/ORACLE_HOME in /etc/oratab" rc_failed rc_status -v print_end rc_exit exit 1 } # we use the Oracle provided scripts dbstart/dbshut for startup/shutdown # of the database itself if [ ! -f $ORACLE_HOME/bin/dbstart -o -z "$ORACLE_OWNER" ]; then echo "No such file: \$ORACLE_HOME/bin/dbstart" echo -n "Oracle could not be found (ORACLE_HOME wrong?)" rc_failed rc_status -v print_end rc_exit exit 1 fi # Oracle 8i uses a different command than 9i to start/stop the # Intelligent Agent if test -x $ORACLE_HOME/bin/agentctl; then # Oracle 9i AGENT_PROG="$ORACLE_HOME/bin/agentctl" AGENT_START="$ORACLE_HOME/bin/agentctl start" AGENT_STOP="$ORACLE_HOME/bin/agentctl stop" else # Oracle 8i AGENT_PROG="$ORACLE_HOME/bin/lsnrctl" AGENT_START="$ORACLE_HOME/bin/lsnrctl dbsnmp_start" AGENT_STOP="$ORACLE_HOME/bin/lsnrctl dbsnmp_stop" fi # Here we finally get to do the real work. case "$1" in start) echo "Starting up Oracle:" su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart"; rc_status; echo -n "Startup of Oracle Database(s): "; rc_status -v -r; echo; echo test "${START_ORACLE_DB_LISTENER:-no}" = "yes" && test -x $ORACLE_HOME/bin/lsnrctl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"; rc_status; echo -n "Startup of Oracle Listener: "; rc_status -v -r; echo; echo) test "${START_ORACLE_DB_APACHE:-no}" = "yes" && test -x $ORACLE_HOME/Apache/Apache/bin/apachectl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/Apache/Apache/bin/apachectl start"; rc_status; echo -n "Startup of Oracle Apache: "; rc_status -v -r; echo; echo) test "${START_ORACLE_DB_CMANAGER:-no}" = "yes" && test -x $ORACLE_HOME/bin/cmctl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/cmctl start"; rc_status; echo -n "Startup of Oracle Connection Manager: "; rc_status -v -r; echo; echo) test "${START_ORACLE_DB_AGENT:-no}" = "yes" && test -x $AGENT_PROG && (su - $ORACLE_OWNER -c "$AGENT_START"; rc_status; echo -n "Startup of Oracle Intelligent Agent: "; rc_status -v -r; echo; echo) test "${START_ORACLE_DB_IFS:-no}" = "yes" && (echo; echo "Starting Oracle IFS: Not yet implemented."; echo) test "${START_ORACLE_DB_OID:-no}" = "yes" && (echo; echo "Starting Oracle OID: Not yet implemented."; echo) ;; stop) echo "Shutting down Oracle:" test -x $AGENT_PROG && (su - $ORACLE_OWNER -c "$AGENT_STOP"; rc_status; echo -n "Shutdown of Oracle Intelligent Agent: "; rc_status -v -r; echo; echo) test -x $ORACLE_HOME/bin/cmctl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/cmctl stop"; rc_status; echo -n "Shutdown of Oracle Connection Manager: "; rc_status -v -r; echo; echo) test -x $ORACLE_HOME/Apache/Apache/bin/apachectl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/Apache/Apache/bin/apachectl stop"; rc_status; echo -n "Shutdown of Oracle Apache: "; rc_status -v -r; echo; echo) test -x $ORACLE_HOME/bin/lsnrctl && (su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"; rc_status; echo -n "Shutdown of Oracle Listener: "; rc_status -v -r; echo; echo) su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut"; rc_status; echo -n "Shutdown of Oracle Database(s): "; rc_status -v -r; echo; echo ;; *) echo "Usage: $0 {start|stop}" print_end exit 1 esac print_end rc_exit