#!/bin/sh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/haws/sbin/subsys/tds/import.sh 1.26 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2004,2011 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)33 1.26 src/43haes/usr/sbin/cluster/haws/sbin/subsys/tds/import.sh, hacmp.assist, 61haes_r714 11/28/11 15:15:11 # ############################################################################### # # This is an application-specific import script that reads the # TDS configuration files and translates it into HACMP specific # commands. The output of this script is another script that can be # called to perform the actual import into HACMP. ############################################################################### # TDS Package name TDS_PACKAGE_NAME="IBMDirectoryProduct" # Version 5.1 TDS TDS_VERSION_51="5.1" # Version 5.2 TDS TDS_VERSION_52="5.2" # Global variable for the TDS Version. We carry it around because # some of the functions may need to do different things depending # on the version. TDS_VERSION="" # The directory where TDS is installed TDS_INSTALL_DIR="" # The volume group where TDS is configured. We'll need to make sure # this is made highly available. TDS_VG="" # Specifies the name of the node where TDS will fallover to # to. TDS_FALLOVER_NODE="" TDS_SERVICE_LABEL="" TDS_DB_LOCATION_ID="ibm-slapdDbLocation" TDS_DB_DIR="" TDS_DB_VG="" TDS_CONF_FILE="" WAS_CELL="" WAS_NODE="" WAS_SERVER_NAME="" WAS_INSTALL_DIR="" # ############################################################################### # # SCRIPT DEFINITION SECTION # ############################################################################### # Define Functions ############################################################################### ############################################################################### # Function: verify_tds_version ############################################################################### # # Make sure that tds is at version 5.2.0 ############################################################################### verify_tds_version() { logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Checking TDS version...\n" TDS_VERSION=`lslpp -Lc $TDS_PACKAGE_NAME 2>/dev/null | sed -e '/^#/d' | cut -f3 -d':' | cut -f 1,2 -d '.'` logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "TDS Version = $TDS_VERSION\n" case $TDS_VERSION in $TDS_VERSION_52) logmsg HAWS_INFO "$MSG_TDS_VER51_DETECTED" "IBM TDS v5.2 detected\n" ;; "") logmsg HAWS_ERROR "$MSG_TDS_NOT_INSTALLED" "IBM TDS could not be found. Please install IBM TDS v5.2\n" exit $HAWS_EXIT_FAIL ;; *) logmsg HAWS_ERROR "$MSG_TDS_UNKNOWN_VERSION" "Unsupported version of IBM TDS: %s. Please install IBM TDS v5.2\n" $TDS_VERSION exit $HAWS_EXIT_FAIL esac } ############################################################################### # Function: get_tds_install_dir ############################################################################### # # Get the location where TDS is installed. ############################################################################### get_tds_install_dir() { logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Getting TDS installation directory..." TDS_INSTALL_DIR=`lslpp -Lc $TDS_PACKAGE_NAME 2>/dev/null | sed -e '/^#/d' | cut -f9 -d':'` logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Directory = $TDS_INSTALL_DIR" TDS_CONF_FILE="$TDS_INSTALL_DIR/etc/ibmslapd.conf" logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "TDS config file = $TDS_CONF_FILE" WAS_INSTALL_DIR="$TDS_INSTALL_DIR/appsrv" logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "WAS Install Directory = $WAS_INSTALL_DIR" } ############################################################################### # Function: parse_tds_config ############################################################################### # # Get the TDS Admin and TDS Database Directory ############################################################################### parse_tds_config() { TDS_ADMIN=`grep '^ibm-slapdAdminDN:' $TDS_CONF_FILE | awk '{print $2}' | sed 's/cn=//g'` TDS_DB_DIR=`grep $TDS_DB_LOCATION_ID $TDS_CONF_FILE | cut -f2 -d':' | sed -e 's/ //g'` logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "DB Directory = $TDS_DB_DIR" } ############################################################################### # Function: get_tds_vg ############################################################################### # # Gets the volume group where the TDS configuration files exist. ############################################################################### get_tds_vg() { logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Getting the vg for TDS...\n" VG="" if [[ -d "$TDS_INSTALL_DIR" ]] ; then findvg "$TDS_INSTALL_DIR" if [[ $? -eq HAWS_EXIT_FAIL ]]; then exit $HAWS_EXIT_FAIL fi TDS_VG=$VG fi if [[ "$TDS_VG" = "" ]] ; then logmsg HAWS_ERROR "$MSG_TDS_UKNOWN_VG" "Can't get the volume group for TDS directory: %s\n" $TDS_INSTALL_DIR else logmsg HAWS_INFO "$MSG_TDS_VG_FOUND" "TDS Volume group = %s\n" $TDS_VG fi } ############################################################################### # Function: get_tds_db_vg ############################################################################### # # Gets the volume group where the TDS database configuration files exist. ############################################################################### get_tds_db_vg() { logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Getting the vg for TDS...\n" VG="" if [[ -d "$TDS_DB_DIR" ]] ; then findvg $TDS_DB_DIR"/sqllib" if [[ $? -eq HAWS_EXIT_FAIL ]]; then exit $HAWS_EXIT_FAIL fi TDS_DB_VG=$VG fi if [[ "$TDS_DB_VG" = "" ]] ; then logmsg HAWS_ERROR "$MSG_TDS_DB_UKNOWN_VG" "Can't get the volume group for TDS database directory: %s\n" $TDS_DB_DIR exit $HAWS_EXIT_FAIL fi logmsg HAWS_INFO "$MSG_TDS_DB_VG_FOUND" "TDS DB Volume group = %s\n" $TDS_DB_VG } ############################################################################### # Function: validate_tds_config ############################################################################### # # Validate the TDS configuration information against HACMP. Make # sure it makes sense to import this stuff. ############################################################################### validate_tds_config() { logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Validating TDS configuration..." IBMSLAPD_CONF=$TDS_INSTALL_DIR"/etc/ibmslapd.conf" local_sum=`sum $IBMSLAPD_CONF` remote_sum=`rsh $TDS_FALLOVER_NODE "sum $IBMSLAPD_CONF"` logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "$IBMSLAPD_CONF checksum - local: $local_sum $TDS_FALLOVER_NODE: $remote_sum\n" if [[ $local_sum != $remote_sum ]] ; then logmsg HAWS_WARN "$MSG_TDS_WARN_IBMSLAPD_CONF_SUM" "The checksum of file %s (%s) does not match the checksum on node %s (%s).\n" $IBMSLAPD_CONF $local_sum $TDS_FALLOVER_NODE $remote_sum fi # If not Validating, there is no need to do anything else. if [[ $VALIDATE_FLAG -ne 1 ]] ; then return fi # Check for the configuration file logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking Configuration file $cfg_script" if [[ ! -f $cfg_script ]] ; then logmsg HAWS_ERROR $MSG_CONFIG_FILE_NOT_FOUND "The configuration file %s was not found.\n" $cfg_script return fi # Check the Configuration script for matching items logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_INSTALL_DIR $TDS_INSTALL_DIR" if [[ -z $(grep -w "TDS_INSTALL_DIR=\"$TDS_INSTALL_DIR\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_INSTALL_DIR "The TDS Installation Directory %s does not match value in %s\n" $TDS_INSTALL_DIR $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_VG $TDS_VG" if [[ -z $(grep -w "TDS_VG=\"$TDS_VG\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_VG "The TDS Volume Group %s does not match value in %s\n" $TDS_VG $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_DB_DIR $TDS_DB_DIR" if [[ -z $(grep -w "TDS_DB_DIR=\"$TDS_DB_DIR\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_DB_DIR "The TDS Database Directory %s does not match value in %s\n" $TDS_DB_DIR $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_DB_VG $TDS_DB_VG" if [[ -z $(grep -w "TDS_DB_VG=\"$TDS_DB_VG\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_DB_VG "The TDS Database Volume Group %s does not match value in %s\n" $TDS_DB_VG $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_ADMIN $TDS_ADMIN" if [[ -z $(grep -w "TDS_ADMIN=\"$TDS_ADMIN\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_ADMIN "The TDS Administrator %s does not match value in %s\n" $TDS_ADMIN $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_PASSWORD" if [[ -z $(grep -w "TDS_PASSWORD=\"$TDS_PASSWORD\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_PASSWORD "The TDS Password does not match value in %s\n" $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_PORT $TDS_PORT" if [[ -z $(grep -w "TDS_PORT=\"$TDS_PORT\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_PORT "The TDS Port %s does not match value in %s\n" $TDS_PORT $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_DB_USER $TDS_DB_USER" if [[ -z $(grep -w "TDS_DB_USER=\"$TDS_DB_USER\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_DB_USER "The TDS Database User %s does not match value in %s\n" $TDS_DB_USER $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking TDS_CONF_FILE $TDS_CONF_FILE" if [[ -z $(grep -w "TDS_CONF_FILE=\"$TDS_CONF_FILE\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_TDS_NO_MATCH_CONF_FILE "The TDS Configuration File %s does not match value in %s\n" $TDS_CONF_FILE $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking WAS_CELL $WAS_CELL" if [[ -z $(grep -w "WAS_CELL=\"$WAS_CELL\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_WAS_NO_MATCH_CELL "The WAS Cell %s does not match value in %s\n" $WAS_CELL $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking WAS_NODE $WAS_NODE" if [[ -z $(grep -w "WAS_NODE=\"$WAS_NODE\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_WAS_NO_MATCH_NODE "The WAS Node %s does not match value in %s\n" $WAS_NODE $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking WAS_SERVER_NAME $WAS_SERVER_NAME" if [[ -z $(grep -w "WAS_SERVER_NAME=\"$WAS_SERVER_NAME\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_WAS_NO_MATCH_SERVER_NAME "The WAS Server Name %s does not match value in %s\n" $WAS_SERVER_NAME $cfg_script fi logmsg HAWS_DEBUG $MSG_DEBUG_MSG "Checking WAS_INSTALL_DIR $WAS_INSTALL_DIR" if [[ -z $(grep -w "WAS_INSTALL_DIR=\"$WAS_INSTALL_DIR\"" $cfg_script) ]] ; then logmsg HAWS_ERROR $MSG_WAS_NO_MATCH_INSTALL_DIR "The WAS Installation Directory %s does not match value in %s\n" $WAS_INSTALL_DIR $cfg_script fi } ############################################################################### # Function: generate_import_script ############################################################################### # # Write the script that will be used to import the TDS configuration # information into HACMP. ############################################################################### generate_import_script() { # Setup the variable names here tds_start_script="$HAWS_HOME/sbin/subsys/tds/startTDS" tds_stop_script="$HAWS_HOME/sbin/subsys/tds/stopTDS" tds_monitor_script="$HAWS_HOME/sbin/subsys/tds/monitor_tds" # This is the script that does the actual import logmsg HAWS_TRACE "$MSG_CREATE_IMPORT" "Generating the import script...\n" echo "#!/usr/bin/ksh93" > $create_script echo "# Script Automatically created on `date`" >> $create_script echo "# Any changes made to this file will be lost next time" >> $create_script echo "# the IBM Directory Server configuration information is imported" >> $create_script echo " " >> $create_script echo ". $clhaws_functions" >> $create_script echo " " >> $create_script echo "FPATH_BASE=/usr/es/lib/ksh93" >> $create_script echo "FPATH=\$FPATH_BASE/hacmp" >> $create_script echo "export FPATH" >> $create_script echo " " >> $create_script echo "get_cluster_state" >> $create_script echo "if [[ \$CLUSTER_STATE -ne 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_CLUSTER_NOT_STABLE \"Cluster is not in stable state.\\\\n\"" >> $create_script echo "exit 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# add service label to PowerHA SystemMirror" >> $create_script echo "logmsg HAWS_INFO $MSG_TDS_SERVICE_ADD \"Creating Service label %s.\\\\n\" \"$TDS_SERVICE_LABEL\"" >> $create_script echo "NETWORK=\$(KLIB_HACMP_get_net_with_most_interfaces $TDS_SERVICE_LABEL)" >> $create_script echo "claddnode -Tservice -B\"$TDS_SERVICE_LABEL\" -w\"\$NETWORK\"" >> $create_script echo "if (( \$? != 0 )); then" >> $create_script echo "logmsg HAWS_ERROR $MSG_TDS_SERVICE_ADD_FAIL \"ERROR: Failed creating PowerHA SystemMirror Service IP Label %s.\\\\n\" \"$TDS_SERVICE_LABEL\"" >> $create_script echo "return 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# Check the application server " >> $create_script echo "$CLLSSERV -n ${asname} >/dev/null 2>&1" >> $create_script echo "if [[ \$? -eq 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_ASNAME_EXISTS \"The Application Server name %s already exists in the cluster.\\\\n\"" $asname >> $create_script echo "return 2" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# Create the application server " >> $create_script echo "$CLADDSERV -s'$asname' -b'$tds_start_script $cfg_script' -e'$tds_stop_script $cfg_script'" >> $create_script echo "if [[ \$? -ne 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_AS_CREATE_FAILED \"Application Server Creation Failed.\\\\n\"" >> $create_script echo "return 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "logmsg HAWS_INFO $MSG_APP_SERVER_CREATED \"Application Server %s created.\\\\n\" \"$asname\"" >> $create_script echo " " >> $create_script echo "# Check the resource group " >> $create_script echo "$CLLSGRP 2>/dev/null | grep $rgname > /dev/null 2>&1" >> $create_script echo "if [[ \$? -eq 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_RGNAME_EXISTS \"The Resource Group name %s already exists in the cluster.\\\\n\"" $rgname >> $create_script echo "return 2" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# Create the resource group " >> $create_script echo "$CLADDGRP -g '$rgname' -s 'ignore' -n '`hostname` $TDS_FALLOVER_NODE' -S 'OHN' -O 'FNPN' -B 'NFB'" >> $create_script echo "if [[ \$? -ne 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_RG_CREATE_FAILED \"Resource Group Creation Failed.\\\\n\"" >> $create_script echo "return 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "logmsg HAWS_INFO $MSG_RESOURCE_GROUP_CREATED \"Resource Group %s created.\\\\n\" \"$rgname\"" >> $create_script echo " " >> $create_script echo "# Check the Application Monitor " >> $create_script echo "$CLLSAPPMON -c ${asname} >/dev/null 2>&1" >> $create_script echo "if [[ \$? -eq 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_ASMON_EXISTS \"The Application Monitor %s already exists in the cluster.\\\\n\"" ${asname} >> $create_script echo "return 2" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# Create the application monitor" >> $create_script echo "$CLADDAPPMON MONITOR_TYPE=user name='$asname' INVOCATION='$mon_mode' RESOURCE_TO_MONITOR='$asname' MONITOR_METHOD='$app_monitor_script' INVOCATION='longrunning' MONITOR_INTERVAL='120' STABILIZATION_INTERVAL='420' RESTART_COUNT='3' RESTART_INTERVAL='1800' FAILURE_ACTION='fallover' CLEANUP_METHOD='$tds_stop_script $cfg_script' RESTART_METHOD='$tds_start_script $cfg_script' HUNG_MONITOR_SIGNAL='9'" >> $create_script echo "if [[ \$? -ne 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_ASMON_CREATE_FAILED \"Application Monitor Creation Failed.\\\\n\"" >> $create_script echo "return 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "logmsg HAWS_INFO $MSG_APP_MON_CREATED \"Application Monitor for application server %s created.\\\\n\" \"$asname\"" >> $create_script echo " " >> $create_script echo "# Check the Resource to Monitor" >> $create_script echo "$CLLSRES -cg ${rgname} | grep -v \"\\#\" | IFS=: read tmp tmp tmp tmp tmp tmp tmp tmp tmp tmp tmp tmp name tmp" >> $create_script echo "if (( \${#name} > 0 )) ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_RGMON_EXISTS \"The Resource Monitor %s already exists in the cluster.\\\\n\"" ${rgname} >> $create_script echo "return 2" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "# Create the resource to monitor now" >> $create_script echo "$CLADDRES -g '$rgname' APPLICATIONS='$asname' VOLUME_GROUP='$TDS_DB_VG' VG_AUTO_IMPORT='true' RECOVERY_METHOD='parallel' SERVICE_LABEL='$TDS_SERVICE_LABEL'" >> $create_script echo "if [[ \$? -ne 0 ]] ; then" >> $create_script echo "logmsg HAWS_ERROR $MSG_RGMON_CREATE_FAILED \"Adding resources to resource group failed.\\\\n\"" >> $create_script echo "return 1" >> $create_script echo "fi" >> $create_script echo " " >> $create_script echo "logmsg HAWS_INFO $MSG_RESOURCES_CREATED \"Resources added to resource group %s.\\\\n\" \"$rgname\"" >> $create_script echo " " >> $create_script echo "logmsg HAWS_INFO $MSG_IMPORT_CREATE_COMPLETE \"%s import create complete.\\\\n\" TDS" >> $create_script echo " " >> $create_script # This is the script that backs out the changes logmsg HAWS_TRACE "$MSG_CREATE_REMOVE" "Generating the remove script...\n" echo "#!/bin/sh" > $delete_script echo "# Script Automatically created on `date`" >> $delete_script echo "# Any changes made to this file will be lost next time" >> $delete_script echo "# the IBM Directory Server configuration information is imported" >> $delete_script echo " " >> $delete_script echo ". $clhaws_functions" >> $delete_script echo " " >> $delete_script echo "get_cluster_state" >> $delete_script echo "if [[ \$CLUSTER_STATE -ne 0 ]] ; then" >> $delete_script echo "logmsg HAWS_ERROR $MSG_CLUSTER_NOT_STABLE \"Cluster is not in stable state.\\\\n\"" >> $delete_script echo "exit 1" >> $delete_script echo "fi" >> $delete_script echo " " >> $delete_script echo "# Remove the resources " >> $delete_script echo "$CLRMRES -g '$rgname'" >> $delete_script echo "logmsg HAWS_INFO $MSG_RESOURCES_DELETED \"Resources removed to resource group %s.\\\\n\" \"$rgname\"" >> $delete_script echo " " >> $delete_script echo "# Delete Service IP Label from PowerHA SystemMirror " >> $delete_script echo "logmsg HAWS_INFO $MSG_TDS_SERVICE_REMOVE \"Removing Service IP label %s from PowerHA SystemMirror.\\\\n\" \"$TDS_SERVICE_LABEL\"" >> $delete_script echo "clrmnode -a \"$TDS_SERVICE_LABEL\"" >> $delete_script echo "if (( \$? != 0 )); then" >> $delete_script echo "logmsg HAWS_ERROR $MSG_TDS_SERVICE_REMOVE_FAIL \"ERROR: Failed removing Service IP Label %s from PowerHA SystemMirror.\\\\n\" \"$TDS_SERVICE_LABEL\"" >> $delete_script echo "fi" >> $delete_script echo " " >> $delete_script echo "# Remove the application monitor " >> $delete_script echo "$CLRMAPPMON $asname" >> $delete_script echo "logmsg HAWS_INFO $MSG_APP_MON_DELETED \"Application Monitor for application server %s deleted.\\\\n\" \"$asname\"" >> $delete_script echo " " >> $delete_script echo "# Remove the application server " >> $delete_script echo "$CLRMSERV $asname" >> $delete_script echo "logmsg HAWS_INFO $MSG_APP_SERVER_DELETED \"Application Server %s deleted.\\\\n\" \"$asname\"" >> $delete_script echo " " >> $delete_script echo "# Remove the resource group " >> $delete_script echo "$CLRMGRP -g $rgname" >> $delete_script echo "logmsg HAWS_INFO $MSG_RESOURCE_GROUP_DELETED \"Resource Group %s deleted..\\\\n\" \"$rgname\"" >> $delete_script echo " " >> $delete_script echo "logmsg HAWS_INFO $MSG_IMPORT_DELETE_COMPLETE \"%s import delete complete.\\\\n\" TDS" >> $delete_script echo " " >> $delete_script # Create the configuration script where application specific settings are stored logmsg HAWS_TRACE "$MSG_CREATE_CONFIG" "Generating config file...\n" echo "#!/bin/sh" > $cfg_script echo "# Script Automatically created on `date`" >> $cfg_script echo "# Any changes made to this file will be lost next time" >> $cfg_script echo "# the IBM Directory Server configuration information is imported" >> $cfg_script echo " " >> $cfg_script echo "# IBM Directory Server Configuration Information " >> $cfg_script echo " " >> $cfg_script echo "TDS_INSTALL_DIR=\"$TDS_INSTALL_DIR\"" >> $cfg_script echo "TDS_VG=\"$TDS_VG\"" >> $cfg_script echo "TDS_DB_DIR=\"$TDS_DB_DIR\"" >> $cfg_script echo "TDS_DB_VG=\"$TDS_DB_VG\"" >> $cfg_script echo "TDS_ADMIN=\"$TDS_ADMIN\"" >> $cfg_script echo "TDS_PASSWORD=\"$TDS_PASSWORD\"" >> $cfg_script echo "TDS_PORT=\"$TDS_PORT\"" >> $cfg_script echo "TDS_DB_USER=\"$TDS_DB_USER\"" >> $cfg_script echo "TDS_CONF_FILE=\"$TDS_CONF_FILE\"" >> $cfg_script echo "WAS_CELL=\"$WAS_CELL\"" >> $cfg_script echo "WAS_NODE=\"$WAS_NODE\"" >> $cfg_script echo "WAS_SERVER_NAME=\"$WAS_SERVER_NAME\"" >> $cfg_script echo "WAS_INSTALL_DIR=\"$WAS_INSTALL_DIR\"" >> $cfg_script echo "#!/bin/sh" > $app_monitor_script echo "# Script Automatically created on `date`" >> $app_monitor_script echo "# Any changes made to this file will be lost next time" >> $app_monitor_script echo "# the IBM Directory Server configuration information is imported" >> $app_monitor_script echo " " >> $app_monitor_script echo "# IBM Directory Server monitor script " >> $app_monitor_script echo " " >> $app_monitor_script echo "$tds_monitor_script \"$cfg_script\"" >> $app_monitor_script echo " " >> $app_monitor_script echo "exit \$?" >> $app_monitor_script complete_scripts $TDS_FALLOVER_NODE } ############################################################################### # # Function: process_arguments # This is a subsystem-specific version of the routine that processes # command line arguments. # ############################################################################### process_arguments() { logmsg HAWS_DEBUG "$MSG_TDS_PROCARG" "Processing 'tds' arguments...\n" while getopts :n:l:u:w:p:i:o: c do case $c in n) TDS_FALLOVER_NODE=$OPTARG logmsg HAWS_INFO "$MSG_FALLOVER_NODE_NAME_SET" "Fallover Node specified as %s\n" $TDS_FALLOVER_NODE ;; l) TDS_SERVICE_LABEL=$OPTARG logmsg HAWS_INFO "$MSG_SERVICE_LABEL_SET" "Service Label set to %s\n" $TDS_SERVICE_LABEL ;; w) TDS_PASSWORD=$OPTARG logmsg HAWS_INFO "$MSG_TDS_PASSWORD_SET" "TDS Password set.\n" ;; p) TDS_PORT=$OPTARG logmsg HAWS_INFO "$MSG_TDS_PORT_SET" "TDS Port set to %s\n" $TDS_PORT ;; i) TDS_DB_USER=$OPTARG logmsg HAWS_INFO "$MSG_TDS_DB_USER_SET" "TDS DB Admin user set to %s\n" $TDS_DB_USER ;; o) WAS_NODE=$OPTARG logmsg HAWS_INFO "$MSG_WAS_NODE_SET" "WAS Node set to %s\n" $WAS_NODE ;; \?) logmsg HAWS_ERROR "$MSG_UNKNOWN_OPTION" "Unrecognized command line option specified\n" exit $HAWS_EXIT_FAIL;; esac done logmsg HAWS_DEBUG "$MSG_TDS_PROCDONE" "Done processing 'tds' arguments...\n" status=0 # Make sure that a fallover node was specified if [[ "$TDS_FALLOVER_NODE" = "" ]] ; then logmsg HAWS_ERROR "$MSG_NO_FALLOVER" "You must specify a fallover node using the -n flag\n" status=1 fi # Make sure that a service label was specified if [[ "$TDS_SERVICE_LABEL" = "" ]] ; then logmsg HAWS_ERROR "$MSG_NO_SERVICE_LABEL" "You must specify a service label using the -l flag\n" status=1 fi # Make sure that a tds password was specified if [[ "$TDS_PASSWORD" = "" ]] ; then logmsg HAWS_ERROR "$MSG_TDS_NO_PASSWORD" "You must specify a TDS password using the -w flag\n" status=1 fi # Make sure that a tds port was specified if [[ "$TDS_PORT" = "" ]] ; then logmsg HAWS_ERROR "$MSG_TDS_NO_PORT" "You must specify a TDS port using the -p flag\n" status=1 fi # Make sure that a tds db user was specified if [[ "$TDS_DB_USER" = "" ]] ; then logmsg HAWS_ERROR "$MSG_TDS_NO_DB_USER" "You must specify a TDS database user using the -i flag\n" status=1 fi if [[ status -ne 0 ]] ; then exit $HAWS_EXIT_FAIL fi } ############################################################################### # Function: remote_copy_tds_conf ############################################################################### # # Copy the TDS configuration file /etc/ibmslapd.conf to the fallover # node. ############################################################################### remote_copy_tds_conf() { tds_copy_status=0 IBMSLAPD_CONF=$TDS_INSTALL_DIR"/etc/ibmslapd.conf" IBMSLAPD_CONF_HAWS=$TDS_INSTALL_DIR"/etc/ibmslapd.conf.haws" logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Saving $IBMSLAPD_CONF on node $TDS_FALLOVER_NODE to $IBMSLAPD_CONF_HAWS\n" rsh $TDS_FALLOVER_NODE "if [[ -f $IBMSLAPD_CONF ]] ; then cp -fp $IBMSLAPD_CONF $IBMSLAPD_CONF_HAWS ; fi" > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Copying $IBMSLAPD_CONF to node $TDS_FALLOVER_NODE\n" rcp -F $IBMSLAPD_CONF $TDS_FALLOVER_NODE:$IBMSLAPD_CONF > /dev/null 2>&1 if [[ $? -ne 0 ]] ; then logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Copy did not work\n" tds_copy_status=1 fi else logmsg HAWS_DEBUG "$MSG_DEBUG_MSG" "Save did not work\n" tds_copy_status=1 fi if [[ $tds_copy_status -ne 0 ]] ; then logmsg HAWS_WARN "$MSG_TDS_WARN_CONF_COPY" "Cannot copy TDS conf file %s to node %s.\n" $IBMSLAPD_CONF $TDS_FALLOVER_NODE fi } ############################################################################### # # SCRIPT EXECUTION SECTION # ############################################################################### # This section of the script is used to call into the various predefined # to perform the actual script execution. # # The intent of this section is to provide a high-level view of how this # script operates. ############################################################################### process_arguments $* verify_tds_version get_tds_install_dir parse_tds_config get_tds_vg get_tds_db_vg parse_websphere_config init_java get_server_names create_script_names "tds" `hostname` $TDS_FALLOVER_NODE validate_tds_config # If not Validating, generate the scripts if [[ $VALIDATE_FLAG -ne 1 ]] ; then remote_copy_tds_conf generate_import_script fi