From 5e8cfa6b634d9405fc38eac9510a625b0811be98 Mon Sep 17 00:00:00 2001 From: Muhammad Ibrahim Date: Fri, 3 Oct 2025 22:27:04 +0100 Subject: [PATCH] feat: Add Proxmox LXC auto-enrollment script with dpkg error recovery --- agents/proxmox_auto_enroll.sh | 4 ++-- backend/src/server.js | 36 ----------------------------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/agents/proxmox_auto_enroll.sh b/agents/proxmox_auto_enroll.sh index ad573a9..ff1202e 100755 --- a/agents/proxmox_auto_enroll.sh +++ b/agents/proxmox_auto_enroll.sh @@ -1,10 +1,10 @@ #!/bin/bash -set -euo pipefail # Exit on error, undefined vars, pipe failures +set -eo pipefail # Exit on error, pipe failures (removed -u as we handle unset vars explicitly) # Trap to catch errors only (not normal exits) trap 'echo "[ERROR] Script failed at line $LINENO with exit code $?"' ERR -SCRIPT_VERSION="1.1.0" +SCRIPT_VERSION="1.1.1" echo "[DEBUG] Script Version: $SCRIPT_VERSION ($(date +%Y-%m-%d\ %H:%M:%S))" # ============================================================================= diff --git a/backend/src/server.js b/backend/src/server.js index e407f0a..6d83c2f 100644 --- a/backend/src/server.js +++ b/backend/src/server.js @@ -1,40 +1,4 @@ require("dotenv").config(); - -// Validate required environment variables on startup -function validateEnvironmentVariables() { - const requiredVars = { - JWT_SECRET: "Required for secure authentication token generation", - DATABASE_URL: "Required for database connection", - }; - - const missing = []; - - // Check required variables - for (const [varName, description] of Object.entries(requiredVars)) { - if (!process.env[varName]) { - missing.push(`${varName}: ${description}`); - } - } - - // Fail if required variables are missing - if (missing.length > 0) { - console.error("❌ Missing required environment variables:"); - for (const error of missing) { - console.error(` - ${error}`); - } - console.error(""); - console.error( - "Please set these environment variables and restart the application.", - ); - process.exit(1); - } - - console.log("✅ Environment variable validation passed"); -} - -// Validate environment variables before importing any modules that depend on them -validateEnvironmentVariables(); - const express = require("express"); const cors = require("cors"); const helmet = require("helmet");