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 <noreply@anthropic.com>
This commit is contained in:
+9
-1
@@ -311,11 +311,17 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
echo " hwmonDaemon API Key Configuration"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo ""
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user