提交 51632e4d authored 作者: Andy's avatar Andy

23

上级 b74cfebd
#!/bin/bash
###################################################
# 安装路径
Install_Dir="/home/deploy/indiaplat"
# 平台名
GamePlatName=0100_IndiaPlat_Dev
# 分支
PlatSvr_Ranch=0100_IndiaPlat_Dev
PlatWeb_Ranch=0100_IndiaPlat_Dev
GameSvr_Ranch=0100_IndiaPlat_Dev
GameWeb_Ranch=0100_IndiaPlat_Dev
# git 地址
Git_PlatAddr=git.wkwork.xyz:LaunchDeploy
# git 路径
Git_ScriptAddr=git.wkwork.xyz/LaunchDeploy
###################################################
# 脚本地址前缀
Fun_Script_Url_Path=http://oauth2:QFF_7BNyjHsq_Zvfsfut@$Git_ScriptAddr/install/raw/master
PlatSvr_Repo_Url="git@$Git_PlatAddr/wk_gameplat_svr.git"
PlatSvr_Base_Dir="./platsvr"
PlatSvr_Branches=(
$PlatSvr_Ranch
)
PlatWeb_Repo_Url="git@$Git_PlatAddr/wk_gameplat_web.git"
PlatWeb_Base_Dir="./platweb"
PlatWeb_Branches=(
$PlatWeb_Ranch
)
GameSvr_Repo_Url="git@$Git_PlatAddr/wk_bdgame_svr.git"
GameSvr_Base_Dir="./bdgamesvr"
GameSvr_Branches=(
$GameSvr_Ranch
)
GameWeb_Repo_Url="git@$Git_PlatAddr/wk_bdgame_web.git"
GameWeb_Base_Dir="./bdgameweb"
GameWeb_Branches=(
$GameWeb_Ranch
)
if [ ! -d "$Install_Dir" ]; then
mkdir -p "$Install_Dir"
fi
cd $Install_Dir
echo_content() {
local tmp_color="$1" # 颜色
local tmp_text="$2" # 文本
local tmp_opt="$3" # 第三个参数用于传 -n
local tmp_echo_type="echo -e"
[ "$tmp_opt" = "-n" ] && tmp_echo_type="echo -en"
case "$tmp_color" in
"red") $tmp_echo_type "\033[31m${tmp_text}\033[0m" ;;
"green") $tmp_echo_type "\033[32m${tmp_text}\033[0m" ;;
"yellow") $tmp_echo_type "\033[33m${tmp_text}\033[0m" ;;
"blue") $tmp_echo_type "\033[34m${tmp_text}\033[0m" ;;
"purple") $tmp_echo_type "\033[35m${tmp_text}\033[0m" ;;
"skyBlue") $tmp_echo_type "\033[36m${tmp_text}\033[0m" ;;
"white") $tmp_echo_type "\033[37m${tmp_text}\033[0m" ;;
esac
}
check_install_deps() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_deps.sh) check_install_deps
bash <(curl -sSL $Fun_Script_Url_Path/fun_deps.sh) check_install_docker
bash <(curl -sSL $Fun_Script_Url_Path/fun_deps.sh) check_install_pm2
}
check_gitaccount() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_git.sh) check_gitaccount
}
fetch_git_platsvr() {
echo $Fun_Script_Url_Path
echo $PlatSvr_Repo_Url
bash <(curl -sSL $Fun_Script_Url_Path/fun_git.sh) fetch_git $PlatSvr_Repo_Url $PlatSvr_Base_Dir $PlatSvr_Branches
}
fetch_git_platweb() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_git.sh) fetch_git $PlatWeb_Repo_Url $PlatWeb_Base_Dir $PlatWeb_Branches
}
fetch_git_gamesvr() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_git.sh) fetch_git $GameSvr_Repo_Url $GameSvr_Base_Dir $GameSvr_Branches
}
fetch_git_gameweb() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_git.sh) fetch_git $GameWeb_Repo_Url $GameWeb_Base_Dir $GameWeb_Branches
}
linux_docker() {
bash <(curl -sSL $Fun_Script_Url_Path/fun_docker.sh) linux_docker
}
run_platsvr_docker() {
local current_dir=$(pwd)
cd $PlatSvr_Base_Dir/$PlatSvr_Ranch/docker-base || exit
make up
cd $current_dir
cd $PlatSvr_Base_Dir/$PlatSvr_Ranch/docker-proxy || exit
make up
cd $current_dir
}
run_gamesvr_docker() {
local current_dir=$(pwd)
cd $GameSvr_Base_Dir/$GameSvr_Ranch/docker-game || exit
make up
cd $current_dir
cd $GameSvr_Base_Dir/$GameSvr_Ranch/docker-proxy || exit
make up
cd $current_dir
}
run_service() {
local current_dir=$(pwd)
cd $PlatSvr_Base_Dir/$GameSvr_Ranch/server || exit
make export_env
make start
cd $current_dir
}
# ------------------ 数组定义菜单项 ------------------
Memu_Items=(
"测试 Git 账户"
"获取 Plat Svr"
"获取 Plat Web"
"获取 Game Svr"
"获取 Game Web"
"运行 Plat Docker"
"运行 Game Docker"
"运行 Server"
"Docker管理"
"结束"
)
# 每个编号对应一个函数(index 对齐 MENU_ITEMS)
Mennu_Actions=(
"check_gitaccount"
"fetch_git_platsvr"
"fetch_git_platweb"
"fetch_git_gamesvr"
"fetch_git_gameweb"
"run_platsvr_docker"
"run_gamesvr_docker"
"run_service"
"linux_docker"
"exit 0"
)
main() {
# ------------------ 主循环 ------------------
while true; do
clear
echo_content "skyBlue" "============================"
echo_content "red" " 安装游戏平台($GamePlatName) "
echo_content "skyBlue" "============================"
for i in "${!Memu_Items[@]}"; do
# printf " %2d) %s\n" "$((i + 1))" "${Memu_Items[$i]}"
# echo_content "skyBlue" " $((i + 1))) ${Memu_Items[$i]}"
echo_content "white" " $((i + 1))) " -n
echo_content "green" "${Memu_Items[$i]}"
done
echo_content "skyBlue" "============================"
echo_content "skyBlue" "请选择操作: " -n
read -r choice
# 转为下标(减 1)
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#Memu_Items[@]}" ]; then
index=$((choice - 1))
echo_content "skyBlue" ">> 执行: ${Memu_Items[$index]}"
eval "${Mennu_Actions[$index]}"
else
echo_content "skyBlue" "无效选择。"
fi
echo_content "yellow" "按任意键继续..." -n
read -n 1 -s -r
echo # 输入后换行(可选)
done
}
# ======= 安装默认工具 =======
check_install_deps
# ======= 启动程序 =======
main
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论