first commit

This commit is contained in:
iProbe 2022-10-18 16:59:37 +08:00
commit ba848e218d
1001 changed files with 152333 additions and 0 deletions

View file

@ -0,0 +1,217 @@
```
#!/bin/bash
## Edit by ZeroC
# 20170908
. ./server
logpath=/root/update
DIRDATE=`date +%Y-%m-%d`
UPDATE=`date +%Y-%m-%d:%H:%M:%S`
## 帮助
Help()
{
if [ $# -eq 1 ];then
baseName=$1
echo -e "\033[31;1mUsge:\t'bash $baseName help' 打印帮助信息\n\t'bash $baseName' 更新应用服务\033[0m\n"
elif [ $# -eq 2 -a $2 == "list" ];then
echo -e "\033[32;1m++++++++ServerName List++++++++\033[0m"
echo -e "\033[31;1m\ta api\n\tb admin\n\tc pc\n\td swoole\n\te users\n\tf transaction\n\tg products\n\th orders\n\ti fullscale\n\tj repayment\n\tk capital\n\tl sysaccount\n\tm bases\n\tn trusteeship\n\to contract\n\tp others\n\tq scan\033[0m\n"
fi
}
## ip列表
IPlist()
{
server=$1
List=$2
echo "$server:"
for ip_l in ${List[@]};do
echo -e "\033[33;1m\t$ip_l\033[0m"
done
}
## rsync推送更新
Rsync()
{
server_c=$1
ip=$2
if [ ! -d $logpath/$DIRDATE/$server_c ];then
mkdir -p $logpath/$DIRDATE/$server_c
fi
echo "+++++++++++++++++++++++++++++++++++++++++" >> $logpath/$DIRDATE/$server_c/$ip
echo $UPDATE >> $logpath/$server_c/$ip
/usr/bin/rsync -avz --exclude-from=/data/script/rsync/exclude --password-file=/data/script/rsync/pass /data/htdocs/v/$server_c/ rsync@$ip::server >> $logpath/$DIRDATE/$server_c/$ip
echo "+++++++++++++++++++++++++++++++++++++++++" >> $logpath/$DIRDATE/$server_c/$ip
echo >> $logpath/$DIRDATE/$server_c/$ip
}
## 重启微服务
Restart()
{
#serverU=`echo $1|sed 's/\b[a-z]/\U&/'`
ip=$2
ssh root@$ip "/bin/bash /data/script/run.sh restart"
}
## 更新模块
UpdateM()
{
serverM=$1
server="\<$1\>"
iparray=$2
## 同一服务的所有ip都更新
if [ $# -eq 2 ];then
## 微服务
if [[ "${micro[@]}" =~ $serverM ]];then
for ip in ${iparray[@]};do
Rsync $serverM $ip
Restart $serverM $ip
sleep 5
done
## swoole
elif [ $serverM == "swoole" ];then
for ip in ${iparray[@]};do
Rsync swoole $ip
Restart swoole $ip
sleep 5
done
## api/admin/pc
elif [ $serverM == "api" -o "admin" -o "pc" ];then
for ip in ${iparray[@]};do
Rsync $serverM $ip
done
fi
# 一个服务只更新其中一个ip
elif [ $# -eq 3 ]; then
## 微服务
if [[ "${micro[@]}" =~ $serverM ]];then
if [[ "${iparray[@]}" =~ $3 ]];then
Rsync $serverM $3
Restart $serverM $3
else
echo -e "\033[31;1mWrong IP!\033[0m"
exit 1
fi
## swoole
elif [ $serverM == "swoole" ];then
if [[ "${swoole[@]}" =~ $3 ]];then
Rsync swoole $3
Restart swoole $3
else
echo -e "\033[31;1mWrong IP!\033[0m"
exit 1
fi
# api/admin/pc
elif [ $serverM == "api" -o "admin" -o "pc" ];then
if [[ "${iparray[@]}" =~ $2 ]];then
Rsync $serverM $3
else
echo -e "\033[31;1mWrong IP!\033[0m"
exit 1
fi
else
echo -e "\033[31;1mWrong Server!\033[0m"
fi
fi
}
## 更新系统
UpdateS()
{
serverS=$1
serverL=$2
read -p "The IP[default all ip]:" addr
if [ -z $addr ];then
echo -e "\033[33;1mUpdate all $serverS\033[0m"
UpdateM $serverS "${serverL[*]}"
else
echo -e "\033[33;1mUpdate one of $serverS: $addr\033[0m"
UpdateM $serverS "${serverL[*]}" $addr
fi
}
## Main
echo -e "\033[33;1mChoose the server you want to update\033[0m"
Help $0 list
read -p "Your choose:" sername
case $sername in
help)
Help $0
;;
a|A|api)
IPlist api "${api[*]}"
UpdateS api "${api[*]}"
;;
b|B|admin)
IPlist admin "${admin[*]}"
UpdateS admin "${admin[*]}"
;;
c|C|pc)
IPlist pc "${pc[*]}"
UpdateS pc "${pc[*]}"
;;
d|D|swoole)
IPlist swoole "${swoole[*]}"
UpdateS swoole "${swoole[*]}"
;;
e|E|users)
IPlist users "${users[*]}"
UpdateS users "${users[*]}"
;;
f|F|transaction)
IPlist transaction "${transaction[*]}"
UpdateS transaction "${transaction[*]}"
;;
g|G|products)
IPlist products "${products[*]}"
UpdateS products "${products[*]}"
;;
h|H|orders)
IPlist orders "${orders[*]}"
UpdateS orders "${orders[*]}"
;;
i|I|fullscale)
IPlist fullscale "${fullscale[*]}"
UpdateS fullscale "${fullscale[*]}"
;;
j|J|repayment)
IPlist repayment "${repayment[*]}"
UpdateS repayment "${repayment[*]}"
;;
k|K|capital)
IPlist capital "${capital[*]}"
UpdateS capital "${capital[*]}"
;;
l|L|sysaccount)
IPlist sysaccount "${sysaccount[*]}"
UpdateS sysaccount "${sysaccount[*]}"
;;
m|M|bases)
IPlist bases "${bases[*]}"
UpdateS bases "${bases[*]}"
;;
n|N|trusteeship)
IPlist trusteeship "${trusteeship[*]}"
UpdateS trusteeship "${trusteeship[*]}"
;;
o|O|contract)
IPlist contract "${contract[*]}"
UpdateS contract "${contract[*]}"
;;
p|P|others)
IPlist others "${others[*]}"
UpdateS others "${others[*]}"
;;
q|Q|scan)
IPlist scan "${scan[*]}"
UpdateS scan "${scan[*]}"
;;
*)
echo -e "\033[31;1mWrong option!\033[0m"
;;
esac
```

View file

@ -0,0 +1,26 @@
```
# 微服务列表
micro=("users" "transaction" "products" "orders" "fullscale" "repayment" "capital" "sysaccount" "bases" "trusteeship" "contract" "others" "scan")
# api ip列表
api=("192.168.6.63" "192.168.6.64")
# admin ip列表
admin=("192.168.6.69" "192.168.6.70")
# pc ip列表
pc=("192.168.6.60" "192.168.6.61" "192.168.6.62")
#各微服务ip列表
users=("192.168.6.73" "192.168.6.74" "192.168.6.106")
transaction=("192.168.6.75" "192.168.6.76" "192.168.6.109")
products=("192.168.6.77" "192.168.6.78")
orders=("192.168.6.81" "192.168.6.82" "192.168.107")
fullscale=("192.168.6.83" "192.168.6.84")
repayment=("192.168.6.85" "192.168.6.86")
capital=("192.168.6.87" "192.168.6.88" "192.168.6.108")
sysaccount=("192.168.6.89" "192.168.6.90")
bases=("192.168.6.91" "192.168.6.92")
trusteeship=("192.168.6.93" "192.168.6.94")
contract=("192.168.6.95" "192.168.6.96")
others=("192.168.6.97" "192.168.6.98")
scan=("192.168.6.99" "192.168.6.100")
# swoole ip列表
swoole=("${users[*]}" "${transaction[*]}" "${products[*]}" "${orders[*]}" "${fullscale[*]}" "${repayment[*]}" "${capital[*]}" "${sysaccount[*]}" "${bases[*]}" "${trusteeship[*]}" "${contract[*]}" "${others[*]}" "${scan[*]}")
```