update_script/main.sh

395 lines
12 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
#删除命令乱码解决
stty erase ^h
#引用其他文件
source function/function.sh
# 定义ANSI颜色转义码
#red='\033[0;31m' #红色
#green='\033[0;32m' #绿色
#yellow='\033[0;33m' #黄色
#NC='\033[0m'
#文字颜色:
red='\033[31m'
green='\033[32m'
yellow='\033[33m'
blue='\033[34m'
purple='\033[35m'
cyan='\033[36m'
white='\033[37m'
NC='\033[0m' # 恢复默认颜色
# 定义函数,用于展示菜单选项
show_menu() {
echo -e "================================"
echo -e "欢迎使用${blue}戒灵更新脚本${NC}"
echo -e "1. ${yellow}游戏服更新${NC}"
echo -e "2. ${yellow}gm更新${NC}"
echo -e "3. ${yellow}登陆服更新${NC}"
echo -e "4. ${yellow}支付服更新${NC}"
echo -e "5. ${yellow}敏感词服更新${NC}"
echo -e "0. ${red}退出${NC}"
}
# 定义函数,用于处理用户输入
handle_input() {
read -p "请输入选项编号: " choice
case $choice in
1)
# 在这里编写选项一的代码
game
;;
2)
echo -e "${yellow}开始更新gm服${NC}"
# 在这里编写选项二的代码
gm
;;
3)
echo -e "${yellow}开始更新登陆服${NC}"
# 在这里编写选项三的代码
login
;;
4)
echo -e "${yellow}开始更新支付服${NC}"
# 在这里编写选项四的代码
pay
;;
5)
echo -e "${yellow}开始更新敏感词服${NC}"
# 在这里编写选项五的代码
mingan
;;
0)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
*)
echo -e "${red}无效的选项,请重新输入${NC}"
handle_input
;;
esac
}
#游戏服更新
game(){
echo -e "================================"
echo -e "开始更新${green}游戏服${NC}"
echo -e "1. ${yellow}打更新包${NC}"
echo -e "2. ${yellow}打热更包${NC}"
echo -e "3. ${yellow}正式服热更${NC}"
echo -e "4. ${yellow}正式服停服更新${NC}"
echo -e "5. ${yellow}测试服热更${NC}"
echo -e "6. ${yellow}测试服停服更新${NC}"
echo -e "0. ${green}返回主菜单${NC}"
echo -e "*. ${red}其他任意键退出程序${NC}"
read -p "请输入选项编号: " choice
case $choice in
1)
echo -e "${yellow}打更新包${NC}"
echo "=============================="
show_file project
read -p "请输入项目地址: " project
show_file package
read -p "请输入包名(不需要带文件后缀): " package
echo -e "开始打包 项目:$project, 包名:$package"
bash update_game.sh $project $package
game
;;
2)
echo -e "${yellow}打热更包${NC}"
echo "=============================="
show_file project
read -p "请输入项目地址: " project
show_file package
read -p "请输入包名(不需要带文件后缀): " package
echo -e "开始打包 项目:$project, 包名:$package"
bash hotfix_game.sh $project $package
game
;;
3)
echo -e "${yellow}正式服热更${NC}"
echo "=============================="
show_file package
read -p "请输入包名(不需要带文件后缀): " package
show_file script/txt
read -p "请输入文件名称(不需要带文件后缀): " channel
echo -e "开始发送 包名:$package, channel$channel"
send_package_update $package ${channel}.txt 0
game
;;
4)
echo -e "${yellow}正式服停服更新${NC}"
echo "=============================="
show_file package
read -p "请输入包名(不需要带文件后缀): " package
show_file script/txt
read -p "请输入文件名称(不需要带文件后缀): " channel
echo -e "开始发送 包名:$package, channel$channel"
send_package_update $package ${channel}.txt 1
game
;;
5)
echo -e "${yellow}测试服热更${NC}"
echo "=============================="
show_file package
read -p "请输入包名(不需要带文件后缀): " package
read -p "请输入游戏服ip: " ip
echo -e "开始发送 包名:$package, ip$ip"
send_package_update $package $ip 0
game
;;
6)
echo -e "${yellow}测试服停服更新${NC}"
echo "=============================="
show_file package
read -p "请输入包名(不需要带文件后缀): " package
read -p "请输入游戏服ip: " ip
echo -e "开始发送 包名:$package, ip$ip"
send_package_update $package $ip 1
game
;;
0)
show_menu
handle_input
;;
*)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
esac
}
#gm更新
gm(){
txt=gm_ip.txt
echo -e "================================"
echo -e "开始更新${green}gm服${NC}"
echo -e "1. ${yellow}打包${NC}"
echo -e "2. ${yellow}单机器更新${NC}"
echo -e "3. ${yellow}批量更新${NC}"
echo -e "4. ${yellow}单机器重启${NC}"
echo -e "5. ${yellow}批量重启${NC}"
echo -e "0. ${green}返回主菜单${NC}"
echo -e "*. ${red}其他任意键退出程序${NC}"
read -p "请输入选项编号: " choice
case $choice in
1)
echo -e "${yellow}打包${NC}"
show_file project
read -p "请输入表所在游戏项目地址: " project
bash update_gm.sh $project
echo -e "gm打包完成"
gm
;;
2)
echo -e "${yellow}单机器更新${NC}"
read -p "请输入游戏服ip: " ip
echo -e "开始更新gm"
gm_send_package $ip
gm
;;
3)
echo -e "${yellow}批量更新${NC}"
echo -e "开始更新gm"
gm_send_package txt
gm
;;
4)
echo -e "${yellow}单机器重启${NC}"
read -p "请输入游戏服ip: " ip
echo -e "开始重启gm"
gm_reboot $ip
gm
;;
5)
echo -e "${yellow}单机器更新${NC}"
read -p "请输入游戏服ip: " ip
echo -e "开始更新gm"
for i in `awk '{print $2}' /data/update/script/txt/$txt`
do
gm_reboot $i
done
gm
;;
0)
show_menu
handle_input
;;
*)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
esac
}
#登陆 ssh $i "sh /data/jieling/gm/gm_restart.sh"
login(){
echo -e "================================"
echo -e "开始更新${green}登陆服${NC}"
echo -e "1. ${yellow}更新登陆服代码${NC}"
echo -e "2. ${yellow}重启登陆服${NC}"
echo -e "0. ${green}返回主菜单${NC}"
echo -e "*. ${red}其他任意键退出程序${NC}"
read -p "请输入选项编号: " choice
case $choice in
1)
echo -e "${yellow}登陆服更新${NC}"
read -p "请输入登陆服ip: " ip
echo -e "开始更新登陆服 ip$ip"
bash update_login.sh $ip
read -r -p "更新完毕是否需要重启Y/N: " input
case $input in
[yY][eE][sS]|[yY])
login_reboot $ip
;;
*)
echo "over..."
exit 0
;;
esac
login
;;
2)
echo -e "${yellow}登陆服重启${NC}"
read -p "请输入登陆服ip: " ip
echo -e "开始重启登陆服 ip$ip"
login_reboot
login
;;
0)
show_menu
handle_input
;;
*)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
esac
}
login_reboot(){
ip=${1}
ssh $ip "bash /usr/local/apache-tomcat-7.0.79/login_reboot.sh"
ssh $ip "ps -ef|grep tomcat"
echo "登陆服重启完毕"
}
#支付
pay(){
echo -e "================================"
echo -e "开始更新${green}支付服${NC}"
echo -e "1. ${yellow}更新支付服代码${NC}"
echo -e "2. ${yellow}重启支付服${NC}"
echo -e "0. ${green}返回主菜单${NC}"
echo -e "*. ${red}其他任意键退出程序${NC}"
read -p "请输入选项编号: " choice
case $choice in
1)
echo -e "${yellow}支付服更新${NC}"
read -p "请输入支付服ip: " ip
echo -e "开始更新支付服 ip$ip"
bash update_delivery.sh $ip
read -r -p "更新完毕是否需要重启Y/N: " input
case $input in
[yY][eE][sS]|[yY])
pay_reboot $ip
;;
*)
echo "over..."
exit 0
;;
esac
pay
;;
2)
echo -e "${yellow}支付服重启${NC}"
read -p "请输入支付服ip: " ip
echo -e "开始重启支付服 ip$ip"
pay_reboot $ip
login
;;
0)
show_menu
handle_input
;;
*)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
esac
}
pay_reboot(){
ip=${1}
ssh $ip "bash /data/jieling/delivery-server/pay_reboot.sh"
ssh $ip "ps -ef|grep delivery"
echo "支付服重启完毕"
}
#敏感词
mingan(){
echo -e "================================"
echo -e "开始更新${green}敏感词服${NC}"
echo -e "1. ${yellow}更新敏感词服代码${NC}"
echo -e "2. ${yellow}重启敏感词服${NC}"
echo -e "0. ${green}返回主菜单${NC}"
echo -e "*. ${red}其他任意键退出程序${NC}"
read -p "请输入选项编号: " choice
case $choice in
1)
echo -e "${yellow}敏感词服更新${NC}"
read -p "请输入敏感词服ip: " ip
echo -e "开始更新敏感词服 ip$ip"
bash update_sensitive.sh $ip
read -r -p "更新完毕是否需要重启Y/N: " input
case $input in
[yY][eE][sS]|[yY])
mingan_reboot $ip
;;
*)
echo "over..."
exit 0
;;
esac
mingan
;;
2)
echo -e "${yellow}敏感词服重启${NC}"
read -p "请输入敏感词服ip: " ip
echo -e "开始重启敏感词服 ip$ip"
mingan_reboot
login
;;
0)
show_menu
handle_input
;;
*)
echo -e "${red}谢谢使用,再见!${NC}"
exit 0
;;
esac
}
mingan_reboot(){
ip=${1}
ssh $ip "bash /data/jieling/sensitiveWordFilter/bin/mingan_reboot.sh"
ssh $ip "ps -ef|grep sensitive"
echo "敏感字服重启完毕"
}
# 主循环,展示菜单并处理用户输入
while true; do
show_menu
handle_input
done