Files
pve-pbs-setup/create_pve-mgnt-lxc.sh

82 lines
2.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
### === Konfiguration ===
CTID=301
HOSTNAME="debian-lxc"
TEMPLATE_STORAGE="local"
TEMPLATE_NAME="debian-13-standard_13.1-2_amd64.tar.zst"
ROOTFS_STORAGE="local-lvm"
ROOTFS_SIZE="4G"
BRIDGE="xx_vmbrmgt"
IP_ADDR="10.60.10.2/24"
GATEWAY="10.60.10.1"
CORES=1
MEMORY=512
SWAP=0
### === Checks ===
if ! command -v pct &>/dev/null; then
echo "❌ pct nicht gefunden läuft das Script auf einem Proxmox Host?"
exit 1
fi
### === Template prüfen ===
if [ ! -f "/var/lib/vz/template/cache/${TEMPLATE_NAME}" ]; then
echo "❌ Template ${TEMPLATE_NAME} nicht gefunden!"
echo "👉 Bitte vorher herunterladen:"
echo " pveam download ${TEMPLATE_STORAGE} ${TEMPLATE_NAME}"
exit 1
fi
### === LXC erstellen ===
echo "🚀 Erstelle unprivilegierten LXC ${CTID}..."
pct create ${CTID} \
${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE_NAME} \
--hostname ${HOSTNAME} \
--cores ${CORES} \
--memory ${MEMORY} \
--swap ${SWAP} \
--rootfs ${ROOTFS_STORAGE}:${ROOTFS_SIZE} \
--net0 name=eth0,bridge=${BRIDGE},ip=${IP_ADDR},gw=${GATEWAY} \
--unprivileged 1 \
--features nesting=1 \
--onboot 1 \
--tty 2 \
--pty 1 \
--ostype debian \
--start 0
if [ $? -ne 0 ]; then
echo "❌ Fehler beim Erstellen des LXCs"
exit 1
fi
### === LXC starten ===
echo "▶️ Starte LXC..."
pct start ${CTID}
### === Warten bis Container läuft ===
echo "⏳ Warte auf LXC..."
sleep 5
### === Pakete im LXC installieren ===
echo "📦 Installiere Pakete im LXC..."
pct exec ${CTID} -- bash -c "
apt update &&
apt upgrade -y &&
apt install -y curl sudo
"
### === Newt Installer ausführen ===
echo "🧩 Installiere NEWT Client..."
pct exec ${CTID} -- bash -c "
curl -fsSL https://gitea.vmd55888.de/manuel.maier/update-install-newt/raw/branch/main/install_newt_v2.sh -o install_newt_v2.sh &&
chmod +x install_newt_v2.sh &&
bash ./install_newt_v2.sh --install
"
echo "✅ Fertig! LXC ${CTID} läuft, Autostart aktiv, Console funktioniert 🎉"