Update vmcreate1.sh

This commit is contained in:
2025-10-26 18:29:55 +00:00
parent ce60818de1
commit 2f6de5abf7

View File

@@ -100,7 +100,7 @@ mksnippet(){
} }
# Обрабатываем опции # Обрабатываем опции
while getopts "a:f:hk:u:p:d:t" opt; do while getopts "a:f:hk:u:p:d:t:" opt; do
case $opt in case $opt in
a) harule="$OPTARG";; a) harule="$OPTARG";;
f) file="$OPTARG" ;; f) file="$OPTARG" ;;
@@ -109,7 +109,7 @@ while getopts "a:f:hk:u:p:d:t" opt; do
u) username="$OPTARG";; u) username="$OPTARG";;
p) password="$OPTARG";; p) password="$OPTARG";;
d) size="$OPTARG";; d) size="$OPTARG";;
t) tag="$OPTARG";; t) tag=,"$OPTARG";;
*) echo "Invalid option. Use '-h' for help."; exit 1;; *) echo "Invalid option. Use '-h' for help."; exit 1;;
esac esac
done done
@@ -223,7 +223,7 @@ 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= snippet=
if [[ (qm status "$vmid") ]]; then if qm status "$vmid"; then
echo "VM $vmid exists. Aborting" echo "VM $vmid exists. Aborting"
exit 9 exit 9
elif [[ -e "$snippet" ]]; then elif [[ -e "$snippet" ]]; then
@@ -272,7 +272,7 @@ do
echo "ERROR" echo "ERROR"
exit 8 exit 8
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/${vmnum}_user.yaml" qm set $vmid --cicustom "user=${storage}:snippets/${vmnum}_user.yaml"
qm set $vmid --ipconfig0 ip="$ip"/"$mask",gw="$gw" qm set $vmid --ipconfig0 ip="$ip"/"$mask",gw="$gw"