\#!/bin/bash
\#shwf@workai123
path="/Users/arick/goProject/src/"
rHost="root@39.104.52.206"
buildArr[0]="exit"
buildArr[1]="uaa-api"
buildArr[2]="uaa-srv"
buildArr[3]="payroll-api"
buildArr[4]="payroll-srv"
buildArr[5]="cmbgateway-api"
buildArr[6]="cmbgateway-srv"
buildArr[7]="uaa-api"
echo "编译并上传工具"
for s in "${!buildArr[@]}"
do
eval i=$(echo '${buildArr['"${s}"']}')
echo "${s} :$i"
done
echo " "
echo "例如 :编译 uaa-api uaa-srv 两个"
echo "输入:1 2"
echo "即可! 输入:0 退出 "
echo -n "输入内容:"
read something
doBuild(){
temp=(${1//-/ })
\#拼接命 令
buildStr="GO\_ENABLED=O GOOS=linux GOARCH=amd64 go build -o ./${1} ${path}aicloud/${temp[1]}/${temp[0]}/main.go"
\#执行
cd /sdfsfd
\#eval ${buildStr}
if [ $? ]
then
echo "进来了$?"
return 1
fi
echo "build end"
doRsync="rsync -v ./${1} ${rHost}:/opt/work/hro/backend/bin/uaa-srv"
\#eval ${doRsync}
echo "rsync end"
}
echo "输入内容为: $something"
arr=(${something// / })
str=""
for s in ${arr[@]}
do
\#echo $s -gt 大于
if [ $s -gt 0 ]
then
eval i=$(echo '${buildArr['"${s}"']}')
echo $i
doBuild ${i}
temp="supervisorctl restart $i;"
str="$str $temp"
else
echo "退出..."
fi
done
echo $str
\#shh 链接后重启
\#ssh $rHost "$str"
allDone(){
echo -en '\\a'
afplay /System/Library/Sounds/Funk.aiff
/usr/bin/osascript \<\<-EOF
tell application "System Events"
activate
display dialog "任务 结束"
end tell
EOF
echo -en "\\007"
}
allDone