Files
abot/docker-entrypoint.sh

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:temp/wechat_ipad/config.toml}"
legacy_config_path: "\${WECHAT_LEGACY_CONFIG_PATH:wechat_ipad/config.toml}"
EOF
fi
# wechat_ipad 登录态现在单独落到本地状态目录:
# 1. 静态连接配置已统一走 `.env` / `config.yaml`
# 2. 这里只需要保证状态文件目录存在,供运行期自动写入 wxid / device 缓存;
# 3. 这样容器启动脚本不再负责生成和维护第二份静态配置文件。
mkdir -p /app/temp/wechat_ipad
exec "$@"