create_pve-mgnt-lxc_v2.sh gelöscht
This commit is contained in:
@@ -1,111 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# =====================================================
|
|
||||||
# Proxmox VE: Debian 13 LXC automatisch erstellen
|
|
||||||
# =====================================================
|
|
||||||
|
|
||||||
# Root-Check
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
dialog --msgbox "Bitte als Root ausführen!" 8 40
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Root-Passwort abfragen
|
|
||||||
ROOTPASS=$(dialog --title "Root Passwort" --passwordbox "Root-Passwort für LXC:" 8 40 3>&1 1>&2 2>&3 3>&-)
|
|
||||||
clear
|
|
||||||
|
|
||||||
# Hostname & VMID
|
|
||||||
HOSTNAME="$(hostname)-MGNT"
|
|
||||||
VMID=300
|
|
||||||
while pct status $VMID &>/dev/null; do ((VMID++)); done
|
|
||||||
|
|
||||||
dialog --msgbox "Hostname: $HOSTNAME\nNächste freie VMID: $VMID" 10 50
|
|
||||||
|
|
||||||
# Storage Auswahl
|
|
||||||
mapfile -t STORAGES < <(pvesm status --content rootdir | awk 'NR>1 {print $1}')
|
|
||||||
STORAGE_CHOICES=()
|
|
||||||
for i in "${!STORAGES[@]}"; do
|
|
||||||
STORAGE_CHOICES+=("$i" "${STORAGES[$i]}" "off")
|
|
||||||
done
|
|
||||||
|
|
||||||
STORAGE_INDEX=$(dialog --title "Storage Auswahl" --radiolist \
|
|
||||||
"Welcher Storage für RootFS?" 15 50 5 \
|
|
||||||
"${STORAGE_CHOICES[@]}" 3>&1 1>&2 2>&3 3>&-)
|
|
||||||
STORAGE="${STORAGES[$STORAGE_INDEX]}"
|
|
||||||
clear
|
|
||||||
|
|
||||||
# Bridge Auswahl
|
|
||||||
mapfile -t BRIDGES < <(grep -Po '^auto \K.*' /etc/network/interfaces)
|
|
||||||
BRIDGE_CHOICES=()
|
|
||||||
for i in "${!BRIDGES[@]}"; do
|
|
||||||
BRIDGE_CHOICES+=("$i" "${BRIDGES[$i]}" "off")
|
|
||||||
done
|
|
||||||
|
|
||||||
BRIDGE_INDEX=$(dialog --title "Bridge Auswahl" --radiolist \
|
|
||||||
"Welche Bridge soll der LXC nutzen?" 15 50 5 \
|
|
||||||
"${BRIDGE_CHOICES[@]}" 3>&1 1>&2 2>&3 3>&-)
|
|
||||||
BRIDGE="${BRIDGES[$BRIDGE_INDEX]}"
|
|
||||||
clear
|
|
||||||
|
|
||||||
# Netzwerk / Ressourcen
|
|
||||||
IP="10.60.10.2/24"
|
|
||||||
GATEWAY="10.60.10.1"
|
|
||||||
CORES=1
|
|
||||||
MEMORY=512
|
|
||||||
SWAP=0
|
|
||||||
ROOTFS_SIZE=8
|
|
||||||
|
|
||||||
# Template
|
|
||||||
dialog --infobox "Suche aktuelles Debian 13 Template..." 5 50
|
|
||||||
pveam update
|
|
||||||
TEMPLATE_NAME=$(pveam available | awk '/debian-13-standard_.*_amd64\.tar\.zst/ {print $2}' | tail -n1)
|
|
||||||
if [[ -z "$TEMPLATE_NAME" ]]; then
|
|
||||||
dialog --msgbox "Kein Debian 13 Template gefunden!" 8 50
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE_NAME"
|
|
||||||
if [[ ! -f "$TEMPLATE_PATH" ]]; then
|
|
||||||
dialog --title "Template herunterladen" --infobox "Lade $TEMPLATE_NAME..." 5 60
|
|
||||||
pveam download local "$TEMPLATE_NAME" | tee /tmp/lxc_template.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---- LXC erstellen ----
|
|
||||||
dialog --title "LXC erstellen" --infobox "Erstelle unprivilegierten LXC $HOSTNAME..." 5 60
|
|
||||||
CREATE_CMD="pct create $VMID local:vztmpl/$TEMPLATE_NAME \
|
|
||||||
--hostname $HOSTNAME \
|
|
||||||
--cores $CORES \
|
|
||||||
--memory $MEMORY \
|
|
||||||
--swap $SWAP \
|
|
||||||
--rootfs $STORAGE:$ROOTFS_SIZE \
|
|
||||||
--net0 name=eth0,bridge=$BRIDGE,ip=$IP,gw=$GATEWAY,type=veth \
|
|
||||||
--unprivileged 1"
|
|
||||||
|
|
||||||
if [[ -n "$ROOTPASS" ]]; then
|
|
||||||
CREATE_CMD="$CREATE_CMD --password $ROOTPASS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Direkt ausführen + Output ins Dialog-Fenster
|
|
||||||
$CREATE_CMD 2>&1 | dialog --title "LXC erstellen (VMID $VMID)" --progressbox 20 80
|
|
||||||
|
|
||||||
# WebUI-Konsole
|
|
||||||
CONF_FILE="/etc/pve/lxc/$VMID.conf"
|
|
||||||
echo "lxc.tty.max = 2" >> "$CONF_FILE"
|
|
||||||
echo "lxc.pty.max = 2" >> "$CONF_FILE"
|
|
||||||
echo "features: nesting=1,keyctl=1" >> "$CONF_FILE"
|
|
||||||
|
|
||||||
# Autostart aktivieren
|
|
||||||
pct set $VMID --onboot 1 2>&1 | dialog --title "Autostart setzen" --progressbox 10 60
|
|
||||||
|
|
||||||
# Container starten
|
|
||||||
pct start $VMID 2>&1 | dialog --title "LXC starten" --progressbox 15 60
|
|
||||||
|
|
||||||
# Software installieren
|
|
||||||
pct exec $VMID -- bash -c "
|
|
||||||
apt update &&
|
|
||||||
apt install -y curl sudo &&
|
|
||||||
curl -fsSL https://gitea.vmd55888.de/manuel.maier/update-install-newt/raw/branch/main/install_newt_v2.sh -o install_newt_v2.sh &&
|
|
||||||
bash ./install_newt_v2.sh --install
|
|
||||||
" 2>&1 | dialog --title "Software installieren" --progressbox 20 80
|
|
||||||
|
|
||||||
dialog --msgbox "✔ LXC $HOSTNAME (VMID $VMID) erstellt, gestartet und Autostart aktiviert!" 8 60
|
|
||||||
clear
|
|
||||||
Reference in New Issue
Block a user