fix(installer): clean old Authelia DB on fresh install to avoid encryption key mismatch

This commit is contained in:
Claus Lohmar 2026-06-14 15:44:49 +00:00
parent 50648f9c43
commit 631780cdf6
2 changed files with 7 additions and 3 deletions

View file

@ -61,12 +61,14 @@ NextWks/
### Prerequisites ### Prerequisites
- Go 1.22+ - Linux (amd64) — tested on Debian/Ubuntu, Proxmox LXC
- Authelia v4.38 (install with `bash scripts/install-authelia.sh`) - Go 1.22+ (installed automatically if missing)
- `git`, `curl`, `openssl` (standard tools)
### Production Install (recommended) ### Production Install
```bash ```bash
# One command — downloads, builds, deploys
curl -fsSL https://git.lohmar.co.uk/lexton-it/NextWks/raw/main/install.sh | bash curl -fsSL https://git.lohmar.co.uk/lexton-it/NextWks/raw/main/install.sh | bash
``` ```

View file

@ -381,6 +381,8 @@ AUTHEOF
# Create initial users_database.yml (needed for Authelia to start) # Create initial users_database.yml (needed for Authelia to start)
if [ ! -f "${AUTHELIA_DIR}/users_database.yml" ]; then if [ ! -f "${AUTHELIA_DIR}/users_database.yml" ]; then
info "Creating initial users database..." info "Creating initial users database..."
# Remove old DB if encryption key changed
find "${AUTHELIA_DIR}/db.sqlite3" -delete 2>/dev/null || true
ADMIN_HASH=$("${AUTHELIA_DIR}/authelia" crypto hash generate --password "$(openssl rand -base64 16)" 2>/dev/null | awk '{print $NF}' || echo "\$argon2id\$v=19\$m=65536,t=3,p=4\$placeholder") ADMIN_HASH=$("${AUTHELIA_DIR}/authelia" crypto hash generate --password "$(openssl rand -base64 16)" 2>/dev/null | awk '{print $NF}' || echo "\$argon2id\$v=19\$m=65536,t=3,p=4\$placeholder")
cat > "${AUTHELIA_DIR}/users_database.yml" << USERSDB cat > "${AUTHELIA_DIR}/users_database.yml" << USERSDB
users: users: