🐛 修复环境变量账号密码生效逻辑 #42
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run

- 修复首次部署管理账号密码环境变量不生效
- 使用环境变量优先设置用户名和密码
This commit is contained in:
Cp0204 2024-11-25 18:48:21 +08:00
parent 26060f0dd7
commit 9d599b5e64

View File

@ -288,16 +288,12 @@ def init():
dest.write(src.read()) dest.write(src.read())
data = read_json() data = read_json()
# 默认管理账号 # 默认管理账号
if not data.get("webui"): data["webui"] = {
data["webui"] = { "username": os.environ.get("WEBUI_USERNAME")
"username": "admin", or data.get("webui", {}).get("username", "admin"),
"password": "admin123", "password": os.environ.get("WEBUI_PASSWORD")
} or data.get("webui", {}).get("password", "admin123"),
elif os.environ.get("WEBUI_USERNAME") and os.environ.get("WEBUI_PASSWORD"): }
data["webui"] = {
"username": os.environ.get("WEBUI_USERNAME"),
"password": os.environ.get("WEBUI_PASSWORD"),
}
# 默认定时规则 # 默认定时规则
if not data.get("crontab"): if not data.get("crontab"):
data["crontab"] = "0 8,18,20 * * *" data["crontab"] = "0 8,18,20 * * *"