fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER END
9444c26f4faabda140242c3986089704c4073cedTom Whitten# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# help message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $CLUSTER_CONFIGURED -eq 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -i : display information on the Availability Suite services
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -e : enable Availability Suite services (all, by default)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -d : disable Availability Suite services (all, by default)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -r : enable/disable Remote Mirror
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $CLUSTER_CONFIGURED -eq 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -s : set the location of the cluster configuration database" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -x : turn on script debugging (may be used with any valid option)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte When executed with no options or with nothing but -x, $PROG runs in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte interactive fashion, allowing the user to initialize the local (and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if applicable, the cluster) configuration database, and to start the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## SET GLOBAL VARIABLES ######################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# root directory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set lib path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set parser config location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set local dscfg location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set cluster dscfg reference file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# a service that has a dependency on us
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# SMF defines
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# SMF services (enable and disable)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSMF_ENABLE="nws_scm nws_sv nws_ii nws_rdc nws_rdcsyncd"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSMF_DISABLE="nws_rdcsyncd nws_rdc nws_ii nws_sv nws_scm"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# state of each service
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set architecture
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# number of sectors required for database
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 1024*1024*5.5/512
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# must set here, else seen as null in MAIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# for debugging
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set lengthy message here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCLUST_LOC_MESS="The current location is invalid for a Sun StorageTek \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteData Services configuration database. Once a valid location is \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteentered (raw slice on \"did\" device), you may upgrade the existing \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedatabase to this new location - following the procedure outlined \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortein the Installation and Configuration Guide."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## SET GLOBAL VARIABLES ######################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## ERROR ####################################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# called with optional error msg $1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# prints basic guidelines for configuration of the database location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -eq 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\tBecause you are installing on a cluster," >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\tthe database must be located on a raw slice of a did device.">&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\t$REQUIRED sectors ($MB MBs) are required for the database." >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## ERROR ####################################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## ALL LOCATION TESTS ########################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# sets numerous environment variables describing the state of the system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $IN_CLUSTER = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Checks if in cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# returns 1 if in cluster, else 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -x /usr/sbin/clinfo ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -eq 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# checks if a system is configured as a cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# returns 1 if configured as a cluster, 0 if not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -f /etc/cluster/nodeid ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Check the list of Sun Cluster device groups known in the dscfg, determing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# if they are currently enabled on this Sun Cluster node. If so, fail allowing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# the system administator to scswitch them elsewhere.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $VALID_CLUSTER_DB == 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEVICE_GROUPS=`$DSCFG -s $FILE_LOC -l 2>/dev/null | \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte grep "^dsvol:" | cut -d' ' -f3 | sort | uniq | xargs`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -eq 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print "The following Sun Cluster device groups are in use "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print "'scswitch' them to another Sun Cluster node before "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# checks to see if this is a char device in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# /dev/did/rdsk directory returns 1 if so.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ "did" = $DID -a "rdsk" = $RDSK -a -c $1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# checks size of area for db location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SECTORS=`prtvtoc $1 | tr -s ' '| grep "^ $SLICE " | awk '{print $5}'`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if required size is greater than space available, then fail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# looks in dscfg_cluster reference file. if a location is configured,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# tests to see if it is a valid database. if so, returns 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -s $CLUSTER_REF ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# checks for the existence of dscfg_local database, and if it exists,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# tests to see if it is a valid database. if so, returns 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -s $LOCAL_DSCFG ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# used to test if a valid DS config database exists on machine already
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# MAGIC_STRING is the top line in the config used in v3.1 & v3.2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # dscfg distinct strings, varies on the architecture
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Write the first or 16th block (skipping over VTOC) to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # the TMP_FILE, then scan for the presence of the "MAGI"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd if=$1 of=$TMP_FILE count=1 iseek=$offset 2>/dev/null
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FILECONTENTS=`strings $TMP_FILE | head -1 2>/dev/null`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ `echo $FILECONTENTS | grep -c "$MAGIC_STRING"` -gt 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## ALL LOCATION TESTS ########################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## MAIN FUNCTIONS ############################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# since location already has been set, asks what to do now? keeping
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# it still checks the size (since an upgrade from 3.0 may still be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# occuring) and also checks if was an old cluster config on disallowed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# /dev/did/dsk directory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0 if cluster location is invalid or the user does not want to keep it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 1 if the location is valid and the user wants to keep it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NOTE="\nThe Sun StorageTek Data Services database configuration"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\nCurrent location: $PKG_INSTALL_ROOT$FILE_LOC"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QUEST="Would you like to preserve the existing configuration"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QUEST="$QUEST information at its current location? "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #Since the user has said "yes I want to keep this current one"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #it may actually be a 3.x database, which only required 4.5mb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #space, so now will check that there is room to grow another 1mb"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# asks if user wants to keep existing db information, overwrite with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# a new db, or view the contents, and be asked again...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0 if old location is bad
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 1 if old location is good
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\nIt appears a valid database configuration exists here already."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\nWould you like to preserve this information and continue?"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\tmaybe - view contents of current configuration"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $DSCFG -s "$FILE_LOC" -C $CTAG_NULL >/dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\nContents of database configuration found at $SAFE_LOC are:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# gets location from user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #Checks for absolute path name, and if file name and file doesn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\n\n----------ENTER DATABASE CONFIGURATION LOCATION-----------------"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Note: Please ensure this location meets all requirements specified"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "in the Availability Suite Installation Guide."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # allow non-root user to access for least privileges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# tests for proper config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0 if bad location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 1 if good location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did_clust_msg="You are in cluster and $LOCATION is not valid DID device"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Set "actual file location" variable here to equal file location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # entered by user because getting here means contains_data was already
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # successfully called before and now the two can equal each other for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $IN_CLUSTER = 1 -o $CLUSTER_CONFIGURED = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -b "$LOCATION" ] || [ -c "$LOCATION" ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Location may not be changed in a non Sun Cluster OE." 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error "$LOCATION does not meet minimum space requirement."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Notifies the user that the SMF services are online,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# and gives him the option to disable the services before proceeding. If
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# the services are not disabled, the program cannot proceed with setting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# a new dscfg location.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte\nYour services must be disabled before a new configuration location is set.\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QUEST="Would you like to disable the services now and continue with the"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Asks the user if he would like to enable the services now. If so,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# import them (if necessary) and enable them.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte\nIf you would like to start using the Availability Suite immediately, you may
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestart the SMF services now. You may also choose to start the services later
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing the $PROG -e command."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QUEST="Would you like to start the services now? "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# display information about the system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typeset -L15 svc state en SVC="SERVICE" STATE="STATE" EN="ENABLED"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print "cluster configuration location: ${FILE_LOC}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "\n*** Warning: The service$p above $p_has an incorrect "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# initialize the local configuration database (only called if none exists)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# returns 0 if successful, 1 if failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Could not find a valid local configuration database."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Initializing local configuration database..."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo y | ${DSCFG} -i > /dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${DSCFG} -i -p ${PCONFIG} > /dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Make sure the new location is initialized properly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Unable to initialize local configuration database" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Successfully initialized local configuration database"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# initialize the cluster configuration database, if necessary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# returns 0 if successful, 1 if failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Initializing cluster configuration database..."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${DSCFG} -s ${FILE_LOC} -C $CTAG_NULL > /dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo y | ${DSCFG} -i -C $CTAG_NULL > /dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${DSCFG} -i -p ${PCONFIG} -C $CTAG_NULL > /dev/null 2>&1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Unable to initialize cluster configuration database" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Successfully initialized cluster configuration database"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# prompt the user for a config location and set AVS to use that location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewhile [ $REPEAT -eq 0 ]; do
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # See if user has entered location already, and it was an existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $VALID_DB_ENTERED = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if 1, location passes, and FILE_LOC being passed to end, else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # set VALID_CLUSTER_DB to 0 since the "valid one" isn't valid anymore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # (bad size, etc) thereby when looping go straight to get_location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if 1, then valid db exists, now see what user wants to do
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $VALID_CLUSTER_DB = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if 0, then user can't or won't keep location. set PROMPT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if either are 0, then user wants or needs new db as outlined in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $VALID_CLUSTER_DB = 0 ] || [ $PROMPT = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # We cannot proceed if the services are running. Give the user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # a chance to stop the services. If he chooses not to, bail.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if 1, then user entered an existsing db location, loop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # user wants to leave location where and how it is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## MAIN FUNCTIONS ############################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte######################## SMF HELPER FUNCTIONS ########################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# check if any SMF service is online (enabled)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Display which services are enabled. (Must be called after check_enabled)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "\nThe following Availability Suite services are enabled:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# check if the given SMF service is online (enabled)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: service name to check for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte en=`svcprop -c -p general/enabled svc:/system/${1}:default`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# If necessary, flag no dependency check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# If necessary, remove the no dependency check flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set the filesystem/local dependency type and refresh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: service name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $2: either "require_all" or "optional_all"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $svc != nws_rdcsyncd ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "command failed: svccfg -s $FS_LOCAL_SVC "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "setprop ${svc}-local-fs/grouping=$dep_group "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # we need local-fs to know about the new grouping attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# check if the grouping dependency type for filesystem/local is correct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: service name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0 if the setting is correct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 1 if the setting is incorrect
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# outputs: sets CORRECT_GROUPING with the value of what the grouping should be.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # If it's not imported, we just return success, since we don't want
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # get the current grouping value from the repository
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_grouping=`svcprop -c -p ${svc}-local-fs/grouping $FS_LOCAL_SVC`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Figure out what the grouping should be (based on enabled status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# enable/disable the given SMF service. Also, update the filesystem-local
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# dependency, if appropriate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: service name to check for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $2: "enable" or "disable"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typeset command=$2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # If disabling, then enable_state better be true, and we are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # If enabling, then enable_state better be false, and we are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "$svc service already ${command}d... skipping"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This chart summarizes the behavior of the -r and -p sub-options for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# -e and -d options.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# There are 5 possible states, and 5 transitions out of each state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# states: (vertical axis)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0: no services enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# C: one or both core services enabled (illegal state)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# R: both core services and RM services enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# P: both core services and PITC service enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# A: all services enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# transitions: (horizontal axis)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# ------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# +/-a: enable/disable, respectively, with neither -r nor -p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# +/-r: enable/disable, respectively, with -r flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# +p: enable with -p flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# The result of the function is the next state after the action has been
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# successfully performed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# +a | -a | +r | -r | +p |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# ++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# ++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# 0 || A | 0* | R | 0* | P |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# --++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# C || A* | 0* | R | 0 | P |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# --++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# R || A* | 0* | R* | 0 | A |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# --++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# P || A* | 0* | A* | P* | P* |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# --++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# A || A* | 0 | A* | P | A* |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# --++----+----+----+----+----+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# *: warning message is displayed, stating that a service is already
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# enable the SMF services needed for the Availability Suite
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # first, import them if they have not yet been imported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # if neither r_flag nor p_flag is set, enable all services
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # First, make sure both core services are enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# disable the SMF services needed for the Availability Suite
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? == 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # This flags the shutdown scripts to not check to make sure the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # services' dependents have been disabled. The flag must be removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # NB: p_flag is not allowed for disables. II should not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # disabled if sndr is enabled. If rdc is not enabled, disabling just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # II is equivalent to disabling all the remaining services.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Now that we've disable the services, lets unload them
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte modinfo | grep '(nws:' | grep -v "kRPC Stub" | sort -r | cut -d' ' -f1 | xargs -l modunload -i 2>/dev/null
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte modinfo | grep '(nws:' | grep -v "kRPC Stub" | sort -r | cut -d' ' -f1 | xargs -l modunload -i 2>/dev/null
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # we're disabling just rdc. If II is not already enabled,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# check if a service has been imported into the repository
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: service to check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# returns 1 if it is imported, 0 if it is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcprop -q -p general/entity_stability svc:/system/${svc}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# import the SMF services into the repository, if necessary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# check to see if an SMF service is in the repository. If it is not,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# import it in.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1: name of service to import
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -f $PKG_INSTALL_ROOT/$MANIFEST_PATH/$svc.xml ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svccfg import $PKG_INSTALL_ROOT/$MANIFEST_PATH/$svc.xml
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## MAIN ######################################
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# getopt processing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# at most one option (besides -x) may be specified at a time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteoptions_count=$((enable + disable + set_location + get_info))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif (( ((r_flag + p_flag) > 0) && ((enable | disable) == 0) ))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "-r and -p options may only be used with -d or -e options" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "The -p option may not be used with the -d option" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# set all the system information variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# if we're enabling, we need to make sure we have a valid dscfg out there.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Cannot find a valid configuration database" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # only initialize the database if necessary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Local configuration database is already initialized."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "Cluster configuration database is already "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # ask the user for a cluster database location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # initialize the new db
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # make sure that the local filesystem dependency type is correct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # NOTE: check_fs_local_grouping sets CORRECT_GROUPING
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # To avoid this issue in the future, always administer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # the services using dscfgadm.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # give the user the chance to startup AVS services, if not started
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "WARNING: AVS services are running on a system "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "which had no valid configuration\ndatabase\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? = 1 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # ask the user for a cluster database location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # initialize the new db
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $? != 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "$PROG -s is only available on Sun Cluster OE systems" >&2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte########################## MAIN ######################################