#!/bin/sh usage() { echo "Usage: $0 node1 no_servers1 [node2 no_servers2 node3 no_servers3 node4 no_servers4]" echo "Creates offline configuration with 4 nodes and required number of instances" echo "Only one cluster with that many server instances will be created" echo "The script assumes that we have a DAS and the DAS supports cluster profile" echo echo "Example Usage: ./offline node1 10 node2 6 node3 4 node4 8" } env() { # note: yes, we are testing sailfin, but sailfin build is weird and creates output in glassfish folder! AS_INSTALL=/export/eric/sf/build/src/publish/glassfish ASADMIN=${AS_INSTALL}/bin/asadmin ASADMIN_OPTS="--user admin --passwordfile pass --port 4848 --host localhost --secure=false" cid=cluster1 } checkArgs() { if [ $# -lt 8 ]; then usage exit 127 fi i=1; while [ $# -ge 2 ]; do eval node_${i}=$1 eval servers_${i}=$2 shift shift i=`expr $i + 1` done if [ ! -f pass ]; then echo "ACTION: Create a passwordfile named pass with AS_ADMIN_PASSWORD in it" fi } askUser() { echo "Offline configuration will be created with:" echo "node ${node_1} : ${servers_1} servers in cluster cluster1" echo "node ${node_2} : ${servers_2} servers in cluster cluster1" echo "node ${node_3} : ${servers_3} servers in cluster cluster1" echo "node ${node_4} : ${servers_4} servers in cluster cluster1" echo "continue (y/n)?" read ans if [ $ans != "y" ]; then echo "Exiting without any changes" exit 0 fi echo "making changes to the domain" } createNodes() { ${ASADMIN} create-cluster ${ASADMIN_OPTS} ${cid} nodes="$1 $2 $3 $4" for node in $nodes do ${ASADMIN} create-node-agent-config ${ASADMIN_OPTS} ${node} done } createServers() { node=$1 number_of_servers=$2 i=1 while [ $i -le $number_of_servers ]; do ${ASADMIN} create-instance --nodeagent ${node} --cluster ${cid} server-$node-$i i=`expr $i + 1` done } run() { ${ASADMIN} start-domain domain1 createNodes ${node_1} ${node_2} ${node_3} ${node_4} ${servers_1} ${servers_2} ${servers_3} ${servers_4} i=1 createServers ${node_1} ${servers_1} createServers ${node_2} ${servers_2} createServers ${node_3} ${servers_3} createServers ${node_4} ${servers_4} } checkArgs $* env askUser run