#! /usr/bin/ksh
### 
### wasmenu.sh
###
### Front-end to jacl Scripts
###
### Note that get_* scripts are not part of menu
### but can be found in "get" subdirectory




#cd /usr/local/bin



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

clear

while [ ! "$answer" = "0" ]  
do
    echo "\n             acme Configuration Scripts                                 "
    echo "                                                                            "
    echo "    CREATE                                LIST                              " 
    echo "    1. acme Home Directory              a. acme Home                    "
    echo "    2. Cluster                            b. Clusters                       " 
    echo "    3. JAAS Authentication                c. JAAS Authentication            " 
    echo "    4. JDBC Providers                     d. JDBC Providers                 "  
    echo "    5. Data Sources                       e. Data Sources                   "
    echo "    6. MQ QCFs                            f. MQ QCFs                        "
    echo "    7. MQ Queues                          g. MQ Queues                      "
    echo "    8. JVM                                h. JVM                            "
    echo "    9. Listener ports                     i. Listener Ports                 "
    echo "                                                                            "
    echo "    REMOVE                                REPORTS" 
    echo "    A. Cluster                            aa. Summary"
    echo "    B. JDBC Provider                      bb. Running Apps"
    echo "    C. Data Source                        cc. Servers"
    echo "    D. MQ QCFs                       "
    echo "    E. Listener Ports                     DUMPS "
    echo "    F. JAAS Authentication                it. Invoke Thread Dump" 
    echo "                                                 " 
    echo "    SERVERS                                      " 
    echo "    st. Start "
    echo "    sp. Stop "

    echo "                                                              " 
    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 acme@ -f createcluster.jacl $clustername "$nodes" $serverprefix 1 1"
            wsadmin.sh -username was -password acme@ -f createcluster.jacl $clustername "$nodes" $serverprefix 1 1          
            ;;
        3 ) echo "Note:  Edit set_JAASAuthData.jacl by hand and insert"
            echo "valid login/passwords before running this command."
            echo "Continue? (Y/n): \c" 
            read ans
            if [ "$ans" = "n" ]
            then
                 continue
            fi   
            echo "wsadmin.sh -username was -password acme@ -f set_JAASAuthData.jacl"
            wsadmin.sh -username was -password acme@ -f set_JAASAuthData.jacl 
            ;;
        4 ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f set_JDBCProvider.jacl $cellname $nodename $servername " 
            wsadmin.sh -username was -password acme@ -f set_JDBCProvider.jacl $cellname $nodename $servername 
            ;;
        5 ) echo "Note:  You need to configure authDataAlias by hand in set_DS.jacl"
            echo "before running this option" 
            echo "Continue? (Y/n): \c" 
            read ans
            if [ "$ans" = "n" ]
            then
                 continue
            fi   
            echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter 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 acme@ -f set_DS.jacl $cellname $nodename $servername $clustername"
            wsadmin.sh -username was -password acme@ -f set_DS.jacl $cellname $nodename $servername $clustername
            ;;
        6 ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f set_MQ_QCF.jacl $cellname $nodename $servername "
            wsadmin.sh -username was -password acme@ -f set_MQ_QCF.jacl $cellname $nodename $servername 
            ;;
        7 ) echo "Note:  Review settings in set_MQ_Queues.jacl "
            echo "before running this option"
            echo "Continue? (Y/n): \c"
            read ans
            if [ "$ans" = "n" ]
            then
                 continue
            fi
            echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f set_MQ_Queues.jacl $cellname $nodename $servername "
            wsadmin.sh -username was -password acme@ -f set_MQ_Queues.jacl $cellname $nodename $servername 
            ;;
        8 ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter 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 acme@ -f set_JVM.jacl $cellname $nodename $servername $classpath "
            wsadmin.sh -username was -password acme@ -f set_JVM.jacl $cellname $nodename $servername $classpath
            ;;
        9 ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f set_listener_ports.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f set_listener_ports.jacl $cellname $nodename $servername
            ;;
        it ) echo " "
            echo "Enter server name: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f dump_threads.jacl $servername "
            wsadmin.sh -username was -password acme@ -f dump_threads.jacl $servername 
            ;;
        st ) echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f startServer.jacl $nodename $servername "
            wsadmin.sh -username was -password acme@ -f startServer.jacl $nodename $servername 
            ;;
        sp ) echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f stopServer.jacl $nodename $servername "
            wsadmin.sh -username was -password acme@ -f stopServer.jacl $nodename $servername 
            ;;
        a ) echo "Enter acmea home directory: \c"
            read xhome
            if [ ! "$xhome" = "" ]
            then
                cd $xhome 
                ls -lR | more
            fi   
            ;;
        b ) echo "wsadmin.sh -username was -password acme@ -f list_clusters.jacl"
            wsadmin.sh -username was -password acme@ -f list_clusters.jacl 
            ;;
        c ) echo "wsadmin.sh -username was -password acme@ -f list_JAASAuthData.jacl"
            wsadmin.sh -username was -password acme@ -f list_JAASAuthData.jacl
            ;;
        d ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_JDBCProvider.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_JDBCProvider.jacl $cellname $nodename $servername | more
            ;;
        e ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_DS.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_DS.jacl $cellname $nodename $servername  | more
            ;;
        f ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_QCF.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_QCF.jacl $cellname $nodename $servername  
            ;;
        g ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_queues.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_queues.jacl $cellname $nodename $servername  | more
            ;;
        h ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_JVM.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_JVM.jacl $cellname $nodename $servername  | more
            ;;
        i ) echo "Enter cellname: \c"
            read cellname
            if [ "$cellname" = "" ]
            then
                 cellname=${xhost}Network
            fi   
            echo "Enter nodename: \c"
            read nodename
            if [ "$nodename" = "" ]
            then
                 nodename=${xhost}
            fi   
            echo "Enter servername: \c"
            read servername
            echo "wsadmin.sh -username was -password acme@ -f list_listener_ports.jacl $cellname $nodename $servername"
            wsadmin.sh -username was -password acme@ -f list_listener_ports.jacl $cellname $nodename $servername | more
            ;;
        j ) echo "wsadmin.sh -username was -password acme@ -f listapps.jacl"
            wsadmin.sh -username was -password acme@ -f listapps.jacl | more
            ;;
        A ) echo "Enter cluster name: \c"
             read clustername
             echo "wsadmin.sh -username was -password acme@ -f removecluster.jacl $clustername"
             wsadmin.sh -username was -password acme@ -f removecluster.jacl $clustername
             ;;
        B ) echo "Enter cellname: \c"
             read cellname
             if [ "$cellname" = "" ]
             then
                 cellname=${xhost}Network
             fi
             echo "Enter nodename: \c"
             read nodename
             if [ "$nodename" = "" ]
             then
                 nodename=${xhost}
             fi
             echo "Enter servername: \c"
             read servername
             echo "Enter JDBC Provider Name: \c"
             read JDBCProvider
             echo "wsadmin.sh -username was -password acme@ -f remove_JDBCProvider.jacl $cellname $nodename $servername \"$JDBCProvider\""
             wsadmin.sh -username was -password acme@ -f remove_JDBCProvider.jacl $cellname $nodename $servername "$JDBCProvider"
             ;;
        C ) echo "Enter cellname: \c"
             read cellname
             if [ "$cellname" = "" ]
             then
                 cellname=${xhost}Network
             fi
             echo "Enter nodename: \c"
             read nodename
             if [ "$nodename" = "" ]
             then
                 nodename=${xhost}
             fi
             echo "Enter servername: \c"
             read servername
             echo "Enter Data Source Name: \c"
             read DS
             echo "wsadmin.sh -username was -password acme@ -f remove_DS.jacl $cellname $nodename $servername \"$DS\""
             wsadmin.sh -username was -password acme@ -f remove_DS.jacl $cellname $nodename $servername "$DS"
             ;;
        D ) echo "Enter cellname: \c"
             read cellname
             if [ "$cellname" = "" ]
             then
                 cellname=${xhost}Network
             fi
             echo "Enter nodename: \c"
             read nodename
             if [ "$nodename" = "" ]
             then
                 nodename=${xhost}
             fi
             echo "Enter servername: \c"
             read servername
             echo "Enter Queue Connection Factory Name: \c"
             read QCF
             echo "wsadmin.sh -username was -password acme@ -f remove_QCF.jacl $cellname $nodename $servername \"$QCF\""
             wsadmin.sh -username was -password acme@ -f remove_QCF.jacl $cellname $nodename $servername "$QCF"
             ;;
        E ) echo "Enter cellname: \c"
             read cellname
             if [ "$cellname" = "" ]
             then
                 cellname=${xhost}Network
             fi
             echo "Enter nodename: \c"
             read nodename
             if [ "$nodename" = "" ]
             then
                 nodename=${xhost}
             fi
             echo "Enter servername: \c"
             read servername
             echo "Enter Queue Connection Factory Name: \c"
             read QCF
             echo "wsadmin.sh -username was -password acme@ -f remove_listener_ports.jacl $cellname $nodename $servername \"$QCF\""
             wsadmin.sh -username was -password acme@ -f remove_listener_ports.jacl $cellname $nodename $servername "$QCF"
             ;;
        aa ) echo "wsadmin.sh -username was -password acme@ -f displayconfig.jacl all"
             wsadmin.sh -username was -password acme@ -f displayconfig.jacl all
             ;;
        aa ) echo "wsadmin.sh -username was -password acme@ -f displayconfig.jacl all"
             wsadmin.sh -username was -password acme@ -f displayconfig.jacl all
             ;;
        aa ) echo "wsadmin.sh -username was -password acme@ -f displayconfig.jacl all"
             wsadmin.sh -username was -password acme@ -f displayconfig.jacl all
             ;;
        bb ) echo "wsadmin.sh -username was -password acme@ -f listrunningapps.jacl"
             wsadmin.sh -username was -password acme@ -f listrunningapps.jacl
             ;;
        cc ) echo "wsadmin.sh -username was -password acme@ -f servers.jacl"
             wsadmin.sh -username was -password acme@ -f list_servers.jacl
             ;;
        0 ) echo "exiting..."
            exit 1 ;;
    esac
done