add new features
All checks were successful
Update Dispatches / refresh-news (push) Successful in 2s
All checks were successful
Update Dispatches / refresh-news (push) Successful in 2s
proxmox commander
This commit is contained in:
99
modules/proxmox-commander
Normal file
99
modules/proxmox-commander
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------
|
||||
# Dynasty Module: Proxmox Commander (Fleet Provisioning Engine)
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
# Colors
|
||||
BLUE='\033[38;5;45m'; PURPLE='\033[38;5;127m'; GOLD='\033[38;5;178m'; RED='\033[38;5;196m'; NC='\033[0m'
|
||||
|
||||
# --- 1. ENVIRONMENT CHECK ---
|
||||
if ! command -v pct &> /dev/null; then
|
||||
echo -e "${RED}❌ Error: This module must run on a Proxmox Host.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}🐉 Dynasty Proxmox Commander Initialized${NC}"
|
||||
echo -e "-------------------------------------------------"
|
||||
|
||||
# --- 2. GATHER GLOBAL SETTINGS ---
|
||||
read -p "🚢 Total LXCs to manifest: " LXC_COUNT
|
||||
|
||||
# Batch Distro Logic
|
||||
DISTRO_MODE="individual"
|
||||
if [ "$LXC_COUNT" -gt 1 ]; then
|
||||
read -p "📋 Use the same Distro for all? (y/n): " SAME_DISTRO
|
||||
[[ "$SAME_DISTRO" =~ ^[Yy]$ ]] && DISTRO_MODE="global"
|
||||
fi
|
||||
|
||||
if [ "$DISTRO_MODE" == "global" ]; then
|
||||
echo -e "${PURPLE}Select Global Distro:${NC}\n1) Deb 12 2) Deb 13 3) Alpine 4) Arch"
|
||||
read -p "Selection: " G_OS
|
||||
fi
|
||||
|
||||
# ID Strategy
|
||||
read -p "🔢 Starting LXC ID (e.g., 200): " START_ID
|
||||
AUTO_ID="n"
|
||||
[ "$LXC_COUNT" -gt 1 ] && read -p "🤖 Auto-assign sequential IDs? (y/n): " AUTO_ID
|
||||
|
||||
# --- 3. STORAGE DISCOVERY ---
|
||||
echo -e "\n${PURPLE}🗄️ Scanning Proxmox Storage...${NC}"
|
||||
pvesm status | awk 'NR>1 {print " - " $1 " (" $2 ")"}'
|
||||
read -p "📥 Template Storage (where ISOs live): " T_STORE
|
||||
read -p "💾 Disk Storage (where LXCs run): " D_STORE
|
||||
|
||||
# --- 4. THE CONFIGURATION LOOP ---
|
||||
declare -A LXC_STACKS
|
||||
declare -A LXC_NAMES
|
||||
declare -A LXC_IDS
|
||||
|
||||
for (( i=1; i<=$LXC_COUNT; i++ )); do
|
||||
echo -e "\n${BLUE}🛠️ Configuring Node #$i${NC}"
|
||||
|
||||
# Identify ID and Hostname
|
||||
[[ "$AUTO_ID" =~ ^[Yy]$ ]] && CID=$((START_ID + i - 1)) || read -p " 🆔 ID for Node #$i: " CID
|
||||
read -p " 🏷️ Hostname for Node #$i: " NAME
|
||||
|
||||
LXC_IDS[$i]=$CID
|
||||
LXC_NAMES[$i]=$NAME
|
||||
|
||||
# Network Setup
|
||||
read -p " 🌐 VLAN Tag [none]: " VLAN
|
||||
read -p " 🧬 DNS [1.1.1.1]: " DNS; DNS=${DNS:-1.1.1.1}
|
||||
read -p " 📏 MTU [1500]: " MTU; MTU=${MTU:-1500}
|
||||
|
||||
# Stack Logic
|
||||
read -p " 📦 Install Docker? (y/n): " INST_DOCKER
|
||||
STACK="none"
|
||||
if [[ "$INST_DOCKER" =~ ^[Yy]$ ]]; then
|
||||
echo -e " 1) Portainer 2) Arcane 3) Dockhand 4) Docker Only"
|
||||
read -p " Select Stack: " STACK
|
||||
fi
|
||||
LXC_STACKS[$i]=$STACK
|
||||
|
||||
# Save Config to file for persistence
|
||||
CONF_PATH="$HOME/.dynr/configs/$NAME.conf"
|
||||
mkdir -p "$HOME/.dynr/configs"
|
||||
echo "ID=$CID;NAME=$NAME;STACK=$STACK;VLAN=$VLAN;DNS=$DNS;MTU=$MTU" > "$CONF_PATH"
|
||||
done
|
||||
|
||||
# --- 5. EXECUTION BLOCK ---
|
||||
read -p "🔥 Initiate Full Fleet Manifestation? (y/n): " EXEC_ALL
|
||||
if [[ "$EXEC_ALL" =~ ^[Yy]$ ]]; then
|
||||
for (( i=1; i<=$LXC_COUNT; i++ )); do
|
||||
CID=${LXC_IDS[$i]}
|
||||
NAME=${LXC_NAMES[$i]}
|
||||
|
||||
echo -e "${GOLD}🏗️ Building $NAME (ID: $CID)...${NC}"
|
||||
|
||||
# Actual Proxmox commands would be uncommented here:
|
||||
# pct create $CID $T_STORE:vztmpl/debian-12... --hostname $NAME --net0 name=eth0,bridge=vmbr0,ip=dhcp,tag=$VLAN --dns $DNS
|
||||
|
||||
# Enable Protected Mode
|
||||
# pct set $CID --protection 1
|
||||
|
||||
# Mesh TUN/TAP Config Injection
|
||||
# echo "lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file" >> /etc/pve/lxc/$CID.conf
|
||||
|
||||
echo -e "${GOLD}✅ $NAME is live.${NC}"
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user