From d5121c56f3526656ceab026d20cce6733db81db1 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 22 Mar 2026 14:32:16 -0400 Subject: [PATCH] Fix: never overwrite existing hwmonDaemon .env on re-runs If /etc/hwmonDaemon/.env already exists and has a real API key, skip the prompt and preserve the file entirely. Only write a new .env when none exists or it still has the placeholder value. Safe to run freshStart.sh on existing hosts. Co-Authored-By: Claude Sonnet 4.6 --- freshStart.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/freshStart.sh b/freshStart.sh index 4d9101c..d123a9b 100644 --- a/freshStart.sh +++ b/freshStart.sh @@ -311,11 +311,17 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━ echo " hwmonDaemon API Key Configuration" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" -echo "The hwmonDaemon requires an API key to create tickets." -echo "You can enter it now or configure it later by editing:" -echo " /etc/hwmonDaemon/.env" -echo "" -read -p "Enter API key (or press Enter to skip): " API_KEY + +API_KEY="" +if [[ -f /etc/hwmonDaemon/.env ]] && ! grep -q "your_api_key_here" /etc/hwmonDaemon/.env; then + echo "✓ Existing /etc/hwmonDaemon/.env detected — skipping (will not overwrite)" +else + echo "The hwmonDaemon requires an API key to create tickets." + echo "You can enter it now or configure it later by editing:" + echo " /etc/hwmonDaemon/.env" + echo "" + read -p "Enter API key (or press Enter to skip): " API_KEY +fi # Determine platform-specific defaults if [[ "$PLATFORM" == "pbs" ]]; then @@ -326,7 +332,9 @@ else CEPH_DEFAULT="true" fi -if [[ -n "$API_KEY" ]]; then +if [[ -f /etc/hwmonDaemon/.env ]] && ! grep -q "your_api_key_here" /etc/hwmonDaemon/.env; then + : # already guarded above — existing .env preserved +elif [[ -n "$API_KEY" ]]; then # Create .env file with API key and all config options cat > /etc/hwmonDaemon/.env << EOF # hwmonDaemon Configuration