#!/bin/sh # # init.crsd - Control script for the CRS daemon. # # This should not be linked into an rcX.d directory. It should # only be invoked from init.crs or from inittab. # # No manual invocation of init.crsd is supported. # ORA_CRS_HOME=%ORA_CRS_HOME% ORACLE_USER=%OwnerId% ORACLE_HOME=$ORA_CRS_HOME export ORA_CRS_HOME export ORACLE_HOME UMASK=/bin/umask SED=/bin/sed CAT=/bin/cat LOGMSG="/bin/logger -puser.err" ECHO=/bin/echo KILL=/bin/kill RMF="/bin/rm -f" SLEEP=/bin/sleep TOUCH=/bin/touch GREP=/bin/grep PSE="/bin/ps -e" LS=/bin/ls AWK=/bin/awk MVF="/bin/mv -f" HEAD=/usr/bin/head SU=/bin/su # Incase /bin/hostname is not present in a particular platform, we # may have to do something different. HOSTN=/bin/hostname EXPRN=/usr/bin/expr CUT=/usr/bin/cut TR=/bin/tr #solaris on amd and SPARC has issue with /bin/tr [ 'SunOS' = `/bin/uname` ] && TR=/usr/xpg4/bin/tr #on linux tr is at /usr/bin/tr [ 'Linux' = `/bin/uname` ] && TR=/usr/bin/tr #If the hostname is an IP address, let hostname #remain as IP address HOST=`$HOSTN` len1=`$EXPRN "$HOST" : '.*'` len2=`$EXPRN match $HOST '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'` # Strip off domain name in case /bin/hostname returns # FQDN hostname if [ $len1 != $len2 ]; then HOST=`$ECHO $HOST | $CUT -d'.' -f1 ` fi HOST=`$ECHO $HOST | $TR '[:upper:]' '[:lower:]'` UNIQUEDATE=`/bin/date '+%Y-%m-%d-%H:%M:%S'` UNIQUECORE=core.$UNIQUEDATE # Default path for SCR control files. SCRDIR=/var/opt/oracle/scls_scr/$HOST UNAME=/bin/uname PLATFORM=`$UNAME` MAXFILE=65536 case $PLATFORM in Linux) SCRDIR=/etc/oracle/scls_scr/$HOST ID=/etc/init.d LOGGER="/usr/bin/logger" if [ ! -f "$LOGGER" ]; then LOGGER="/bin/logger" fi LOGMSG="$LOGGER -puser.err" if [ ! -f "$UMASK" ]; then UMASK=umask fi SETULIMITFORLOCKEDMEMORY="ulimit -l unlimited" $SU -l $ORACLE_USER -c "$ECHO \$TZ > /tmp/oratz.$$ " > /dev/null 2>&1 NEWTZ=`$SED 's/^[ \t]*//;s/[ \t]*$//' < /tmp/oratz.$$` $RMF /tmp/oratz.$$ if [ ! -z "$NEWTZ" ]; then TZ=$NEWTZ; export TZ; fi ;; HP-UX) ID=/sbin/init.d ;; SunOS) ID=/etc/init.d VER=`$UNAME -r | $SED -e 's/\.//g'` ;; AIX) SCRDIR=/etc/oracle/scls_scr/$HOST ID=/etc ;; OSF1) ID=/sbin/init.d ;; *) /bin/echo "ERROR: Unknown Operating System" exit -1 ;; esac # This file controls how the CRS flags are set. On a manual startup # or on an automatic startup, this file will exist. init.crsd run will # remove the file and invoke one-time-only actions. CRSDBOOT=$SCRDIR/root/crsdboot # This file contains the PID of the running CRSD PIDFILE=$ORA_CRS_HOME/crs/init/$HOST.pid # Flags file for CRSD FLAGFILE=$ORA_CRS_HOME/crs/init/$HOST.flags case $1 in 'home') $ECHO $ORA_CRS_HOME exit 0; ;; 'stop') [ -r $PIDFILE ] && crspid=`$CAT $PIDFILE` $LOGMSG "Oracle CRSD $crspid set to stop" # Indicate that the next time we start up, it may be an initial startup. $ECHO "stopped" > $CRSDBOOT $LOGMSG "Oracle CRSD $crspid shutdown completed" ;; 'run') # foreground run out of init # Check to see if we are supposed to run this boot. $ID/init.cssd startcheck while [ "$?" != "0" ]; do # recheck every once in a while, in case manual startup is invoked $SLEEP 30 $ID/init.cssd startcheck done # Check to see if this is the first time CRSD has started this boot. FIRST=false CRSDID=`$CAT $CRSDBOOT` BOOTID=`$ID/init.cssd bootid` BOOTFLAG=restart if [ "$CRSDID" != "$BOOTID" ]; then $RMF $PIDFILE # Do not execute these one-time actions again. $ECHO "$BOOTID" > $CRSDBOOT BOOTFLAG=reboot fi # Allow the daemon to drop a diagnostic core file ulimit -c unlimited # Fix for bug 7483048; warning in alert.log for low open file descriptors ulimit -n $MAXFILE cd $ORA_CRS_HOME/log/$HOST/crsd # Fix for bug 3784537; instance crashes with VLM enabled and # a low locked memory limit (ulimit -l). For eg. the # OS default value of 4KB isn't sufficient. if [ "$SETULIMITFORLOCKEDMEMORY" ]; then $SETULIMITFORLOCKEDMEMORY fi # If there is an old corefile by such a collision prone name, then # rename it to something safe. if [ -f ./core ]; then $MVF ./core "$UNIQUECORE" fi # keep crsd log/trace from being world readable. $UMASK `$UMASK | $SED 's/.$/6/'` $LOGMSG "Running CRSD with TZ = $TZ" # foreground run out of init shift if [ "$PLATFORM" -eq "SunOS" -a "$VER" -ge "510" ]; then # For Solaris 10 crsd must be started in the correct oracle project PROJECT=`projects -d $ORACLE_USER` newtask -p $PROJECT $ORA_CRS_HOME/bin/crsd $BOOTFLAG $* else $ORA_CRS_HOME/bin/crsd $BOOTFLAG $* fi # Perform some quick system sanity checks. NEWBOOTID=`$ID/init.cssd bootid` if [ "$NEWBOOTID" != "$BOOTID" ]; then $LOGMSG "Oracle CRSD respawn disabled due to change in bootid." $ECHO "stopped" > $CRSDBOOT fi NEWHOST=`$HOSTN` len1=`$EXPRN "$NEWHOST" : '.*'` len2=`$EXPRN match $NEWHOST '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'` # Strip off domain name in case /bin/hostname returns # FQDN hostname if [ $len1 != $len2 ]; then NEWHOST=`$ECHO $NEWHOST | $CUT -d'.' -f1 ` fi NEWHOST=`$ECHO $NEWHOST | $TR '[:upper:]' '[:lower:]'` if [ "$NEWHOST" != "$HOST" ]; then $LOGMSG "Oracle CRSD respawn disabled. Unsupported change in hostname." $ECHO "stopped" > $CRSDBOOT fi $ID/init.cssd runcheck if [ "$?" != "0" ]; then # here we attempted to start up, but failed. If we are # supposed to be shutdown, then mark the shutdown state. $ECHO "stopped" > $CRSDBOOT fi ;; 'tz') #Print TZ value $ECHO $TZ ;; *) $ECHO "Manual invocation of $0 is not supported." ;; esac