From 8475628e563ed15e89b62b82345d764132f67bbd Mon Sep 17 00:00:00 2001 From: Fushinn Date: Sun, 21 Jan 2024 21:19:54 +0800 Subject: [PATCH] =?UTF-8?q?0.9.9.16=20#####=201.=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ##### --- .shell/get-taichi.sh | 3 --- async_app/http.py | 11 +++++++++-- core/config.py | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.shell/get-taichi.sh b/.shell/get-taichi.sh index e864896..84c8e4d 100644 --- a/.shell/get-taichi.sh +++ b/.shell/get-taichi.sh @@ -1031,12 +1031,9 @@ echo "9. 使用Docker安装(AMD64, ARM64 如果遇到没有对应glibc库,使用 echo "10. 源码安装(适用于所有架构, 推荐)" echo "11. 源码更新" echo "12. 查看状态" -echo "13. [DEBUG]更改Docker路径配置" -echo "14. 群晖或者OpenWRT等应用安装路径错误修复" echo "========================" echo "优先使用源码安装" echo "群晖或者OpenWRT使用Docker安装" -echo "群晖或者OpenWRT使用Docker安装注册完成后使用14更新路径" echo "========================" read -p "请输入你的选择(1-12):" operation diff --git a/async_app/http.py b/async_app/http.py index 433a6f1..a6bd4bd 100644 --- a/async_app/http.py +++ b/async_app/http.py @@ -9,12 +9,19 @@ import tornado.web from aiodocker import Docker -from core.config import SOURCE_URL, DOCKER_DATA_PATH +from core.config import SOURCE_URL from core.models import client CODE_YES = 200 # 操作成功的响应码 CODE_NO = 400 # 操作失败的响应码 +# 获取 Docker 数据路径 +def get_docker_data_path(): + docker_info = client.info() + return docker_info.get('DockerRootDir') + +# 使用 Docker 数据路径 +docker_data_path = get_docker_data_path() def create_api_response(handler: tornado.web.RequestHandler, code: int, errmsg: any = '', data: any = None): """ @@ -129,7 +136,7 @@ async def post(self, id): image, name=name, ports={k: (None, v) for k, v in ports.items()}, - volumes={f"{DOCKER_DATA_PATH}/volumes/{v}/_data{details['bind']}": {'bind': details['bind'], + volumes={f"{docker_data_path}/volumes/{v}/_data{details['bind']}": {'bind': details['bind'], 'mode': details['mode']} for v, details in volumes.items()} if volumes else {}, restart_policy=restart_policy, diff --git a/core/config.py b/core/config.py index 095970d..ed9e8d9 100644 --- a/core/config.py +++ b/core/config.py @@ -6,10 +6,11 @@ # 构造 config.json 文件的完整路径 config_path = os.path.join(os.path.dirname(argv[0]), 'config.json') + + # 定义默认值 default_data = { 'source_url': 'https://app.kookoo.top', - 'docker_data_path':'/var/lib/docker', 'docker_download_url': 'https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz', 'docker_service_config': ( "[Unit]\n" @@ -59,7 +60,7 @@ DOCKER_DOWNLOAD_URL = data['docker_download_url'] DOCKER_SERVICE_CONFIG = data['docker_service_config'] GET_DOCKER_SHELL_COMMAND = data['get_docker_shell_command'] -DOCKER_DATA_PATH = data['docker_data_path'] + # @/file 配置文件 HOME_PATH = os.path.abspath('/') # 将路径转化为标准绝对路径 HOME_NAME = os.path.basename(HOME_PATH) # 根目录的名字 @@ -105,7 +106,7 @@ """ TAICHI_OS_WELCOME_MESSAGE = ("\n" - "版本 : 0.9.9.12-DEV\n" + "版本 : 0.9.9.16-DEV\n" "GITHUB : https://github.com/Xingsandesu\n") # # @/command 配置文件 # commands = {