initial commit

This commit is contained in:
TheOnlyMace
2026-06-18 23:45:08 +02:00
commit 7ba9687619
96 changed files with 4309 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
"""Generate bcrypt hash and JWT secret for HexaWetter admin login."""
from __future__ import annotations
import argparse
import secrets
import bcrypt
def hash_password(plain_password: str) -> str:
return bcrypt.hashpw(plain_password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")
def docker_compose_escape(value: str) -> str:
"""Escape $ for docker compose .env interpolation ($$ -> literal $)."""
return value.replace("$", "$$")
def main() -> None:
parser = argparse.ArgumentParser(description="Generate HexaWetter admin credentials")
parser.add_argument("password", help="Admin password (min. 8 characters)")
args = parser.parse_args()
if len(args.password) < 8:
raise SystemExit("Password must be at least 8 characters")
password_hash = hash_password(args.password)
jwt_secret = secrets.token_urlsafe(48)
print("Add these lines to your .env file:\n")
print("ADMIN_USERNAME=admin")
print(f"ADMIN_PASSWORD_HASH={docker_compose_escape(password_hash)}")
print(f"ADMIN_JWT_SECRET={jwt_secret}")
print("\n# Hinweis: bcrypt-Hashes enthalten $. Fuer docker compose muss jedes $ als $$ escaped sein.")
if __name__ == "__main__":
main()