#!/bin/bash # Quick script to update hwmonDaemon API key on existing servers echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo " hwmonDaemon API Key Update Utility" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" # Check if running as root if [[ $EUID -ne 0 ]]; then echo "❌ This script must be run as root" exit 1 fi # Create directory if it doesn't exist mkdir -p /etc/hwmonDaemon # Prompt for API key echo "Enter your Tinker Tickets API key:" read -p "API Key: " API_KEY if [[ -z "$API_KEY" ]]; then echo "❌ API key cannot be empty" exit 1 fi # Create/update .env file cat > /etc/hwmonDaemon/.env << EOF # hwmonDaemon Configuration # Updated on $(date) # Ticket API Configuration TICKET_API_KEY=$API_KEY TICKET_API_URL=http://10.10.10.45/create_ticket_api.php EOF chmod 600 /etc/hwmonDaemon/.env echo "" echo "✅ API key updated successfully!" echo "" echo "Configuration saved to: /etc/hwmonDaemon/.env" echo "" echo "The new API key will be used on the next hwmon run." echo "To test immediately:" echo " systemctl start hwmon.service" echo "" echo "Check logs:" echo " journalctl -u hwmon.service -n 20"