proxmox:ct_op_basis_van_csv
This is an old revision of the document!
titel
context
dit document toont een (ChatGPT) script waarbij je containers cloont op basis van
- een template (ID:2000)
- een .CSV bestand:
- VLANID
script
#!/bin/bash
# Template/container ID to clone
TEMPLATE_ID=2000
# CSV file path
CSV_FILE="vlans.csv"
# Prefix to add to VLAN IDs below 100
VMID_PREFIX=1
# Loop through CSV, skip header
tail -n +2 "$CSV_FILE" | while IFS=',' read -r vlanID vlanname; do
# Ensure VMID is >= 100
if [ "$vlanID" -lt 100 ]; then
VMID="${VMID_PREFIX}${vlanID}"
else
VMID="$vlanID"
fi
echo "Cloning container from template $TEMPLATE_ID with new VMID $VMID and hostname $vlanname"
# Clone the container
pct clone "$TEMPLATE_ID" "$VMID" --hostname "$vlanname" --full 1
# Configure network after cloning
pct set "$VMID" --net0 name=eth0,bridge=vmbr0,tag="$vlanID",ip=dhcp
# Start the container
pct start "$VMID"
echo "Container $VMID ($vlanname) cloned and started successfully."
done
meer info
voeg hier linken toe naar verdere uitleg
proxmox/ct_op_basis_van_csv.1763913526.txt.gz · Last modified: by admin

