Update vmcreate1.sh

This commit is contained in:
2025-10-26 13:18:39 +00:00
parent 9956e30353
commit 06dbc4d50e

View File

@@ -109,7 +109,12 @@ if [[ $# -ne 0 ]]; then
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -n "$arg " >> ./hosts.tmp echo -n "$arg " >> ./hosts.tmp
echo -n "vm" >> ./hosts.tmp echo -n "vm" >> ./hosts.tmp
printf "%03d\n" "$(echo -n $arg | cut -d '.' -f 3)" >> ./hosts.tmp vlan=$(echo -n $arg | cut -d '.' -f 3)
if [[ $vlan -eq 0 ]]; then
echo -n "100" >> ./hosts.tmp
else
printf "%02d\n" "$vlan" >> ./hosts.tmp
fi
printf "%03d\n" "$(echo -n $arg | cut -d '.' -f 4)" >> ./hosts.tmp printf "%03d\n" "$(echo -n $arg | cut -d '.' -f 4)" >> ./hosts.tmp
echo >> hosts.tmp echo >> hosts.tmp
else else
@@ -149,6 +154,20 @@ hostcheck (){
fi fi
} }
#Функция создания VMID, аргумент - IPv4 адрес.
get_vmid(){
local vlan=$(echo -n $arg | cut -d '.' -f 3)
local oct4=$(echo -n $arg | cut -d '.' -f 4)
local vmid=""
if [[ $vlan -eq 0 ]]; then
vmid=100
else
vmid=$(printf "%02d\n" "$vlan")
fi
vmid+=$(printf "%03d\n" "$oct4")
echo -n $vmid
}
# Проверяем ключ # Проверяем ключ
if [ -v pubkey ]; then if [ -v pubkey ]; then
if [[ ! -f pubkey ]]; then if [[ ! -f pubkey ]]; then