96 lines
3.3 KiB
Bash
96 lines
3.3 KiB
Bash
#!/bin/bash
|
|
# ==============================================================================
|
|
# OnEver Drive — Proxmox VE Host Provisioning Script
|
|
# Executed directly on the Proxmox VE Host Shell (pve)
|
|
# Creates native Debian 12 / 13 LXC Container and mounts persistent storage
|
|
# ==============================================================================
|
|
|
|
set -e
|
|
|
|
# Configuration variables
|
|
CT_ID=100
|
|
HOSTNAME="onever-backend"
|
|
MEMORY=2048
|
|
SWAP=1024
|
|
CORES=2
|
|
DISK_SIZE="20G"
|
|
STORAGE_POOL="local-lvm"
|
|
HOST_BACKUP_STORAGE="/mnt/pve/backup-pool" # Adjust to your Proxmox ZFS/LVM path
|
|
BRIDGE="vmbr0"
|
|
IP_CONFIG="dhcp" # Or: "192.168.1.100/24,gw=192.168.1.1"
|
|
|
|
echo "========================================================================"
|
|
echo " ONEVER DRIVE — PROXMOX VE LXC CREATION SCRIPT "
|
|
echo "========================================================================"
|
|
|
|
# 1. Check Proxmox environment
|
|
if ! command -v pct &> /dev/null; then
|
|
echo "[!] Error: 'pct' command not found. This script must be executed on a Proxmox VE node."
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Check if CT ID already exists
|
|
if pct status "$CT_ID" &> /dev/null; then
|
|
echo "[!] Error: Container ID $CT_ID already exists. Please choose a different CT_ID."
|
|
exit 1
|
|
fi
|
|
|
|
# 3. Locate or download Debian 12 / 13 standard template
|
|
echo "[*] Searching for Debian 12 / 13 template..."
|
|
pveam update
|
|
TEMPLATE=$(pveam available | grep -E "debian-(12|13)-standard" | tail -n 1 | awk '{print $2}')
|
|
|
|
if [ -z "$TEMPLATE" ]; then
|
|
echo "[!] Could not automatically find Debian template. Using default debian-12-standard."
|
|
TEMPLATE="debian-12-standard_12.2-1_amd64.tar.zst"
|
|
fi
|
|
|
|
if ! pveam list local | grep -q "$TEMPLATE"; then
|
|
echo "[*] Downloading template: $TEMPLATE..."
|
|
pveam download local "$TEMPLATE"
|
|
fi
|
|
|
|
TEMPLATE_PATH="local:vztmpl/$TEMPLATE"
|
|
|
|
# 4. Create persistent host directories if not present
|
|
echo "[*] Preparing host persistent backup storage at: $HOST_BACKUP_STORAGE..."
|
|
mkdir -p "$HOST_BACKUP_STORAGE/backups"
|
|
mkdir -p "$HOST_BACKUP_STORAGE/temp"
|
|
chmod 775 "$HOST_BACKUP_STORAGE/backups"
|
|
chmod 777 "$HOST_BACKUP_STORAGE/temp"
|
|
|
|
# 5. Create native LXC Container
|
|
echo "[*] Creating LXC container CT $CT_ID ($HOSTNAME)..."
|
|
pct create "$CT_ID" "$TEMPLATE_PATH" \
|
|
--hostname "$HOSTNAME" \
|
|
--memory "$MEMORY" \
|
|
--swap "$SWAP" \
|
|
--cores "$CORES" \
|
|
--ostype debian \
|
|
--storage "$STORAGE_POOL" \
|
|
--rootfs "$STORAGE_POOL:$DISK_SIZE" \
|
|
--net0 "name=eth0,bridge=$BRIDGE,ip=$IP_CONFIG" \
|
|
--unprivileged 1 \
|
|
--onboot 1 \
|
|
--start 0
|
|
|
|
# 6. Mount persistent storage volumes directly to the LXC
|
|
echo "[*] Mounting host persistent storage pool into CT $CT_ID..."
|
|
pct set "$CT_ID" -mp0 "$HOST_BACKUP_STORAGE/backups,mp=/storage/backups"
|
|
pct set "$CT_ID" -mp1 "$HOST_BACKUP_STORAGE/temp,mp=/storage/temp"
|
|
|
|
# 7. Start container
|
|
echo "[*] Starting CT $CT_ID..."
|
|
pct start "$CT_ID"
|
|
|
|
echo ""
|
|
echo "========================================================================"
|
|
echo "[+] Container CT $CT_ID ($HOSTNAME) successfully created and started!"
|
|
echo "========================================================================"
|
|
echo ""
|
|
echo "Next step: Enter container and run the Debian native installer:"
|
|
echo " pct enter $CT_ID"
|
|
echo " git clone <REPO_URL> /opt/onever_drive"
|
|
echo " bash /opt/onever_drive/deployment/proxmox/02-install-backend-debian.sh"
|
|
echo ""
|