#!/bin/sh # # init.evmd - Control script for the Oracle EVM daemon. # # This should not be in an rcX.d directory; it should only # be invoked from init.crs. # # No manual invocation of init.evmd is supported. # ORA_CRS_HOME=%ORA_CRS_HOME% ORACLE_USER=%OwnerId% ORACLE_HOME=$ORA_CRS_HOME export ORACLE_HOME export ORA_CRS_HOME CAT=/bin/cat RMF="/bin/rm -f" LOGMSG="/bin/logger -puser.err" ECHO=/bin/echo KILL=/bin/kill SU=/bin/su GREP=/bin/grep SLEEP=/bin/sleep MVF="/bin/mv -f" UNAME=/bin/uname PLATFORM=`$UNAME` # 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 AWK=/bin/awk 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 #set ulimit to unlimited ULIMIT_CORE="ulimit -c unlimited" case $PLATFORM in Linux) ID=/etc/init.d LOGGER="/usr/bin/logger" if [ ! -f "$LOGGER" ];then LOGGER="/bin/logger" fi LOGMSG="$LOGGER -puser.err" SU="/bin/su -l" ;; HP-UX) ID=/sbin/init.d ;; SunOS) ID=/etc/init.d ;; AIX) ID=/etc ;; OSF1) ID=/sbin/init.d ;; *) /bin/echo "ERROR: Unknown Operating System" exit -1 ;; esac # This file contains the PID of the running EVMD PIDFILE=$ORA_CRS_HOME/evm/init/$HOST.pid # Flags for communicating with evmd FLAGFILE=$ORA_CRS_HOME/evm/init/$HOST.flags case $1 in 'home') $ECHO $ORA_CRS_HOME exit 0; ;; 'user') $ECHO $ORACLE_USER exit 0; ;; 'stop') $LOGMSG "Oracle EVMD set to stop" ;; '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 # Save the initial bootid. BOOTID=`$ID/init.cssd bootid` $RMF $FLAGFILE $PIDFILE cd $ORA_CRS_HOME/log/$HOST/evmd # 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 # NOTE: su will wipe your LD_LIBRARY_PATH, but keep most of the # remainder of the environment. It is necessary to run the evmd # wrapper script from here instead of the binary directly. shift $SU $ORACLE_USER -c "sh -c '$ULIMIT_CORE; cd $ORA_CRS_HOME/log/$HOST/evmd; exec $ORA_CRS_HOME/bin/evmd $*'" # Perform a quick system sanity check. NEWBOOTID=`$ID/init.cssd bootid` if [ "$NEWBOOTID" != "$BOOTID" ]; then $LOGMSG "Oracle EVMD respawn disabled due to change in bootid." fi # Ensure that the hostname has not changed. This could prevent respawn. 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 EVMD respawn disabled. Unsupported change in hostname." fi ;; *) $ECHO "Manual invocation of $0 is not supported." ;; esac