#! /usr/bin/ksh
### wasmenu.sh
###





xhost=`hostname`
cellname=${xhost}Network
nodename=${xhost}
PATH=$PATH:/opt/WebSphere/AppServer/bin:/opt/mqm/bin

xwhoami=`whoami`
if [  "$xwhoami" != "root" ]
then
    echo " "
    echo "You must be root to execute this program"
    echo "exiting..."
    exit 1
fi


clear

while [ ! "$answer" = "e" ]  
do
    echo "\n             Company Configuration Scripts                                 "
    echo "                                                                            "
    echo "    CREATE                                LIST                              " 
    echo "    1. Company Home                        a. Company Home                    "
    echo "    2. Cluster                            b. Clusters                       " 
    echo "    3. JDBC Providers                     c. JDBC Providers                 "  
    echo "    4. Data Sources                       d. Data Sources                   "
    echo "    5. MQ QCFs                            e. MQ QCFs                        "
    echo "    6. MQ Queues                          f. MQ Queues                      "
    echo "    7. JVM                                g. JVM                            "
    echo "    8. Listener ports                     h. Listener Ports                 "
    echo "    9. Company Buyer 4.0                   i. Applications                   "
    echo "                                                                            "
    echo "    GENERATE SCRIPT                       REMOVE                            " 
    echo "    A. Data Sources                       AA. Cluster                       "
    echo "    B. JDBC Provider                                                        "
    echo "    C. JVM                                                                  "
    echo "    D. MQ Queues                                                            "
    echo "    E. Listener Ports                                                       "
    echo "                                                                            "
    echo "    REPORTS                                                                 " 
    echo "    aa. Summary                                                              "
    echo "    bb. Running Applications                                                 "
    echo "    cc. Servers                                                              "
    echo "                                                                            "
    echo "    0. Exit                                                                 "
    echo "                                                                            "
    echo "    Enter choice: \c                                                        "
    read answer

    echo "\n\n"
    case $answer in
        1 ) sh ./set_directory.sh 
            ;;
        2 ) echo "Enter clustername: \c"
            read clustername
            echo "Enter server prefix: \c"
            read serverprefix
            echo "Enter nodes (node1 node2 node3 ...): \c"
            read nodes
            if [ "nodes" = "" ]
            then
                 nodes=${xhost}
            fi   
            echo "wsadmin.sh -username was -password notiv@ -f createcluster.jacl $clustername "$nodes" $serverprefix 1 1"
            wsadmin.sh -username was -password notiv@ -f createcluster.jacl $clustername "$nodes" $serverprefix 1 1          
            ;;
        3 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f set_listener_ports.jacl $cellname $nodename $servername" 
            wsadmin.sh -username was -password notiv@ -f set_JDBCProvider.jacl $cellname $nodename $servername
            ;;
        4 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "Enter Authentication Alias prefix (${nodename}Manager): \c"
            read authmgr
            if [ "$authmgr" = "" ]
            then
                 echo "Setting Authentication Alias prefix to ${nodename}Manager"
                 authmgr=${nodename}Manager
            fi   
            echo "Enter clustername: \c"
            read clustername
            echo "wsadmin.sh -username was -password notiv@ -f set_DataSources.jacl $cellname $nodename $servername $authmgr $clustername"
            wsadmin.sh -username was -password notiv@ -f set_DataSources.jacl $cellname $nodename $servername $authmgr $clustername
            ;;
        5 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f set_MQ_QCF.jacl $cellname $nodename $servername "
            wsadmin.sh -username was -password notiv@ -f set_MQ_QCF.jacl $cellname $nodename $servername 
            ;;
        6 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f set_MQ_Queues.jacl $cellname $nodename $servername "
            wsadmin.sh -username was -password notiv@ -f set_MQ_Queues.jacl $cellname $nodename $servername 
            ;;
        7 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "Enter classpath: \c"
            read classpath
            echo "wsadmin.sh -username was -password notiv@ -f set_JVM.jacl $cellname $nodename $servername $classpath "
            wsadmin.sh -username was -password notiv@ -f set_JVM.jacl $cellname $nodename $servername $classpath
            ;;
        8 ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f listener_ports.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f set_listener_ports.jacl $cellname $nodename $servername
            ;;
        a ) echo "Enter company home directory: \c"
            read xhome
            if [ ! "$xhome" = "" ]
            then
                cd $xhome 
                ls -lR | more
            fi   
            ;;
        b ) echo "wsadmin.sh -username was -password notiv@ -f list_clusters.jacl"
            wsadmin.sh -username was -password notiv@ -f list_clusters.jacl 
            ;;
        c ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_JDBCProvider.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_JDBCProvider.jacl $cellname $nodename $servername | more
            ;;
        d ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_DS.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_DS.jacl $cellname $nodename $servername  | more
            ;;
        e ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_QCF.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_QCF.jacl $cellname $nodename $servername  | more
            ;;
        f ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_queues.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_queues.jacl $cellname $nodename $servername  | more
            ;;
        g ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_JVM.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_JVM.jacl $cellname $nodename $servername  | more
            ;;
        h ) echo "Enter cellname ($cellname): \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename ($nodename): \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password notiv@ -f list_listener_ports.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password notiv@ -f list_listener_ports.jacl $cellname $nodename $servername | more
            ;;
        i ) echo "wsadmin.sh -username was -password notiv@ -f listapps.jacl"
            wsadmin.sh -username was -password notiv@ -f listapps.jacl | more
            ;;
        A ) get_DS.sh
            ;;
        B ) get_JDBCProvider.sh
            ;;
        C ) get_JVM.sh
            ;;
        D ) get_MQ_Queues.sh
            ;;
        E ) get_listener_ports.sh
            ;;
        AA ) echo "Enter cluster name: \c"
             read clustername
             echo "wsadmin.sh -username was -password notiv@ -f removecluster.jacl $clustername"
             wsadmin.sh -username was -password notiv@ -f removecluster.jacl $clustername
             ;;
        aa ) echo "wsadmin.sh -username was -password notiv@ -f displayconfig.jacl all"
             wsadmin.sh -username was -password notiv@ -f displayconfig.jacl all
             ;;
        bb ) echo "wsadmin.sh -username was -password notiv@ -f listrunningapps.jacl"
             wsadmin.sh -username was -password notiv@ -f listrunningapps.jacl
             ;;
        cc ) echo "wsadmin.sh -username was -password notiv@ -f servers.jacl"
             wsadmin.sh -username was -password notiv@ -f list_servers.jacl
             ;;
        0 ) echo "exiting..."
            exit 1 ;;
    esac
done


#        1 )