From d5d6038a531cc1e9b5e97219f651f1c6a71630d9 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 10 Feb 2026 13:20:04 -0500 Subject: [PATCH] Add PBS platform detection and expanded .env configuration Detects PVE vs PBS at startup, installs platform-specific packages (iperf3/fio for PVE, zfsutils-linux for PBS), and generates .env with all hwmonDaemon config options pre-populated based on platform. Fixes: https://code.lotusguild.org/LotusGuild/hwmonDaemon/issues/5 Co-Authored-By: Claude Opus 4.6 --- freshStart.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/freshStart.sh b/freshStart.sh index 6568380..2c27149 100644 --- a/freshStart.sh +++ b/freshStart.sh @@ -3,6 +3,21 @@ set -e echo "Starting Proxmox fresh installation script..." +# ============================================================================= +# Platform Detection +# ============================================================================= +PLATFORM="unknown" +if command -v pveversion &>/dev/null; then + PLATFORM="pve" + echo "Detected platform: Proxmox VE ($(pveversion 2>/dev/null || echo 'version unknown'))" +elif command -v proxmox-backup-manager &>/dev/null; then + PLATFORM="pbs" + echo "Detected platform: Proxmox Backup Server" +else + echo "WARNING: Could not detect Proxmox platform (PVE or PBS)" + echo "Proceeding with common package installation..." +fi + # Cleanup function for failed installations cleanup() { echo "Cleaning up on error..." @@ -26,7 +41,20 @@ trap cleanup ERR # Install dependencies echo "Installing required packages..." apt-get update -apt-get install -y python3-pip smartmontools iperf3 python3-psutil python3-requests lm-sensors fastfetch rsync fio jq sysstat + +# Common packages for all platforms +COMMON_PKGS="python3-pip smartmontools python3-psutil python3-requests lm-sensors fastfetch rsync jq sysstat" + +if [[ "$PLATFORM" == "pve" ]]; then + echo "Installing PVE-specific packages..." + apt-get install -y $COMMON_PKGS iperf3 fio nvme-cli +elif [[ "$PLATFORM" == "pbs" ]]; then + echo "Installing PBS-specific packages..." + apt-get install -y $COMMON_PKGS zfsutils-linux nvme-cli +else + echo "Installing common packages..." + apt-get install -y $COMMON_PKGS nvme-cli +fi # Install Node Exporter echo "Installing Prometheus Node Exporter..." @@ -137,27 +165,82 @@ echo " /etc/hwmonDaemon/.env" echo "" read -p "Enter API key (or press Enter to skip): " API_KEY +# Determine platform-specific defaults +if [[ "$PLATFORM" == "pbs" ]]; then + PBS_DEFAULT="true" + CEPH_DEFAULT="false" +else + PBS_DEFAULT="false" + CEPH_DEFAULT="true" +fi + if [[ -n "$API_KEY" ]]; then - # Create .env file with API key + # Create .env file with API key and all config options cat > /etc/hwmonDaemon/.env << EOF # hwmonDaemon Configuration # Auto-generated by freshStart.sh on $(date) +# Platform: ${PLATFORM} # Ticket API Configuration TICKET_API_KEY=$API_KEY TICKET_API_URL=http://10.10.10.45/create_ticket_api.php + +# Cluster Identification +CLUSTER_NAME=proxmox-cluster + +# Ceph Monitoring (PVE nodes) +CEPH_ENABLED=${CEPH_DEFAULT} +#CEPH_TICKET_NODE= +#CEPH_USAGE_WARNING=70 +#CEPH_USAGE_CRITICAL=85 + +# PBS Monitoring (Proxmox Backup Server) +PBS_ENABLED=${PBS_DEFAULT} +#PBS_ZFS_WARNING=80 +#PBS_ZFS_CRITICAL=90 + +# Prometheus Metrics +PROMETHEUS_ENABLED=false +#PROMETHEUS_PORT=9101 + +# Health Check Endpoint +HEALTH_SERVER_ENABLED=false +#HEALTH_SERVER_PORT=9102 EOF chmod 600 /etc/hwmonDaemon/.env echo "✓ API key configured in /etc/hwmonDaemon/.env" else - # Create template .env file - cat > /etc/hwmonDaemon/.env << 'EOF' + # Create template .env file with all config options + cat > /etc/hwmonDaemon/.env << EOF # hwmonDaemon Configuration # Edit this file to add your API key +# Platform: ${PLATFORM} # Ticket API Configuration TICKET_API_KEY=your_api_key_here TICKET_API_URL=http://10.10.10.45/create_ticket_api.php + +# Cluster Identification +CLUSTER_NAME=proxmox-cluster + +# Ceph Monitoring (PVE nodes) +CEPH_ENABLED=${CEPH_DEFAULT} +#CEPH_TICKET_NODE= +#CEPH_USAGE_WARNING=70 +#CEPH_USAGE_CRITICAL=85 + +# PBS Monitoring (Proxmox Backup Server) +PBS_ENABLED=${PBS_DEFAULT} +#PBS_ZFS_WARNING=80 +#PBS_ZFS_CRITICAL=90 + +# Prometheus Metrics +PROMETHEUS_ENABLED=false +#PROMETHEUS_PORT=9101 + +# Health Check Endpoint +HEALTH_SERVER_ENABLED=false +#HEALTH_SERVER_PORT=9102 EOF chmod 600 /etc/hwmonDaemon/.env echo "⚠️ WARNING: API key not configured!" @@ -199,9 +282,11 @@ trap - ERR echo "✓ Installation complete! All services are running correctly." echo "" +echo "Platform: ${PLATFORM^^}" +echo "" echo "Services installed:" echo " - Node Exporter: http://$(hostname -I | awk '{print $1}'):9100/metrics" -echo " - hwmon daemon: Monitoring system health every 15 minutes" +echo " - hwmon daemon: Monitoring system health hourly" echo "" echo "Configuration files:" echo " - hwmon config: /etc/hwmonDaemon/.env" @@ -211,6 +296,17 @@ echo " - Node Exporter: journalctl -u node_exporter" echo " - hwmon: journalctl -u hwmon.service" echo " - hwmon logs: /var/log/hwmonDaemon/" echo "" +if [[ "$PLATFORM" == "pbs" ]]; then + echo "PBS-specific monitoring enabled:" + echo " - ZFS pool health and usage monitoring" + echo " - Failed backup/GC/sync task detection" + echo "" +elif [[ "$PLATFORM" == "pve" ]]; then + echo "PVE-specific monitoring enabled:" + echo " - Ceph cluster health monitoring" + echo " - LXC container storage monitoring" + echo "" +fi 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 \ No newline at end of file