重构代码, 将一键脚本封装为main函数
This commit is contained in:
parent
4b4e15a7fc
commit
4eb55e029f
134
install.sh
134
install.sh
@ -1,10 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录
|
||||
source "${script_dir}/utils/base.sh"
|
||||
|
||||
|
||||
install(){
|
||||
local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录
|
||||
source "${script_dir}/utils/base.sh"
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
install_package curl
|
||||
fi
|
||||
@ -30,65 +29,72 @@ install(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 显示菜单
|
||||
echo "请选择一个操作:"
|
||||
echo "1. 一键部署"
|
||||
echo "2. 生成配置 / 重置配置"
|
||||
echo "3. 查看分享链接"
|
||||
echo "4. 启动容器"
|
||||
echo "5. 停止容器"
|
||||
echo "6. 更新镜像"
|
||||
echo "7. 修改域名"
|
||||
echo "8. 修改端口"
|
||||
main(){
|
||||
local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录
|
||||
source "${script_dir}/utils/base.sh"
|
||||
|
||||
# 读取用户选择
|
||||
read -p "输入您的选择: " choice
|
||||
# 显示菜单
|
||||
echo "请选择一个操作:"
|
||||
echo "1. 一键部署"
|
||||
echo "2. 生成配置 / 重置配置"
|
||||
echo "3. 查看分享链接"
|
||||
echo "4. 启动容器"
|
||||
echo "5. 停止容器"
|
||||
echo "6. 更新镜像"
|
||||
echo "7. 修改域名"
|
||||
echo "8. 修改端口"
|
||||
|
||||
# 根据用户选择执行相应的操作
|
||||
case $choice in
|
||||
1)
|
||||
# 一键部署
|
||||
install
|
||||
bash ./bin/create_config.sh
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
2)
|
||||
# 生成配置
|
||||
bash ./bin/create_config.sh
|
||||
;;
|
||||
3)
|
||||
# 查看分享链接
|
||||
check_config_file
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
4)
|
||||
# 启动容器
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
5)
|
||||
# 停止容器
|
||||
echo "正在停止容器.."
|
||||
docker-compose -f ./docker-compose.yml down
|
||||
;;
|
||||
6)
|
||||
# 更新镜像
|
||||
bash ./bin/update_docker_images.sh
|
||||
;;
|
||||
7)
|
||||
# 修改域名
|
||||
check_config_file
|
||||
bash ./bin/update_domain.sh
|
||||
restart_docker
|
||||
;;
|
||||
8)
|
||||
# 修改端口
|
||||
check_config_file
|
||||
bash ./bin/update_port.sh
|
||||
restart_docker
|
||||
;;
|
||||
*)
|
||||
echo "无效的选择, 请重新选择."
|
||||
;;
|
||||
esac
|
||||
# 读取用户选择
|
||||
read -p "输入您的选择: " choice
|
||||
|
||||
# 根据用户选择执行相应的操作
|
||||
case $choice in
|
||||
1)
|
||||
# 一键部署
|
||||
install
|
||||
bash ./bin/create_config.sh
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
2)
|
||||
# 生成配置
|
||||
bash ./bin/create_config.sh
|
||||
;;
|
||||
3)
|
||||
# 查看分享链接
|
||||
check_config_file
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
4)
|
||||
# 启动容器
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
;;
|
||||
5)
|
||||
# 停止容器
|
||||
echo "正在停止容器.."
|
||||
docker-compose -f ./docker-compose.yml down
|
||||
;;
|
||||
6)
|
||||
# 更新镜像
|
||||
bash ./bin/update_docker_images.sh
|
||||
;;
|
||||
7)
|
||||
# 修改域名
|
||||
check_config_file
|
||||
bash ./bin/update_domain.sh
|
||||
restart_docker
|
||||
;;
|
||||
8)
|
||||
# 修改端口
|
||||
check_config_file
|
||||
bash ./bin/update_port.sh
|
||||
restart_docker
|
||||
;;
|
||||
*)
|
||||
echo "无效的选择, 请重新选择."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main
|
||||
Loading…
Reference in New Issue
Block a user