#!/bin/ksh # # Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved. # # # Register this instance of Solaris with # Oracle Configuration Manager (OCM) and # start the data collector # # or start the data collector # # or stop the data collector # # # start: # if this system is not registered with OCM # if the opt_out property exists # disable this service and exit # else # if there is a property for a custom response file package # expect a response file as $CUSTOM_RESPONSE_FILE # else # if there are user and ciphertext SMF properties in the reg group # create response file using ciphertext # else if there are user and password SMF properties # create response file using user and password # else if there is user without password SMF property # create and use the "anonymous" response file # else # use the "disconnected" mode # # use whichever response file is appropriate to register # (scheduler is started as side-effect) # # if there was a custom file package # remove the package # # if this system is registered with OCM # start it # # stop: # stop the OCM scheduler # # # ############################################################ . /lib/svc/share/smf_include.sh typeset TRUE=0 typeset FALSE=1 typeset SERVICE=system/ocm:default typeset DISABLE_SVC="/usr/sbin/svcadm disable ${SERVICE}" typeset -x JAVA_HOME=${JAVA_HOME:-/usr/java/jre} # needed for configCCR # product constants export ORACLE_HOME=/usr/lib/ocm typeset ORACLE_HOME_BIN=${ORACLE_HOME}/ccr/bin typeset ORACLE_HOME_LIB=${ORACLE_HOME}/ccr/lib export ORACLE_CONFIG_HOME=/var/ocm # If the configCCR reports this error, we do ignore it, because it will be # recreated once configCCR -a option is invoked. typeset OUT_IGNORE_ERR="OCM is not configured for this host or ORACLE_CONFIG_HOME. Please configure OCM first." # Ignore the "OCM is not configured" error on stop. typeset OUT_STOP_IGNORE_ERR1="OCM is not configured for this host or ORACLE_CONFIG_HOME. Please configure OCM first." # Ignore the "OCM is not running" error on stop. typeset OUT_STOP_IGNORE_ERR2="Oracle Configuration Manager is not running." # Retry stop if failed. typeset OUT_STOP_RETRY="Oracle Configuration Manager could not be stopped." typeset OUT_STOP_RETRY_COUNT=5 typeset OUT_STOP_RETRY_SLEEP_TIME=2 typeset REG_CMD=/usr/sbin/configCCR typeset OCM_RF_CREATOR_CMD=${ORACLE_HOME_BIN}/OCMRFCreator typeset OCM_SCHEDULER_PS=${ORACLE_HOME_BIN}/nmz typeset OCM_COLLECTOR_LOCKFILE=${ORACLE_CONFIG_HOME}/ccr/state/collector.lock typeset OCM_SCHED_TEMPLATE=${ORACLE_HOME}/ccr/config/default/sched.properties.template typeset OCM_SCHED_CONFIG=${ORACLE_CONFIG_HOME}/ccr/config/default/sched.properties typeset OCM_SCHEDULER_RESTART="/usr/sbin/emCCR start" typeset OCM_SCHEDULER_STOP="/usr/sbin/emCCR stop_abort" # su to user "ocm" to execute emCCR so that the nmz can be run as ocm. typeset SU_OCM="/usr/bin/su - ocm -c" # Export env variable again after su since it will start a new shell. typeset SU_ENV="JAVA_HOME=/usr/java/jre ORACLE_CONFIG_HOME=/var/ocm ORACLE_HOME=/usr/lib/ocm" # # registration constants # typeset CUSTOM_RESPONSE_FILE=${ORACLE_CONFIG_HOME}/.rsp/ocm.rsp # may be a custom file delivered via AI install or typeset OCMCREATOR_RESPONSE_FILE=${ORACLE_CONFIG_HOME}/.rsp/ocmcreator.rsp # dynamically created typeset REGISTERED_FILE=${ORACLE_CONFIG_HOME}/ccr/config/default/uplinkreg.bin typeset REGISTERED_KEY="key.registered" # Disconnected mode typeset DISCONNECTED_FILE=${ORACLE_CONFIG_HOME}/ccr/config/collector.properties typeset DISCONNECTED_KEY="ccr.disconnected=true" # # SMF properties that may be set in AI client profile # typeset RESPONSE_FILE_PKG_NAME_PROP=reg/response_file_pkg_name # if present, gives IPS package name delivering custom response file typeset OPT_OUT_PROP=reg/opt_out # if present indicates opt-out of OCM registration and collection # # SMF properties populated by the installers # typeset REG_USER_PROP="reg/user" # MOS user ID typeset REG_PASSWORD_PROP="reg/password" # MOS password, sensitive encrypted typeset REG_PROXY_HOST_PROP="reg/proxy_host" # Proxy host host:port typeset REG_PROXY_USER_PROP="reg/proxy_user" typeset REG_PROXY_PASSWORD_PROP="reg/proxy_password" # Proxy password, sensitive encrypted typeset REG_CONFIG_HUB_PROP="reg/config_hub" # OCM hub info. host:port typeset REG_CIPHERTEXT_PROP="reg/cipher" # OCM Ciphertext returned from Oracle authentication typeset REG_INDEX_PROP="reg/key" # Key used to encrypt sensitive fields via base64 algorithm. # # flags to modify registration behavior # export CCR_NOUPDATE=1 # turn off auto_update # not actually honored by OCM scripts but included here # to show it's been investigated # no update is set into the OCM distribution by the S11 build export CCR_DISABLE_CRON_ENTRY=1 # don't write entry to cron # registration dynamic globals typeset RESPONSE_FILE_PKG= # # Owner information using for switching users # export OCM_OWNER=62 export OCM_GROUP=12 export ROOT_OWNER=0 export BIN_GROUP=2 ############################################################## # # # Utility functions ############################################################## # # Change the owner of configuration files to the new user "ocm", # then stop the emCCR as new user "ocm". This routine will be called # in every method to ensure the owner of the service is consistent # with the owner of configuration files. # SwitchConfigFileOwner() { stop_need=0 # Configure file list set -A configFiles /var/ocm/ccr/state/semaphore.op \ /var/ocm/ccr/state/sched.state \ /var/ocm/ccr/state/semaphore.update \ /var/ocm/ccr/config/collector.properties \ /var/ocm/ccr/config/emCCRenv \ /var/ocm/ccr/config/sched.properties \ /var/ocm/ccr/config/ccr.properties \ /var/ocm/ccr/config/default/uplinkreg.bin \ /var/ocm/ccr/config/default/sched.properties \ /var/ocm/ccr/config/default/collector_config.inventory \ /var/ocm/ccr/config/default/targets.xml \ /var/ocm/ccr/log/collector.log \ /var/ocm/ccr/log/upgrade.log \ /var/ocm/ccr/log/sched.log \ /usr/lib/ocm/ccr/config/default/sched.properties \ /usr/lib/ocm/ccr/config/sched.properties \ for file in ${configFiles[@]} do if [[ -e $file ]]; then fileOwner=`/usr/bin/ls -Llnd $file | /usr/bin/nawk '{print $3}'` if [[ $OCM_OWNER -ne $fileOwner ]]; then stop_need=1 break fi fi done if [[ stop_need -eq 1 ]]; then echo "Switching owner of configuration files..." /usr/bin/chown -R $OCM_OWNER:$OCM_GROUP /var/ocm/ccr /usr/bin/chown -R $OCM_OWNER:$OCM_GROUP /usr/lib/ocm/ccr /usr/bin/chown $ROOT_OWNER:$BIN_GROUP /usr/lib/ocm/ccr/engines/SunOS/perl fi if [[ -d /var/ocm/.ocm ]]; then dirOwner=`/usr/bin/ls -Llnd /var/ocm/.ocm | /usr/bin/nawk '{print $3}'` if [[ $OCM_OWNER -ne $dirOwner ]]; then echo "Switching owner of configuration files..." /usr/bin/chown -R $OCM_OWNER:$OCM_GROUP /var/ocm/.ocm fi fi if [[ -d /var/ocm/ccr/state/review ]]; then dirOwner=`/usr/bin/ls -Llnd /var/ocm/ccr/state/review | /usr/bin/nawk '{print $3}'` if [[ $OCM_OWNER -ne $dirOwner ]]; then echo "Switching owner of configuration files..." /usr/bin/chown -R $OCM_OWNER:$OCM_GROUP /var/ocm/ccr/state/review fi fi if [[ stop_need -eq 1 ]]; then ${SU_OCM} "$SU_ENV ${OCM_SCHEDULER_STOP}" fi } # # Get the value of a property defined on the service. # getproparg() { val=$(svcprop -p $1 $SERVICE) [[ -n "$val" ]] && echo $val } # # remove_custom_response_file_package # # The contents of this package should not remain on the # system after registration, even if registration fails. # # Implicitly returns the exit code of IPS package removal. # remove_custom_response_file_package() { /usr/bin/pkg uninstall $1 } # # disable_ocm # # disable this service; do not register # disable_ocm() { ${DISABLE_SVC} } # # restore_place_holder_files # # restore place holder files to make pkg verify happy # restore_place_holder_files() { # directories mkdir -p ${ORACLE_CONFIG_HOME}/ccr/state/temp mkdir -p ${ORACLE_CONFIG_HOME}/ccr/state/review mkdir -p ${ORACLE_CONFIG_HOME}/ccr/state/upload/external mkdir -p ${ORACLE_CONFIG_HOME}/ccr/state/previous mkdir -p ${ORACLE_CONFIG_HOME}/ccr/state/diagnostic mkdir -p ${ORACLE_CONFIG_HOME}/ccr/config/default mkdir -p ${ORACLE_CONFIG_HOME}/ccr/log /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/temp /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/review /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/upload /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/upload/external /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/previous /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/state/diagnostic /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/config /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/config/default /usr/bin/chmod 0700 ${ORACLE_CONFIG_HOME}/ccr/log # placeholder registration FILES="${ORACLE_CONFIG_HOME}/ccr/config/ccr.properties ${ORACLE_CONFIG_HOME}/ccr/config/collector.properties ${ORACLE_CONFIG_HOME}/ccr/config/default/targets.xml ${ORACLE_CONFIG_HOME}/ccr/config/default/uplinkreg.bin ${ORACLE_CONFIG_HOME}/ccr/config/sched.properties ${ORACLE_CONFIG_HOME}/ccr/log/collector.log ${ORACLE_CONFIG_HOME}/ccr/log/sched.log ${ORACLE_CONFIG_HOME}/ccr/log/upgrade.log ${ORACLE_CONFIG_HOME}/ccr/state/sched.state ${ORACLE_CONFIG_HOME}/ccr/config/emCCRenv ${ORACLE_CONFIG_HOME}/ccr/config/default/sched.properties" for file in $FILES do [[ -f "$file" ]] || echo "\c" > $file /usr/bin/chmod 0600 $file done cp ${ORACLE_HOME}/ccr/config/default/collector_config.inventory ${ORACLE_CONFIG_HOME}/ccr/config/default/collector_config.inventory /usr/bin/chmod 0600 ${ORACLE_CONFIG_HOME}/ccr/config/default/collector_config.inventory # initial values FILES="${ORACLE_CONFIG_HOME}/ccr/state/semaphore.op ${ORACLE_CONFIG_HOME}/ccr/state/semaphore.update" for file in $FILES do [[ -f "$file" ]] || echo "0" > $file /usr/bin/chmod 0600 $file done } # # remove_oracle_config_home # # removes the ORACLE_CONFIG_HOME by invoking # configCCR -r command. This as well stops the OCM. # # return configCCR return code or if the ORACLE_CONFIG_HOME # was previously removed, returns 0. # remove_oracle_config_home() { if [[ -f ${REGISTERED_FILE} && ! -s ${REGISTERED_FILE} ]]; then echo "Removing empty registration file" rm ${REGISTERED_FILE} fi OUT_CONFCCR=$($SU_OCM "$SU_ENV $REG_CMD -r") OUT_NO=$? if [[ $OUT_NO != 0 ]]; then case "$OUT_CONFCCR" in *$OUT_IGNORE_ERR*) return 0 ;; *) echo $OUT_CONFCCR return $OUT_NO ;; esac fi return 0 } # # is_prop_set # # return true if the property is set # return false if property is empty or not set # is_prop_set() { prop_value=$(getproparg ${1} 2> /dev/null) if [[ -n "$prop_value" && "$prop_value" != \"\" ]]; then return $TRUE else return $FALSE fi } # # is_disconnected_collector_mode # # return true if Collector is in disconnected mode else return false # is_disconnected_collector_mode() { /usr/bin/grep -w ${DISCONNECTED_KEY} ${DISCONNECTED_FILE} > /dev/null 2>&1 disconnected=$? if [[ $disconnected -eq $TRUE ]]; then echo "Collector running in disconnected mode" elif [[ $disconnected -eq $FALSE ]]; then echo "Collector running in connected mode" else echo "Could not check collector running mode" fi return $disconnected } # is_disconnected_collector_mode # # is_ocm_registered # # return true if OCM is registered else return false # # implementation: look for particular key in # particular file that comes into existence only # upon successful registration. # is_ocm_registered() { /usr/bin/grep -w ${REGISTERED_KEY} ${REGISTERED_FILE} > /dev/null 2>&1 registered=$? if [[ $registered -eq $TRUE ]]; then echo "OCM already registered" elif [[ $registered -eq $FALSE ]]; then echo "OCM not registered" else echo "Could not check if OCM was registered" fi return $registered } # is_ocm_registered # # is_process_running # # return true if process specified as argument is running # else return false # is_process_running() { /usr/bin/ps -ef | /usr/bin/grep "$1" | /usr/bin/grep -v grep > /dev/null 2>&1 running=$? if [[ $running -eq $TRUE ]]; then echo "Process $1 running" elif [[ $running -eq $FALSE ]]; then echo "Process $1 not running" else echo "Could not check if process $1 is running" fi return $running } # is_process_running # # register # # Given a response file, attempt to register with OCM # Returns non-0 on error # register() { response_file=$1 # Test for existence and readability of response file. # If file can't be read don't bother trying to register. if [[ -r ${response_file} ]]; then # First we try to unconfigure previous configuration, we do not # check if it was needed as the below command will fail # if it wasn't and we will proceed with registration. remove_oracle_config_home # remove ccr/config/default/sched.properties # it will be generated from usr/lib/ocm/ccr/config/default/sched.properties.template /usr/bin/rm -f ${OCM_SCHED_CONFIG} # perform the OCM registration $SU_OCM "$SU_ENV ${REG_CMD} -a -R ${response_file}" reg_status=$? if [[ $reg_status -ne 0 ]]; then echo "Registration failed with exit code $reg_status" else echo "Registration completed." /usr/sbin/svccfg -s $SERVICE delcust reg delcust_status=$? if [[ $delcust_status -ne 0 ]]; then echo "Could not remove registration SMF properties." reg_status=1 else # Refresh the smf service /usr/sbin/svcadm refresh $SERVICE fi fi else echo "Response file ${response_file} not found or not readable." reg_status=1 fi return $reg_status } # register # # do_anonymous_registration # # create and use an anonymous registration response file # # creation of response file will fail if the system requires # a proxy and/or Oracle Support Hub in order to # communicate with the OCM server and were not # specified in the SVC properties. # # if creation succeeds go ahead and try to register # # if creation or registration fails user will # need to run # /usr/lib/ocm/ccr/bin/configCCR to register # interactively # do_anonymous_registration() { echo "Begin anonymous registration..." ${OCM_RF_CREATOR_CMD} --anonymous "$OCMCREATOR_RESPONSE_FILE" ocm_rf_status=$? if [[ $ocm_rf_status -eq 0 ]]; then register "$OCMCREATOR_RESPONSE_FILE" reg_status=$? else echo "Failed to generate anonymous response file..." reg_status=1 fi /usr/bin/rm -f "$OCMCREATOR_RESPONSE_FILE" return $reg_status } # do_anonymous_registration # # do_custom_response_file_registration # # The AI profile has specified a package name that # delivers a custom response file. # Attempt registration using this file # then remove the package itself. # do_custom_response_file_registration() { # We already know the name of the file, but not the # name of the package itself. We need that in order to # remove the package after this registration attempt. response_file_pkg=$1 echo "Custom response file package: $response_file_pkg" # use the file for registration register $CUSTOM_RESPONSE_FILE reg_status=$? if [[ $reg_status -eq 0 ]]; then # If the registration succeed remove the custom reg file by # removing its package. # removal is a best-effort, so if for some obscure reason # the remove should fail we will just log the fact # and return the status of registration, not of package removal remove_custom_response_file_package ${response_file_pkg} remove_status=$? if [[ $remove_status -ne 0 ]]; then echo "Unable to remove package ${RESPONSE_FILE_PKG}" # log entry only fi fi return $reg_status } # do_custom_response_file_registration # # do_ciphertext_registration # # create and use an registration response file based on the # username and ciphertext provided in the SVC property. # # creation of response file will fail if the system requires # a proxy and/or Oracle Support Hub in order to # communicate with the OCM server and were not # specified in the SVC properties. # # if creation succeeds go ahead and try to register # # if creation or registration fails user will # need to run # /usr/lib/ocm/ccr/bin/configCCR to register # interactively # do_ciphertext_registration() { echo "Begin ciphertext based registration..." ${OCM_RF_CREATOR_CMD} --ciphertext "$OCMCREATOR_RESPONSE_FILE" ocm_rf_status=$? if [[ $ocm_rf_status -eq 0 ]]; then register "$OCMCREATOR_RESPONSE_FILE" reg_status=$? else echo "Failed to generate ciphertext based response file..." reg_status=1 fi /usr/bin/rm -f "$OCMCREATOR_RESPONSE_FILE" return $reg_status } # do_ciphertext_registration # # do_username_pass_registration # # create and use an registration response file based on the # username and password provided in the SVC property. # # creation of response file will fail if the system requires # a proxy and/or Oracle Support Hub in order to # communicate with the OCM server and were not # specified in the SVC properties. # # if creation succeeds go ahead and try to register # # if creation or registration fails user will # need to run # /usr/lib/ocm/ccr/bin/configCCR to register # interactively # do_username_pass_registration() { echo "Begin password based registration..." ${OCM_RF_CREATOR_CMD} --password "$OCMCREATOR_RESPONSE_FILE" ocm_rf_status=$? if [[ $ocm_rf_status -eq 0 ]]; then register "$OCMCREATOR_RESPONSE_FILE" reg_status=$? else echo "Failed to generate password based response file..." reg_status=1 fi /usr/bin/rm -f "$OCMCREATOR_RESPONSE_FILE" return $reg_status } # do_username_pass_registration # # do_registration # If a custom response file exists (meaning an AI install,) # fetch it and feed it to configCCR then remove the package # that delivered it. # Return non-0 on error. # # If no custom response file then attempt to: # if there are user and ciphertext SMF properties in the reg group # create response file using ciphertext and use it # else if there are user and password SMF properties # create response file using user and password and use it # else if there is user without password SMF property # create the "anonymous" response file and use it # else # use the "disconnected" mode # # Return non-0 on error. # # At any later time the user is able to run # /usr/lib/ocm/ccr/bin/configCCR # manually (interactively) to accomplish registration # override of the created registration response file, or to accomplish # registration if network parameters are needed (anonymous, ciphertext # or password based registration would have failed.) # do_registration() { # Test for name of package containing custom response file. response_file_pkg=$(getproparg ${RESPONSE_FILE_PKG_NAME_PROP} 2> /dev/null) if [[ -n ${response_file_pkg} ]]; then # if there is a response file package named then # attempt registration via AI-delivered custom response file do_custom_response_file_registration ${response_file_pkg} || return 1 else if ( $(is_prop_set ${REG_USER_PROP}) ); then # $REG_USER_PROP is not empty, continue with registration if ( $(is_prop_set ${REG_CIPHERTEXT_PROP}) ); then # ciphertext and MOS user ID exists, continue with # registration based on ciphertext do_ciphertext_registration || return 1 elif ( $(is_prop_set ${REG_PASSWORD_PROP}) ); then # password and MOS user ID exists, continue with # registration based on password do_username_pass_registration || return 1 else # attempt anonymous registration do_anonymous_registration || return 1 fi else # We are expecting the SMF properties in the reg group # to be empty, otherwise we fail the SMF service. # We already checked the REG_USER_PROP. if ( $( is_prop_set ${REG_PASSWORD_PROP} ) || $( is_prop_set ${REG_PROXY_HOST_PROP} ) || $( is_prop_set ${REG_PROXY_USER_PROP} ) || $( is_prop_set ${REG_PROXY_PASSWORD_PROP} ) || $( is_prop_set ${REG_CONFIG_HUB_PROP} ) || $( is_prop_set ${REG_CIPHERTEXT_PROP} ) || $( is_prop_set ${REG_INDEX_PROP} ) ); then exit $SMF_EXIT_ERR_FATAL else # remove ccr/config/default/sched.properties # it will be generated from usr/lib/ocm/ccr/config/default/sched.properties.template /usr/bin/rm -f ${OCM_SCHED_CONFIG} # $REG_USER_PROP is empty go to disabled mode. $SU_OCM "$SU_ENV ${REG_CMD} -a -d" || return 1 fi fi fi return 0 } # do_registration # # do_restart # # start OCM scheduler # # The scheduler is now launched in background. # The SMF restarter is now watching it and will rerun # start() in this file (which leads us here again) # if it exits other than through stop() in this file. # do_restart() { ${SU_OCM} "$SU_ENV ${OCM_SCHEDULER_RESTART}" & echo "Restarted scheduler..." return 0 } # do_restart # # Major methods # # # do_start # # If not registered attempt to do so; scheduler starts # as side effect. Let check for scheduler running take # place anyway. # If registered but scheduler not running just restart it. # do_start() { echo "$0: starting..." is_ocm_registered registered=$? # We do not need to remove configuration prior to registering # as registration will remove it. is_disconnected_collector_mode disconnected=$? if [[ $registered -ne $TRUE || $disconnected -ne $FALSE ]]; then is_prop_set ${OPT_OUT_PROP} should_opt_out=$? if [[ $should_opt_out -ne $TRUE ]]; then if ( $(is_prop_set ${REG_CONFIG_HUB_PROP}) ); then ccr_hub=$(getproparg ${REG_CONFIG_HUB_PROP} 2> /dev/null) echo "Using OCM hub: $ccr_hub" export ORACLE_OCM_SERVICE="${ccr_hub}" fi do_registration reg_status=$? restore_place_holder_files return $reg_status else echo "opt-out selected: disabling this service..." disable_ocm # and exit: force success code exit $SMF_EXIT_OK fi # do opt-out else # not registered if [[ -f ${OCM_COLLECTOR_LOCKFILE} ]]; then echo "OCM collector lockfile exists" is_process_running ${OCM_SCHEDULER_PS} running_sched=$? if [[ $running_sched -eq $FALSE ]]; then echo "OCM scheduler not running, remove lockfile" /usr/bin/rm -f ${OCM_COLLECTOR_LOCKFILE} # Remove the old target files files=`/usr/bin/ls ${OCM_COLLECTOR_LOCKFILE}* | /usr/bin/grep "${OCM_COLLECTOR_LOCKFILE}\.[0-9]*\.[0-9]*"` /usr/bin/rm -f $files fi fi fi # not registered if [[ ! -s ${OCM_SCHED_CONFIG} ]]; then echo "Restore sched.properties to default values and current time" cur_hour=`/usr/bin/date +%H` cur_minute=`/usr/bin/date +%M` /usr/bin/sed -e 's/%FREQUENCY%/DAILY/' -e "s/%HOUR%/$cur_hour/" -e "s/%MINUTE%/$cur_minute/" ${OCM_SCHED_TEMPLATE} > ${OCM_SCHED_CONFIG} chmod 0600 ${OCM_SCHED_CONFIG} fi do_restart return 0 } # do_start() # # do_stop # # do_stop() { echo "Stopping scheduler..." let count=1 while [[ "$count" -le "$OUT_STOP_RETRY_COUNT" ]] do OUT_STOP=$($SU_OCM "$SU_ENV $OCM_SCHEDULER_STOP" 2>&1) OUT_NO=$? if [[ $OUT_NO != 0 ]]; then case "$OUT_STOP" in *$OUT_STOP_IGNORE_ERR1*) return 0 ;; *$OUT_STOP_IGNORE_ERR2*) return 0 ;; *$OUT_STOP_RETRY*) echo "Stopping scheduler... retry $count in $OUT_STOP_RETRY_SLEEP_TIME seconds" sleep $OUT_STOP_RETRY_SLEEP_TIME let count=$count+1 ;; *) echo $OUT_STOP return $OUT_NO ;; esac else return 0 fi done echo $OUT_STOP return $OUT_NO } # # do_unconfigure # # do_unconfigure() { echo "$0: Unconfiguring..." echo "Removing custom OCM smf values (if any)." /usr/sbin/svccfg -s $SERVICE delcust reg || return 1 # We do not exit if there was no previous OCM configuration remove_oracle_config_home ex_value=$? restore_place_holder_files if [[ $ex_value -ne 0 ]]; then echo "Failed to remove OCM configuration files." return 1 fi /usr/sbin/svcadm refresh $SERVICE || return 1 return 0 } # do_refresh # # Reread the configuration files since the ocm.xml has been modified # do_refresh() { echo "Doing refresh..." exit $SMF_EXIT_OK } # do_temp_stop_until_next_reboot # # do_temp_stop_until_next_reboot() { /usr/sbin/svcadm disable -t $SMF_FMRI echo "Unable to contact ccr.oracle.com. Please set your system proxy\n \ in order to allow this system to contact Oracle for better\n \ serviceability. See the configCCR(1M) manual page on home to set\n \ the proxy server for Oracle Configuration Manager.\n" echo "$SMF_FMRI has been temporarily disabled.\n\n" exit $SMF_EXIT_OK } # do_temp_stop_until_next_reboot() # # Main # SwitchConfigFileOwner case "$1" in 'start') do_start || do_temp_stop_until_next_reboot ;; 'stop') do_stop || exit $SMF_EXIT_ERR_FATAL ;; 'unconfigure') do_unconfigure || exit $SMF_EXIT_ERR_FATAL ;; 'refresh') do_refresh || exit $SMF_EXIT_ERR_FATAL ;; esac exit $SMF_EXIT_OK