From a7c50e4b0b4cbd9379b2285ab1aae87c84879ee0 Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 06:21:03 +0200 Subject: [PATCH] Always regenerate web credentials on install, prompt for username Co-Authored-By: Claude Opus 4.6 --- scripts/install.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 9b5fc75..a9f733a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -164,22 +164,22 @@ enable_web="n" read -rp "Enable web dashboard (TUI in browser)? (y/n) [n]: " enable_web /dev/null; then - echo 'WEB_USER="admin"' >> "$CONFIG_DIR/gniza.conf" - fi - if ! grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null || \ - [ -z "$(grep '^WEB_API_KEY=' "$CONFIG_DIR/gniza.conf" 2>/dev/null | sed 's/^WEB_API_KEY="//' | sed 's/"$//')" ]; then - api_key="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')" - if grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then - sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$CONFIG_DIR/gniza.conf" - else - echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf" - fi - info "Web credentials: user=admin password=$api_key" - echo "Save these -- you will need them to access the dashboard." + web_user="admin" + read -rp "Web username [admin]: " web_user /dev/null; then + sed -i "s|^WEB_USER=.*|WEB_USER=\"${web_user}\"|" "$CONFIG_DIR/gniza.conf" else - info "Web credentials already configured." + echo "WEB_USER=\"${web_user}\"" >> "$CONFIG_DIR/gniza.conf" fi + if grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then + sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$CONFIG_DIR/gniza.conf" + else + echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf" + fi + info "Web credentials: user=$web_user password=$api_key" + echo "Save these -- you will need them to access the dashboard." # Install systemd service if [ "$MODE" = "root" ]; then "$INSTALL_DIR/bin/gniza" web install-service || warn "Failed to install web service"