Files
abot/docker-entrypoint.sh
2026-05-07 10:29:03 +08:00

70 lines
2.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
mkdir -p /app/logs
# 首次启动时自动生成最小可运行配置:
# 1. 若用户已经通过挂载文件提供 config.yaml则完全尊重现有配置
# 2. 若未提供,则根据 .env / compose 环境变量生成一份安全模板;
# 3. 模板中的敏感值继续走环境变量占位,避免把真实密钥写进镜像层。
if [ ! -f /app/config.yaml ]; then
cat > /app/config.yaml <<EOF
environment: "\${ABOT_ENVIRONMENT:production}"
plugin_dir: "\${ABOT_PLUGIN_DIR:plugins}"
db_config:
pool_name: "\${ABOT_DB_POOL_NAME:wechat_boot_pool}"
pool_size: "\${ABOT_DB_POOL_SIZE:10}"
host: "\${ABOT_DB_HOST:127.0.0.1}"
port: "\${ABOT_DB_PORT:3306}"
prot: "\${ABOT_DB_PORT:3306}"
user: "\${ABOT_DB_USER:root}"
password: "\${ABOT_DB_PASSWORD}"
database: "\${ABOT_DB_NAME:message_archive}"
charset: "utf8mb4"
use_unicode: true
get_warnings: true
pool_reset_session: true
redis_config:
host: "\${ABOT_REDIS_HOST:127.0.0.1}"
port: "\${ABOT_REDIS_PORT:6379}"
password: "\${ABOT_REDIS_PASSWORD:}"
db: "\${ABOT_REDIS_DB:0}"
decode_responses: true
email_config:
smtp_server: "\${ABOT_EMAIL_SMTP_SERVER:smtp.163.com}"
smtp_port: "\${ABOT_EMAIL_SMTP_PORT:465}"
sender_email: "\${ABOT_EMAIL_SENDER:}"
sender_password: "\${ABOT_EMAIL_PASSWORD:}"
alert_recipient: "\${ABOT_EMAIL_ALERT_RECIPIENT:}"
glances:
host: "\${ABOT_GLANCES_HOST:127.0.0.1}"
port: "\${ABOT_GLANCES_PORT:61208}"
wx_config:
admin: [ "\${ABOT_WX_ADMIN:admin}" ]
wechat_ipad:
server_url: "\${WECHAT_SERVER_URL:http://host.docker.internal:8059/}"
server_ip: "\${WECHAT_SERVER_IP:host.docker.internal}"
server_port: "\${WECHAT_SERVER_PORT:8059}"
server_type: "\${WECHAT_SERVER_TYPE:legacy_855}"
wxid: "\${WECHAT_WXID:}"
device_name: "\${WECHAT_DEVICE_NAME:}"
device_id: "\${WECHAT_DEVICE_ID:}"
state_file: "\${WECHAT_STATE_FILE:}"
legacy_config_path: "\${WECHAT_LEGACY_CONFIG_PATH:wechat_ipad/config.toml}"
EOF
fi
# wechat_ipad 登录态现在默认落到 provider 自己目录下:
# 1. 静态连接配置已统一走 `.env` / `config.yaml`
# 2. 855 当前默认会写到 `wechat_ipad/providers/legacy_855/runtime_state.toml`
# 3. 这里只预创建 provider 根目录,真正状态文件由运行期按 provider 自动写入。
mkdir -p /app/wechat_ipad/providers
exec "$@"