Added api key for hwmonDaemon

This commit is contained in:
2026-01-01 16:00:44 -05:00
parent 29f0157436
commit bc50fd7348
3 changed files with 189 additions and 15 deletions

View File

@@ -99,12 +99,12 @@ echo "Installing hwmon daemon..."
# Download hwmon service files with error handling
echo "Downloading hwmon service files..."
if ! curl --max-time 30 --retry 3 -o /etc/systemd/system/hwmon.service http://10.10.10.110:3000/JWS/hwmonDaemon/raw/branch/main/hwmon.service; then
if ! curl --max-time 30 --retry 3 -o /etc/systemd/system/hwmon.service http://10.10.10.63:3000/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.service; then
echo "ERROR: Failed to download hwmon.service"
exit 1
fi
if ! curl --max-time 30 --retry 3 -o /etc/systemd/system/hwmon.timer http://10.10.10.110:3000/JWS/hwmonDaemon/raw/branch/main/hwmon.timer; then
if ! curl --max-time 30 --retry 3 -o /etc/systemd/system/hwmon.timer http://10.10.10.63:3000/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.timer; then
echo "ERROR: Failed to download hwmon.timer"
exit 1
fi
@@ -120,9 +120,51 @@ if [[ ! -s /etc/systemd/system/hwmon.timer ]]; then
exit 1
fi
# Create log directory for hwmon
# Create configuration directory for hwmon
echo "Setting up hwmon configuration..."
mkdir -p /etc/hwmonDaemon
mkdir -p /var/log/hwmonDaemon
# Prompt for API key or use default
echo ""
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
if [[ -n "$API_KEY" ]]; then
# Create .env file with API key
cat > /etc/hwmonDaemon/.env << EOF
# hwmonDaemon Configuration
# Auto-generated by freshStart.sh 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 "✓ API key configured in /etc/hwmonDaemon/.env"
else
# Create template .env file
cat > /etc/hwmonDaemon/.env << 'EOF'
# hwmonDaemon Configuration
# Edit this file to add your API key
# Ticket API Configuration
TICKET_API_KEY=your_api_key_here
TICKET_API_URL=http://10.10.10.45/create_ticket_api.php
EOF
chmod 600 /etc/hwmonDaemon/.env
echo "⚠️ WARNING: API key not configured!"
echo " Edit /etc/hwmonDaemon/.env to add your API key before tickets can be created"
fi
echo ""
# Start the hwmon daemon
systemctl daemon-reload
systemctl enable hwmon.timer
@@ -148,7 +190,7 @@ fi
# Test hwmon with error handling
echo "Testing hwmon dry-run..."
if ! /usr/bin/env python3 -c "import urllib.request; exec(urllib.request.urlopen('http://10.10.10.110:3000/JWS/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))" --dry-run; then
if ! /usr/bin/env python3 -c "import urllib.request; exec(urllib.request.urlopen('http://10.10.10.63:3000/LotusGuild/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))" --dry-run; then
echo "WARNING: hwmon dry-run test failed, but services are installed"
fi
@@ -161,7 +203,14 @@ echo "Services installed:"
echo " - Node Exporter: http://$(hostname -I | awk '{print $1}'):9100/metrics"
echo " - hwmon daemon: Monitoring system health every 15 minutes"
echo ""
echo "Configuration files:"
echo " - hwmon config: /etc/hwmonDaemon/.env"
echo ""
echo "Log locations:"
echo " - Node Exporter: journalctl -u node_exporter"
echo " - hwmon: journalctl -u hwmon.service"
echo " - hwmon logs: /var/log/hwmonDaemon/"
echo " - hwmon logs: /var/log/hwmonDaemon/"
echo ""
if [[ ! -s /etc/hwmonDaemon/.env ]] || grep -q "your_api_key_here" /etc/hwmonDaemon/.env 2>/dev/null; then
echo "⚠️ REMINDER: Configure your API key in /etc/hwmonDaemon/.env"
fi