Update create_vm.sh

This commit is contained in:
spiritLHLS 2023-05-20 10:09:23 +08:00 committed by GitHub
parent 37a12449eb
commit 1e60f2ccab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,6 +88,7 @@ check_info(){
port_start="${last_line_array[9]}"
port_end="${last_line_array[10]}"
system="${last_line_array[11]}"
storage="${last_line_array[12]}"
_green "当前最后一个NAT服务器对应的信息"
echo "NAT服务器: $vm_num"
# echo "用户名: $user"
@ -97,6 +98,7 @@ check_info(){
echo "外网443端口: $web2_port"
echo "外网其他端口范围: $port_start-$port_end"
echo "系统:$system"
echo "存储盘:$storage"
fi
}
@ -125,6 +127,19 @@ build_new_vms(){
_yellow "输入无效,请输入一个正整数。"
fi
done
while true; do
reading "虚拟机们开设在哪个存储盘上?(若虚拟机要开设在系统盘上则留空或输入local)" storage
if [ -z "$storage" ]; then
storage="local"
fi
output=$(pvesm list | grep "$storage")
if [ -n "$output" ]; then
echo "存储盘 '$storage' 存在于Proxmox VE中。"
break
else
echo "存储盘 '$storage' 不存在于Proxmox VE中请重新输入"
fi
done
while true; do
reading "每个虚拟机分配多少硬盘?(若每个虚拟机分配5G硬盘则输入5)" disk_nums
if [[ "$disk_nums" =~ ^[1-9][0-9]*$ ]]; then
@ -143,7 +158,7 @@ build_new_vms(){
web2_port=$(($web1_port + 1))
port_start=$(($port_end + 1))
port_end=$(($port_start + 25))
./buildvm.sh $vm_num $user $password $cpu_nums $memory_nums $disk_nums $ssh_port $web1_port $web2_port $port_start $port_end debian10
./buildvm.sh $vm_num $user $password $cpu_nums $memory_nums $disk_nums $ssh_port $web1_port $web2_port $port_start $port_end debian10 $storage
cat "vm$vm_num" >> vmlog
rm -rf "vm$vm_num"
sleep 60