This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
# Docker 容器入口脚本
|
||||
# 确保持久化目录和符号链接就绪,然后启动应用
|
||||
# API 凭证通过 Web 配置向导填写,无需手动配置
|
||||
|
||||
set -e
|
||||
|
||||
APPDATA="/app/appdata"
|
||||
|
||||
# 确保持久化子目录存在
|
||||
mkdir -p "$APPDATA/sessions" "$APPDATA/temp" "$APPDATA/log"
|
||||
|
||||
# 确保 data.yaml 文件存在
|
||||
[ -f "$APPDATA/data.yaml" ] || touch "$APPDATA/data.yaml"
|
||||
|
||||
# 创建符号链接,让应用从 /app/ 工作目录找到配置和数据
|
||||
# config.yaml 可能不存在——应用启动时会自动创建默认版本
|
||||
[ -L /app/config.yaml ] || ln -sf "$APPDATA/config.yaml" /app/config.yaml
|
||||
[ -L /app/data.yaml ] || ln -sf "$APPDATA/data.yaml" /app/data.yaml
|
||||
[ -L /app/sessions ] || ln -sf "$APPDATA/sessions" /app/sessions
|
||||
[ -L /app/temp ] || ln -sf "$APPDATA/temp" /app/temp
|
||||
[ -L /app/log ] || ln -sf "$APPDATA/log" /app/log
|
||||
|
||||
# 若 config.yaml 已存在且设置了 WEB_PORT 环境变量,更新配置文件里的端口
|
||||
if [ -n "$WEB_PORT" ] && [ -f "$APPDATA/config.yaml" ]; then
|
||||
sed -i "s/^web_port:.*/web_port: ${WEB_PORT}/" "$APPDATA/config.yaml"
|
||||
fi
|
||||
|
||||
# 若设置了代理环境变量,写入 config.yaml
|
||||
if [ -n "$PROXY_HOSTNAME" ] && [ -f "$APPDATA/config.yaml" ]; then
|
||||
python3 -c "
|
||||
import yaml, os, sys
|
||||
path = '$APPDATA/config.yaml'
|
||||
with open(path) as f:
|
||||
cfg = yaml.safe_load(f) or {}
|
||||
cfg['proxy'] = {
|
||||
'scheme': os.environ.get('PROXY_SCHEME', 'socks5'),
|
||||
'hostname': os.environ.get('PROXY_HOSTNAME'),
|
||||
'port': int(os.environ.get('PROXY_PORT', 7890))
|
||||
}
|
||||
with open(path, 'w') as f:
|
||||
yaml.dump(cfg, f, allow_unicode=True, default_flow_style=False)
|
||||
print('[entrypoint] 代理配置已写入: ' + cfg['proxy']['scheme'] + '://' + cfg['proxy']['hostname'] + ':' + str(cfg['proxy']['port']))
|
||||
"
|
||||
fi
|
||||
|
||||
echo "[entrypoint] 启动应用..."
|
||||
exec python3 /app/media_downloader.py
|
||||
Reference in New Issue
Block a user