fix: run init_db with panel venv python
Use venv interpreter so werkzeug is available; sync admin user from .env on init. Set default panel username to dekun. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+6
-7
@@ -44,14 +44,13 @@ def init_db(env: dict[str, str]) -> None:
|
||||
username = env.get("PANEL_USERNAME", "admin")
|
||||
password = env.get("PANEL_PASSWORD")
|
||||
if not password:
|
||||
raise SystemExit("请在 .env 中设置 PANEL_PASSWORD(运行 generate-keys.sh 可自动生成)")
|
||||
raise SystemExit("请在 .env 中设置 PANEL_PASSWORD")
|
||||
|
||||
row = conn.execute("SELECT id FROM admin WHERE username = ?", (username,)).fetchone()
|
||||
if row is None:
|
||||
conn.execute(
|
||||
"INSERT INTO admin (username, password_hash) VALUES (?, ?)",
|
||||
(username, generate_password_hash(password)),
|
||||
)
|
||||
conn.execute("DELETE FROM admin")
|
||||
conn.execute(
|
||||
"INSERT INTO admin (username, password_hash) VALUES (?, ?)",
|
||||
(username, generate_password_hash(password)),
|
||||
)
|
||||
|
||||
count = conn.execute("SELECT COUNT(*) AS c FROM nodes").fetchone()["c"]
|
||||
if count == 0:
|
||||
|
||||
Reference in New Issue
Block a user