#!/usr/bin/ksh # $Id: ora-smf,v 1.24 2005/12/28 21:54:51 joost Exp $ # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at # http://www.opensource.org/licenses/cddl1.php # See the License for the specific language governing permissions # and limitations under the License. # # Copyright 2005, Joost Mulders. # # Method to stop and start Oracle database & listeners. We're executed by # svc.startd and we expect: # # * Arguments: # stop | start - $1 - to stop or start # database | listener - $2 - what to stop or start # dbname | listenername - $3 - which database or listener to stop/start # * Environment variables # ORACLE_HOME # ORACLE_SID - only when starting a database # # *OR* # # A single keyword "autoimport" which is called as root during postinstall. # "autoimport" reads /var/opt/oracle/oratab and tries to import the # instances defined there. All imported instances are left disabled. # # # Get the directories in wich the files are installed. # [[ ! -z $MFTPATH ]] || MFTPATH=$(/usr/bin/pkgparam ora-smf MFTPATH) [[ ! -z $MTHPATH ]] || MTHPATH=$(/usr/bin/pkgparam ora-smf MTHPATH) # # Source in some functions to keep this method readable # if [[ -r $MTHPATH/ora-smf-func && -r /lib/svc/share/smf_include.sh ]]; then . $MTHPATH/ora-smf-func . /lib/svc/share/smf_include.sh else exit $SMF_EXIT_ERR_CONFIG fi # # See if we got decent arguments # check_arguments $@ || exit # # We're executed by svc.startd # if (( $# > 1 )); then # # See if we got decent environment # check_environ $@ || exit operation=$1 # 'start' or 'stop' object=$2 # 'database' or 'listener' instance=$3 # The SMF instance which *MUST* match Oracle instance status=$SMF_EXIT_ERR_FATAL # Assume problems case $operation in start | stop ) if [[ $object == database ]]; then control_database $operation $instance status=$? elif [[ $object == listener ]]; then control_listener $operation $instance status=$? else exit $SMF_EXIT_ERR_CONFIG fi ;; *) exit $SMF_EXIT_ERR_CONFIG ;; esac # # Tell startd what happened. # exit $status fi # # Do the autoimport thing # if [[ $1 == autoimport ]]; then # # For databases # - Read the oratab file and expand '*' to sid's if necessary # - Lookup the owner and group of the oracle binary # - Modify # /var/svc/manifest/application/database/oracle-database-instance.xml # on the fly and import it. # For listeners # - Read the oratab file and find different ORACLE_HOME's # - For each ORACLE_HOME, find listener.ora and extract listeners # - Modify # /var/svc/manifest/application/database/oracle-listener-instance.xml # on the fly and import it. # auto_import_database auto_import_listener fi