|
| 1 | +homeDir=`dirname $0` |
| 2 | +######## 0) Pre-condition : node agent needs Running ############## |
| 3 | +refargs=`ps -ef|grep java|grep nodeagent|grep -v "grep"` |
| 4 | + |
| 5 | +####### 1) Determine ProfileHome, etc, ########################### |
| 6 | +ProfileHome=`echo $refargs|awk '{print $(NF-3)}'|sed 's_/config__'` |
| 7 | +CellName=`echo $refargs|awk '{print $(NF-2)}'` |
| 8 | +NodeName=`echo $refargs|awk '{print $(NF-1)}'` |
| 9 | +WasHome=`echo $ProfileHome|sed 's_/profiles/.*__'` |
| 10 | +ProfileName=`echo $ProfileHome|awk -F'/' '{print $NF}'` |
| 11 | + |
| 12 | +####### 2) Fix out DM IP ################################ |
| 13 | +DmgrName=`echo $CellName|sed 's/Cell[0-9]*$//'` |
| 14 | +DmgrIP=`cat /etc/hosts|grep "$DmgrName"|grep -v "^#"|head -1|awk '{print $1}'` |
| 15 | + |
| 16 | + |
| 17 | +####### 3) Try to fix out SOAP Port ################### |
| 18 | +XmlFile=`find $ProfileHome/config -name "serverindex.xml"|grep $CellName|grep -v $NodeName|grep Manager` |
| 19 | +tmpno=`cat $XmlFile | grep -n SOAP_CONNECTOR_ADDRESS | awk -F: '{print $1}'`; |
| 20 | +tmpno=`expr $tmpno + 1` |
| 21 | +SoapPort=`cat $XmlFile|sed -n ${tmpno}p| sed 's/.*port="\(.*\)".*/\1/'` |
| 22 | + |
| 23 | +###### 4) DM admin Username and Password ############### |
| 24 | +AdminUser=wasadm; |
| 25 | +AdminPass=****; |
| 26 | + |
| 27 | +while getopts "u:p:n:" opt; do |
| 28 | +case $opt in |
| 29 | + u) AdminUser=$OPTARG;; |
| 30 | + p) AdminPass=$OPTARG;; |
| 31 | + n) SoapPort=$OPTARG;; |
| 32 | + ?) echo "Parameter Error!" |
| 33 | + exit 1;; |
| 34 | +esac |
| 35 | +done |
| 36 | + |
| 37 | +shift $(($OPTIND - 1)) |
| 38 | + |
| 39 | +######## 5) What Servers to Config ##################### |
| 40 | +if [ -z "$*" ]; then |
| 41 | +servers=`ls $ProfileHome/config/cells/$CellName/nodes/$NodeName/servers|grep -v "nodeagent"` |
| 42 | +else |
| 43 | +servers="$*"; |
| 44 | +fi |
| 45 | + |
| 46 | +ServersConfigured="" |
| 47 | +for i in `echo $servers`; do |
| 48 | + grep "TIVOLI" $ProfileHome/config/cells/$CellName/nodes/$NodeName/servers/$i/server.xml>/dev/null 2>&1 |
| 49 | + if [ $? -eq 0 ]; then |
| 50 | + ServersConfigured="$ServersConfigured $i" |
| 51 | + fi |
| 52 | +done |
| 53 | +if [ -n "$ServersConfigured" ]; then |
| 54 | + echo "You choose to configure ["$servers"], But we found that ["$ServersConfigured"] are already configured" |
| 55 | + echo "Are you sure to continue? (yes/no)" |
| 56 | + read reply |
| 57 | + if [ "$reply" = "no" ]; then |
| 58 | + echo "exiting...";exit; |
| 59 | + fi |
| 60 | +fi |
| 61 | + |
| 62 | +ServerName=`echo $servers | sed -e "s/^/$NodeName/" -e "s/ /,$NodeName/g"` |
| 63 | +ServerPath=`echo $servers | sed -e "s#^#cells/$CellName/nodes/$NodeName/servers/#" -e "s_ _,cells/$CellName/nodes/$NodeName/servers/_g"` |
| 64 | + |
| 65 | +######## 6) Generate response file ##################### |
| 66 | +cat ${homeDir}/template/config_dc_template.txt | |
| 67 | + sed -e "s%#ProfileHome#%$ProfileHome%" \ |
| 68 | + -e "s%#DmgrIP#%$DmgrIP%" \ |
| 69 | + -e "s%#AdminUser#%$AdminUser%" \ |
| 70 | + -e "s%#AdminPass#%$AdminPass%" \ |
| 71 | + -e "s%#SoapPort#%$SoapPort%" \ |
| 72 | + -e "s%#ServerName#%$ServerName%" \ |
| 73 | + -e "s%#ProfileName#%$ProfileName%" \ |
| 74 | + -e "s%#WasHome#%$WasHome%" \ |
| 75 | + -e "s%#ServerPath#%$ServerPath%" >${homeDir}/response/config_dc.txt |
| 76 | + |
| 77 | +####### 7) Start to Config ############################# |
| 78 | +OSUser=`echo $refargs|awk '{print $1}'` |
| 79 | +id | grep $OSUser >/dev/null 2>&1 |
| 80 | +if [ $? -ne 0 ]; then |
| 81 | + echo "User not correct" |
| 82 | + exit -1 |
| 83 | +fi |
| 84 | +/TIVOLI/IBM/ITM/bin/itmcmd config -A -p ${homeDir}/response/config_dc.txt yn |
| 85 | + |
| 86 | + |
| 87 | +####### 8) Check if the configuring process correct! ########### |
| 88 | +for i in `echo $servers`; do |
| 89 | + grep "TIVOLI" $ProfileHome/config/cells/$CellName/nodes/$NodeName/servers/$i/server.xml>/dev/null 2>&1 |
| 90 | + if [ $? -eq 0 ] |
| 91 | + then |
| 92 | + echo DC config for server $i Success |
| 93 | + else |
| 94 | + echo DC config for server $i Failed |
| 95 | + fi |
| 96 | +done |
0 commit comments