重构代码, 统一项目入口为install.sh.
This commit is contained in:
+22
-13
@@ -1,6 +1,13 @@
|
||||
#!/bin/bash
|
||||
source "$(dirname "$0")/bin/utils/base.sh"
|
||||
source "$(dirname "$0")/bin/utils/jq_util.sh"
|
||||
|
||||
# 导入依赖脚本文件
|
||||
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
for f in "$BASE_DIR"/bin/utils/*.sh; do
|
||||
[ -f "$f" ] && source "$f"
|
||||
done
|
||||
for f in "$BASE_DIR"/bin/*.sh; do
|
||||
[ -f "$f" ] && source "$f"
|
||||
done
|
||||
|
||||
install(){
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
@@ -12,17 +19,18 @@ install(){
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo 安装jq...
|
||||
install_package jq
|
||||
fi
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo 安装docker...
|
||||
sleep 1
|
||||
curl -fsSL https://get.docker.com | bash -s docker
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
echo 安装docker-compose...
|
||||
sleep 1
|
||||
wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-x86_64
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
@@ -42,6 +50,7 @@ main(){
|
||||
echo "8. 更新镜像"
|
||||
|
||||
# 读取用户选择
|
||||
local choice
|
||||
read -p "输入您的选择: " choice
|
||||
|
||||
# 根据用户选择执行相应的操作
|
||||
@@ -49,36 +58,36 @@ main(){
|
||||
1)
|
||||
# 一键部署
|
||||
install
|
||||
bash ./bin/create_config.sh
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
create_config
|
||||
run
|
||||
printf_share_link
|
||||
;;
|
||||
2)
|
||||
# 生成配置 / 重置配置
|
||||
bash ./bin/create_config.sh
|
||||
create_config
|
||||
;;
|
||||
3)
|
||||
# 查看分享链接
|
||||
check_config_file
|
||||
bash ./bin/print_share_link.sh
|
||||
printf_share_link
|
||||
;;
|
||||
4)
|
||||
# 修改域名
|
||||
check_config_file
|
||||
bash ./bin/update_domain.sh
|
||||
update_domain
|
||||
restart_docker
|
||||
;;
|
||||
5)
|
||||
# 修改端口
|
||||
check_config_file
|
||||
bash ./bin/update_port.sh
|
||||
update_port
|
||||
restart_docker
|
||||
;;
|
||||
6)
|
||||
# 启动容器
|
||||
check_config_file
|
||||
bash ./bin/run.sh
|
||||
bash ./bin/print_share_link.sh
|
||||
run
|
||||
printf_share_link
|
||||
;;
|
||||
7)
|
||||
# 停止容器
|
||||
@@ -86,7 +95,7 @@ main(){
|
||||
;;
|
||||
8)
|
||||
# 更新镜像
|
||||
bash ./bin/update_docker_images.sh
|
||||
update_docker_images
|
||||
restart_docker
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user