mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-03-04 01:38:12 +08:00
Update build_nat_network.sh
This commit is contained in:
parent
e994c965e7
commit
5a8937d98d
1 changed files with 9 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#from https://github.com/spiritLHLS/pve
|
||||
# 2023.06.13
|
||||
# 2023.06.21
|
||||
|
||||
# 打印信息
|
||||
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
|
||||
|
@ -25,6 +25,7 @@ if ! command -v lshw > /dev/null 2>&1; then
|
|||
fi
|
||||
# 提取物理网卡名字
|
||||
interface=$(lshw -C network | awk '/logical name:/{print $3}' | head -1)
|
||||
interface_2=$(lshw -C network | awk '/logical name:/{print $3}' | sed -n '2p')
|
||||
if [ -z "$interface" ]; then
|
||||
interface="eth0"
|
||||
fi
|
||||
|
@ -65,10 +66,14 @@ if ! grep -q "iface lo inet loopback" "$interfaces_file"; then
|
|||
exit 1
|
||||
fi
|
||||
if ! grep -q "iface ${interface} inet manual" "$interfaces_file"; then
|
||||
if grep -q "iface ${interface_2} inet manual" "$interfaces_file"; then
|
||||
interface=${interface_2}
|
||||
else
|
||||
# echo "iface ${interface} inet manual" >> "$interfaces_file"
|
||||
echo "Can not find 'iface ${interface} inet manual' in ${interfaces_file}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if grep -q "vmbr0" "$interfaces_file"; then
|
||||
echo "vmbr0 已存在在 ${interfaces_file}"
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue