📄 kgbstart.sh
字号:
#!/bin/ksh# Licensed Materials - Property of IBM# Restricted Materials of IBM# Copyright IBM Corp. 2006 All Rights Reserved.# US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with# IBM Corp.## Release Name: omdomino_dev## Description: Start up the Domino/Intelliwatch CPC(kgbclient).# Restart the CPC when the Domino Server has# shutdown.## Parameters:# CANDLEHOME, KGB_NOTESINIPATH, and KGB_INSTANCE_NAME# set in the environment## Returns:# None#======================================================#process_running(){# takes process name to search forset -xif [[ "$binArch" = sol+([0-9]) ]]then srun=`ps -u $1 -o "args" | grep -v "grep" | grep "$2"`else # aix, linux, etc srun=`ps -u $1 -o "%a" | grep -v "grep" | grep "$2"`fiecho "`date` : User: $1, Process: $2, List=$srun" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.logif [ -n "$srun" ]; then return 0else return 1fi}# turn on tracing for log fileset -x# make sure CANDLEHOME existsif [ ! -d "$CANDLEHOME" ]; then echo "ERROR: CANDLEHOME was not found, exiting..." exitfi# make sure the instance name existsif [ -z "$KGB_INSTANCE_NAME" ]; then echo "ERROR: KGB_INSTANCE_NAME was not found, exiting..." exitfi# truncate log file and modify permissionscat /dev/null > $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.logchmod 666 $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.logecho "`date` : kgbstart.sh called for instance $KGB_INSTANCE_NAME" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log# make sure the notes.ini path exists#KGB_NOTESINIPATH=`echo $KGB_NOTESINIPATH | sed -e "s/notes.ini//g"`#if [ ! -d "$KGB_NOTESINIPATH" ]; then# echo "`date` : KGB_NOTESINIPATH : $KGB_NOTESINIPATH/notes.ini was not found, exiting..." >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log# exit#fi# setup path to the machine architecture# source dynarch.shl in a subshell so it does not modify the environmentbinArch=`( . $CANDLEHOME/bin/dynarch.shl $CANDLEHOME/registry/archdsc.tbl; setBinLibArchs $cArch gb; echo $binArch )`# export as KGB_BINARCH as BSS1_genenv gets confused on binArchKGB_BINARCH=$binArchexport KGB_BINARCH# determine the Lotus Domino base directory#LOTUSBASEDIR=`cat $KGB_NOTESINIPATH/notes.ini | grep -i NotesProgram | awk -F= {'print $2'}`#while true#do# if [ -f $LOTUSBASEDIR/bin/server ]; then# break# else# LOTUSBASEDIR=`dirname $LOTUSBASEDIR`# if [ "$LOTUSBASEDIR" = "/" -o "$LOTUSBASEDIR" = "" ]; then# break# fi# fi#done#if [ ! -f $LOTUSBASEDIR/bin/server ]; then# echo "`date` : Using the NotesProgram keyword in $KGB_NOTESINIPATH/notes.ini to find the Lotus base directory, ${LOTUSBASEDIR} directory was not found, exiting..." >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log# exit#fi# check the Lotus Domino user id was used to start the agentLOTUSOWNER=`ls -l ${KGB_NOTESINIPATH}/notes.ini | awk '{print $3}'`if [ -z "$LOTUSOWNER" ]; then echo "`date` : Could not determine the Domino user id, exiting..." >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log exitfiif [[ "$binArch" = sol+([0-9]) ]]then /usr/xpg4/bin/id -un | grep "^$LOTUSOWNER" >/dev/null 2>&1else id -un | grep "^$LOTUSOWNER" >/dev/null 2>&1fiif [ $? -ne 0 ]; then ROOTUSER=yesfi# setup environement based on architectureif [[ "$binArch" = aix+([0-9]) ]]then PATH=$PATH:$LOTUSBASEDIR/bin:$LOTUSBASEDIR/notes/latest/ibmpow:$LOTUSBASEDIR/notes/latest/ibmpow/res/C export PATH Notes_ExecDirectory=$LOTUSBASEDIR/notes/latest/ibmpow export Notes_ExecDirectory LIBPATH=$LIBPATH:$LOTUSBASEDIR/notes/latest/ibmpow export LIBPATHfiif [[ "$binArch" = sol+([0-9]) ]]then PATH=$PATH:$LOTUSBASEDIR/bin:$LOTUSBASEDIR/notes/latest/sunspa:$LOTUSBASEDIR/notes/latest/sunspa/res/C export PATH Notes_ExecDirectory=$LOTUSBASEDIR/notes/latest/sunspa export Notes_ExecDirectory LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LOTUSBASEDIR/notes/latest/sunspa export LD_LIBRARY_PATHfiif [[ "$binArch" = li+([0-9]) ]]then PATH=$PATH:$LOTUSBASEDIR/bin:$LOTUSBASEDIR/notes/latest/linux:$LOTUSBASEDIR/notes/latest/linux/res/C export PATH Notes_ExecDirectory=$LOTUSBASEDIR/notes/latest/linux export Notes_ExecDirectory LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LOTUSBASEDIR/notes/latest/linux export LD_LIBRARY_PATHfiif [[ "$binArch" = ls+([0-9]) ]]then PATH=$PATH:$LOTUSBASEDIR/bin:$LOTUSBASEDIR/notes/latest/zlinux:$LOTUSBASEDIR/notes/latest/zlinux/res/C export PATH Notes_ExecDirectory=$LOTUSBASEDIR/notes/latest/zlinux export Notes_ExecDirectory LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LOTUSBASEDIR/notes/latest/zlinux export LD_LIBRARY_PATHfi# chk for the required softlinks if rootif [ -n "$ROOTUSER" ]; then # chk to make sure the agent has been configured if [ ! -f $LOTUSBASEDIR/bin/kgbclient -o ! -f $Notes_ExecDirectory/kgbclient ]; then echo "`date` : Adding softlinks for $KGB_INSTANCE_NAME" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log $CANDLEHOME/$binArch/gb/bin/kgbconfig.sh $KGB_INSTANCE_NAME kgbstart >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log fifi# remove the status fileif [ -f $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out ]; then echo "`date` : removing $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log rm -f $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.outfi# chk for Domino Sever shutdown(1) and restart the client# when the Domino server process endsCNT=1MAXCNT=150while truedo # start the Domino agent, switch to the notes user if root cd "$KGB_NOTESINIPATH" if [ -z "$ROOTUSER" ]; then echo "`date` : starting $LOTUSBASEDIR/bin/kgbclient as the $LOTUSOWNER user" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log $LOTUSBASEDIR/bin/kgbclient $KGB_INSTANCE_NAME CR=$? else echo "`date` : Switching to the $LOTUSOWNER user and starting $LOTUSBASEDIR/bin/kgbclient" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log su $LOTUSOWNER -c "$LOTUSBASEDIR/bin/kgbclient $KGB_INSTANCE_NAME" CR=$? fi echo "`date` : kgbclient exited with return code(${CR})" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log # if return code is 31, server is shutting down if [ $CR -eq 31 ]; then # set the status of server and cluster to recycling echo 4 > $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out echo 5 >> $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out echo "`date` : Starting 5 minute timeout for server process: $Notes_ExecDirectory/server" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log while true do # chk if server process is running process_running $LOTUSOWNER $Notes_ExecDirectory/server if [ $? -eq 1 ]; then break fi echo "`date` : timeout count=$CNT maxcount=$MAXCNT" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log CNT=`expr $CNT + 1` echo "`date` : sleeping" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log sleep 2 if [ $CNT -gt $MAXCNT ]; then echo "`date` : timeout waiting for $Notes_ExecDirectory/server process to stop, exiting..." >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log exit fi done CNT=1 # sleep some more to make sure sleep 5 echo "`date` : restarting kgbclient" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log else break fidone# remove the status fileif [ -f $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out ]; then echo "`date` : removing $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.out" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log rm -f $CANDLEHOME/$binArch/gb/bin/kgb_${KGB_INSTANCE_NAME}_status.outfiecho "`date` : exiting" >> $CANDLEHOME/logs/kgbstart_$KGB_INSTANCE_NAME.log
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -