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