Shell:脚本执行web虚拟机内的系统启停

通过“vmrun -T server -h https://IP:端口/sdk -u 用户名 -p 密码 list”查看:如图1

image(图1),找出规则~定义变量!

#!/bin/bash

####Server 定义变量
VM_RUN='vmrun -T server -h https://IP:端口/sdk -u 用户名 -p 密码'
TD='Win2000_TD/Win2000_TD.vmx'
BREW='WinXP_Brew/WinXP.vmx'
MTK='WinXP_MTK_xmw/WinXP.vmx'
PPC='WinXP_PPC/WinXP.vmx'
S60='WinXP_S60/WinXP.vmx'
SP='WinXP_SP/WinXP.vmx'
QA='WinXP_QA/WinXP.vmx'
VM='[BuilderVM]'
ANDROID='WinXP_Android/WinXP.vmx'
#progress bar 可有可恶的部分~装饰品
progress(){
i=0
while [ $i -lt 20 ]
do
       ((i++))
       echo -ne "=>\033[s"
       echo -ne "\033[40;50"$((i*5*100/100))%"\033[u\033[1D"
   usleep 50000
done
echo
}

#judge Server key
judge(){
case $SERVER in
BREW|brew)
        SERVER=`echo $BREW` ;;
SP|sp)
        SERVER=`echo $SP`  ;;
QA|qa)
        SERVER=`echo $QA` ;;
MTK|mtk)
        SERVER=`echo $MTK` ;;
PPC|ppc)
        SERVER=`echo $PPC` ;;
S60|s60)
        SERVER=`echo $S60` ;;
TD|td)
        SERVER=`echo $TD` ;;
ANDROID|android)
        SERVER=`echo $ANDROID`;;
exit|EXIT)
        exit ;;
*)
#echo "Please Input then name of Service and Status: "
exit
;;
esac
}

#Server status
funcstatus(){
        ps_ef=`ps -ef |grep $1|grep -v grep |wc -l`
        if [ ${ps_ef} == 0 ]
        then
        status='Stop   …'
        else
        status='Running…'
        fi
}

clear
echo ""
echo "  ************Execute Scripts Format************"
echo "   SERVICE SPACE STATUS                         "
echo "               Such As:  brew stop | BREW STOP"
echo "  **********************************************"
echo "          Service          Status: start/stop  "
funcstatus $BREW
echo "          BREW| brew         -Status: $status"
funcstatus $SP
echo "          SP  | sp           -Status: $status"
funcstatus $QA
echo "          QA  | qa           -Status: $status"
funcstatus $PPC
echo "          PPC | ppc          -Status: $status"
funcstatus $S60
echo "          S60 | s60          -Status: $status"
funcstatus $TD
echo "          TD  | td           -Status: $status"
funcstatus $MTK
echo "          MTK | mtk          -Status: $status"
funcstatus $ANDROID
echo "          ANDROID | android       -Status: $status"

echo "  **********************************************"
echo "          Quit or Any key                       "

echo " "
echo "  Service space status"
echo "  Such As:brew stop|BREW stop"
echo -n "       "&& read SERVER VM_Status
judge
$VM_RUN $VM_Status "$VM $SERVER"
echo -n "       "&&progress

- THE END -
版权声明:
转载原创文章请注明,文章出处:http://kinggoo.com
原文地址:http://kinggoo.com/chengxu-shell-vmrunexeute.htm
发表评论?

4 条评论。

  1. 每天看你多一点,生活才会更美好!

  2. 看不懂- -以后有时间慢慢学~

    • 都要时间去积累的!由于我现在邮件通知取消了,只能自己上后台来看!
      等哪天我把友链和邮件还有其他地方都好好弄弄!现在工作换职务,有点繁忙~你那博客不错啊~我以后得推荐推荐

发表评论