mirror of
https://github.com/oneclickvirt/pve.git
synced 2024-09-20 23:15:56 +08:00
Update buildvm_extraip.sh
This commit is contained in:
parent
955f225545
commit
b8e2d37273
|
@ -137,13 +137,18 @@ for ip in "${ip_list[@]}"; do
|
|||
fi
|
||||
done
|
||||
# 宿主机的网关
|
||||
gateway=$(grep -E "iface $interface" -A 2 "/etc/network/interfaces" | grep "gateway" | awk '{print $2}')
|
||||
gateway=$(grep -E "iface $interface" -A 3 "/etc/network/interfaces" | grep "gateway" | awk '{print $2}' | head -n 1)
|
||||
if [ -z "$gateway" ]; then
|
||||
if [ -f /etc/network/interfaces.d/50-cloud-init ]; then
|
||||
gateway=$(grep -E "iface $interface" -A 3 "/etc/network/interfaces.d/50-cloud-init" | grep "gateway" | awk '{print $2}' | head -n 1)
|
||||
fi
|
||||
if [ -z "$gateway" ]; then
|
||||
echo "宿主机网关查询失败"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# echo "ip=${user_ip}/${user_ip_range},gw=${gateway}"
|
||||
# 检查变量是否为空并执行相应操作
|
||||
if [ -z "$gateway" ]; then
|
||||
echo "宿主机网关查询失败"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$user_ip" ]; then
|
||||
echo "可使用的IP列表查询失败"
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue