Update vmcreate1.sh

This commit is contained in:
2025-10-26 15:53:06 +00:00
parent 65762f7332
commit e209da172e

View File

@@ -156,8 +156,8 @@ if [[ $# -eq 0 && -e "$file" ]]; then
cat "$file" cat "$file"
for line in $(cat "$file"); do for line in $(cat "$file"); do
echo "DEBUG line:$line" echo "DEBUG line:$line"
ip=$(echo -n $line | cut -d ' ' -f 1) ip=$(echo -n $line | cut -d ';' -f 1)
hostname=$(echo -n $line | cut -d ' ' -f 2) hostname=$(echo -n $line | cut -d ';' -f 2)
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
hostcheck "$hostname" hostcheck "$hostname"
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@@ -182,7 +182,7 @@ if [[ $# -ne 0 ]]; then
for arg in "$@"; do for arg in "$@"; do
ipcheck "$arg" ipcheck "$arg"
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
get_vmid "$arg" >> hosts.tmp get_vmid "$arg" >> hosts.tmp
echo >> hosts.tmp echo >> hosts.tmp
@@ -220,7 +220,7 @@ cat hosts.tmp; echo
for line in $(cat hosts.tmp) for line in $(cat hosts.tmp)
do do
ip=$(echo -n $line | cut -d ' ' -f 1) ip=$(echo -n $line | cut -d ';' -f 1)
vlan=$(echo -n $ip | cut -d '.' -f 3) vlan=$(echo -n $ip | cut -d '.' -f 3)
if [[ $vlan -eq 0 ]]; then if [[ $vlan -eq 0 ]]; then
mask=23 mask=23
@@ -230,7 +230,7 @@ do
mask=24 mask=24
gw="10.10.${vlan}.1" gw="10.10.${vlan}.1"
fi fi
hostname=$(echo -n $line | cut -d ' ' -f 2) hostname=$(echo -n $line | cut -d ';' -f 2)
vmid=$(get_vmid "$ip") vmid=$(get_vmid "$ip")
mksnippet mksnippet
#### DEBUG 2 #### DEBUG 2