1. 程式人生 > >Linux 命令選單

Linux 命令選單

#!/bin/bash
#menu.sh
 
menu(){
source ~/.bashrc
echo "================================="
echo "Please enter your choise:"
echo "(0) Kill all java"
echo "(1) Start all tomcat"
echo "(2) Start web"
echo "(3) Start crm"
echo "(4) Restart mysql"
echo "(5) Restart nginx"
echo "(6) Check java...."

echo "(9) Exit Menu"
echo "================================"
read input
if [ $input != "9" -a  $input != "0" -a $input != "1" -a $input != "2" -a $input != "3" -a $input != "4" -a $input != "5" -a $input != "6"  ]
then
  menu
fi
 
case $input in
    0)
    echo Are you sure kill all java ?
    sleep 1
    read -s -n1 -p "Are you sure?(y/n)?:.... "
    if [ $REPLY == "y" ]
    then  
      echo kill all java ===OK==
      killall java

    fi
    menu;;
    1)
    echo Are you sure start all tomcat?
    sleep 1
    read -s -n1 -p "Are you sure(y/n)? ... "
    if [ $REPLY == "y" ]
    then
        echo start all tomcat ==OK===
        /data/web/zxweb/apache-tomcat-7.0.75/bin/startup.sh
        sleep 5
        /data/web/crm/tomcat/apache-tomcat-7.0.82/bin/startup.sh
        
        
    fi
    menu;;
    2)
    echo Start web
    sleep 1
    read -s -n1 -p "Are you sure(y/n)? ... "
    if [ $REPLY == "y" ]
    then
        echo start web  ==OK===
        /data/web/zxweb/apache-tomcat-7.0.75/bin/startup.sh
    fi
    menu;;
    3)
    echo Start crm
    sleep 1
    read -s -n1 -p "Are you sure(y/n)? ... "
    if [ $REPLY == "y" ]
    then
        echo start crm ==OK===
        /data/web/crm/tomcat/apache-tomcat-7.0.82/bin/startup.sh
    fi
    menu;;
    4)
    echo Restart mysql
    sleep 1
     read -s -n1 -p "Are you sure(y/n)? ... "
    if [ $REPLY == "y" ]
    then
        echo start mysql ==OK===
        systemctl restart mysqld.service
    fi
    menu;;
    5)
    echo restart nginx
    sleep 1
    read -s -n1 -p "Are you sure(y/n)? ... "
    if [ $REPLY == "y" ]
    then
        echo start nginx ==OK===
        systemctl restart nginx
    fi
    menu;;
    6)
    echo check java .......
    sleep 1
    ps aux|grep java

    menu;;
    9)
    exit;;
esac
}
menu