diff --git a/config_template/tls_cert_config.json b/config_template/tls_cert_config.json index a10d18b..a16c20f 100644 --- a/config_template/tls_cert_config.json +++ b/config_template/tls_cert_config.json @@ -29,5 +29,5 @@ "url": "https://你的域名", "rewriteHost": true } - }, + } } \ No newline at end of file diff --git a/install.sh b/install.sh index 884d679..073a7fa 100644 --- a/install.sh +++ b/install.sh @@ -27,9 +27,43 @@ install(){ fi } +create_config(){ + local config_password=$(jq -r '.auth.password' "./config.json") + if [ "$config_password" != "你的密码" ]; then + local regenerate + read -p "检测到配置已存在,是否重新生成配置?(y/n): " regenerate + if [ "$regenerate" != "y" ] && [ "$regenerate" != "Y" ]; then + echo "取消重新生成配置." + return + fi + fi + + echo "请选择配置类型:" + echo "1. 自签名证书配置" + echo "2. tls证书配置" + local choice + read -p "输入您的选择: " choice + case $choice in + 1) + echo "重置为自签名证书配置..." + cp ./config_template/self_cert_config.json ./config.json + bash ./bin/init.sh + ;; + 2) + echo "重置为tls证书配置..." + cp ./config_template/tls_cert_config.json ./config.json + bash ./bin/init_with_tls_cert.sh + ;; + *) + echo "无效的选择, 请重新选择." + ;; + esac +} + # 显示菜单 echo "请选择一个操作:" +echo "0. 生成配置" echo "1. 启动容器" echo "2. 查看分享链接" echo "3. 停止容器" @@ -43,6 +77,10 @@ read -p "输入您的选择: " choice # 根据用户选择执行相应的操作 case $choice in + 0) + echo "重新生成配置.." + create_config + ;; 1) # 启动容器 echo "启动容器.." @@ -79,6 +117,3 @@ case $choice in echo "无效的选择, 请重新选择." ;; esac - - -