#!/bin/sh # # Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. # # oka.sbs - init script for the kernel Accelerator # This is run by the RC system. ################### INSTANTIATED VARIABLES #################### ORACLE_HOME=%ORA_CRS_HOME% export ORACLE_HOME PATH=/usr/bin:/bin:$ORACLE_HOME/bin USER=%ORACLE_OWNER% ################### TOOLS ##################################### if [ -z "$CHMOD" ]; then CHMOD=/bin/chmod; fi if [ -z "$ECHO" ]; then ECHO=/bin/echo; fi UNAME=/bin/uname PLATFORM=`$UNAME` OKAROOT=${ORACLE_HOME}/bin/okaroot OKALOAD=${ORACLE_HOME}/bin/okaload ######### CLI tools ######### HOSTN=/bin/hostname ECHO=/bin/echo SLEEP=/bin/sleep BASENAME=/bin/basename RMF="/bin/rm -f" HOSTN=/bin/hostname TOUCH=/bin/touch SU=/bin/su CAT=/bin/cat LOGMSG="/bin/logger -puser.err" LOGERR="/bin/logger -puser.alert" MKDIR=/usr/bin/mkdir CHMOD=/usr/bin/chmod CHOWN=/usr/bin/chown DIRNAME=/usr/bin/dirname # Location to TR differs in diff. platforms. TR=/bin/tr # How long to wait (in seconds) before rechecking a dependency, # and printing out messages about it. DEP_CHECK_WAIT=60 case $PLATFORM in Linux) ID=/etc/init.d INIT=/sbin/init LOGGER="/usr/bin/logger" if [ ! -f "$LOGGER" ]; then LOGGER="/bin/logger" fi LOGERR="$LOGGER -puser.err" LOGMSG="$LOGGER -puser.alert" SUBSYSFILE="/var/lock/subsys/oka" TOUCH=/bin/touch RMF="/bin/rm -f" MKDIR=/bin/mkdir CHMOD=/bin/chmod CHOWN=/bin/chown TR=/usr/bin/tr OKA_PORTAL_DEV=/dev/oracka ;; SunOS) TR=/usr/xpg4/bin/tr ;; *) /bin/echo "ERROR: Unknown Operating System" exit -1 ;; esac # Function : Log message to syslog and console log_console () { $ECHO "$*" $LOGMSG "$*" } log_error () { $ECHO "$*" $LOGERR "$*" } success_status() { $LOGMSG "OK" return 0 } if_fail() { RC="$1" REASON="$2" if [ "$RC" = "0" ] then success_status return fi log_error "${REASON}" exit 1 } add_subsysfile() { case $PLATFORM in Linux) #TODO make sure that this makes sense for us # Create /var/lock/subsys/oka $TOUCH $SUBSYSFILE ;; *) ;; esac } rem_subsysfile() { case $PLATFORM in Linux) # remove /var/lock/subsys/oka ;; *) ;; esac } install() { $LOGMSG "Installing OKA... " CMD="${OKAROOT} install" $CMD if_fail "$?" "Failed to install OKA" add_subsysfile $LOGMSG "OKA Installed." } uninstall() { $LOGMSG "Uninstalling OKA... " CMD="${OKAROOT} uninstall" $CMD if_fail "$?" "Failed to uninstall OKA" rem_subsysfile $LOGMSG "OKA Uninstalled." } start() { #TODO find if we really need to wait $LOGMSG "Starting OKA... " # Wait until it is safe to start OKA # Wait for 10 minutes for filesystem to mount # Print message to syslog and console works=true for minutes in 10 9 8 7 6 5 4 3 2 1 do if [ ! -r $OKALOAD ] then works=false log_console "Waiting $minutes minutes for filesystem containing $OKALOAD." $SLEEP $DEP_CHECK_WAIT else works=true break fi done if [ ! $works ] then log_console "Fatal Error :: Timed out waiting for the filesystem containing $OKALOAD." log_console "Oracle Grid Infrastructure not able to access filesystem containing $OKALOAD." log_console "Fix the problem and issue command 'okaroot install' as root user to start kernel accelerator." exit 1 fi CMD="${OKALOAD} start" $CMD if_fail "$?" "Failed to install OKA" add_subsysfile $LOGMSG "OKA Loaded." } stop() { $LOGMSG "Stoping OKA... " CMD="${OKALOAD} stop" $CMD if_fail "$?" "Failed to stop OKA" rem_subsysfile $LOGMSG "OKA Unloaded." } status() { $LOGMSG "Checking OKA status..." CMD="${OKALOAD} check" $CMD if_fail "$?" "OKA Portal device is not accessible" $LOGMSG "OKA Accessible" } # Main loop case $1 in 'start') start ;; 'stop') stop ;; 'restart') stop start ;; 'status') status ;; 'install') install ;; 'uninstall') uninstall ;; 'enable') $LOGMSG "Enable OKA.." start ;; 'disable') $LOGMSG "Disable OKA.." stop ;; *) $ECHO "Usage: $0 {stop|start|restart|status|install|uninstall|disable|enable}" exit 1; ;; esac exit 0