Update vmcreate.sh

This commit is contained in:
2025-10-29 10:39:51 +00:00
parent 14c1c7b10d
commit 98fcdf2128

View File

@@ -93,7 +93,7 @@ keypair_generate () {
}
mksnippet () {
snippet="${path}${vmid}_user.yaml"
snippet="${path}${vmid}_${template}"
cp ./user.yaml "$snippet"
sed -i "s/HOSTNAME/$hostname/g" "$snippet"
if [ $username ]; then
@@ -117,7 +117,7 @@ REMOVE () {
do
ip=$(echo -n "$line" | cut -d ';')
vmid=$(get_vmid "$ip")
snippet="${path}${vmid}_user.yaml"
snippet="${path}${vmid}_${template}"
qm stop $vmid
if [ $harule ]; then ha-manager remove vm:${vmid}; fi
qm destroy $vmid --destroy-unreferenced-disks --purge
@@ -269,7 +269,7 @@ for line in $(cat hosts.tmp)
do
ip=$(echo -n "$line" | cut -d ';' -f 1)
vmid=$(get_vmid "$ip")
snippet="${path}${vmid}_user.yaml"
snippet="${path}${vmid}_${template}"
if qm status "$vmid" &>/dev/null; then
echo "VM $vmid exists. Aborting"
exit 7
@@ -307,7 +307,7 @@ do
fi
qm set $vmid --tags "${node}${tag}"
qm resize $vmid scsi0 +"$size"G
qm set $vmid --cicustom "user=${storage}:snippets/${vmid}_user.yaml"
qm set $vmid --cicustom "user=${storage}:snippets/${vmid}_${template}"
qm set $vmid --ipconfig0 ip="$ip"/"$mask",gw="$gw"
sed -i "s|tag=35|tag=$vlan|" /etc/pve/qemu-server/${vmid}.conf || echo "sedDEBUG 4"
# sed -i "s|vmbr0|vmbr1|" /etc/pve/qemu-server/${vmid}.conf