mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-01 12:33:41 +00:00
feat: Add Proxmox LXC auto-enrollment script with dpkg error recovery
This commit is contained in:
@@ -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))"
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user