Update build_backend.sh

This commit is contained in:
spiritLHLS 2023-02-23 21:13:06 +08:00 committed by GitHub
parent 66a178d92e
commit e3970e507e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,51 +13,49 @@ pvesh create /pools --poolid mypool
_green "资源池 mypool 已创建!" _green "资源池 mypool 已创建!"
# 创建网桥 # 创建网桥
#!/bin/bash # # 选择桥接接口的标准
# bridge_interface_pattern="eth*"
# 选择桥接接口的标准 # interfaces=($(ls /sys/class/net))
bridge_interface_pattern="eth*" # for interface in ${interfaces[@]}; do
interfaces=($(ls /sys/class/net)) # if [[ $interface != "lo" ]] && [[ $interface =~ $bridge_interface_pattern ]]; then
for interface in ${interfaces[@]}; do # bridge_ports="$interface"
if [[ $interface != "lo" ]] && [[ $interface =~ $bridge_interface_pattern ]]; then # break
bridge_ports="$interface" # fi
break # done
fi # if [[ -z $bridge_ports ]]; then
done # echo "错误:找不到可用网络接口"
if [[ -z $bridge_ports ]]; then # exit 1
echo "错误:找不到可用网络接口" # fi
exit 1 # ipv4_address="192.168.1.1"
fi # ipv4_netmask="255.255.255.0"
ipv4_address="192.168.1.1" # ipv6_address=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $2;exit}' | cut -d'/' -f1)
ipv4_netmask="255.255.255.0" # ipv6_netmask=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $4;exit}' | cut -d'/' -f1)
ipv6_address=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $2;exit}' | cut -d'/' -f1) # cat <<EOF > /etc/network/interfaces.d/vmbr1.cfg
ipv6_netmask=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $4;exit}' | cut -d'/' -f1) # auto vmbr1
cat <<EOF > /etc/network/interfaces.d/vmbr1.cfg # iface vmbr1 inet static
auto vmbr1 # address $ipv4_address
iface vmbr1 inet static # netmask $ipv4_netmask
address $ipv4_address # bridge_ports $bridge_ports
netmask $ipv4_netmask # bridge_stp off
bridge_ports $bridge_ports # bridge_fd 0
bridge_stp off # iface vmbr1 inet6 static
bridge_fd 0 # address $ipv6_address
iface vmbr1 inet6 static # netmask $ipv6_netmask
address $ipv6_address # EOF
netmask $ipv6_netmask # if grep -q "iface vmbr1" /etc/network/interfaces; then
EOF # echo "网桥 vmbr1 已经在 Proxmox VE 配置中"
if grep -q "iface vmbr1" /etc/network/interfaces; then # else
echo "网桥 vmbr1 已经在 Proxmox VE 配置中" # # 添加到配置文件
else # cat <<EOF >> /etc/network/interfaces
# 添加到配置文件 # # Proxmox VE bridge vmbr1
cat <<EOF >> /etc/network/interfaces # iface vmbr1 inet manual
# Proxmox VE bridge vmbr1 # bridge-ports $bridge_ports
iface vmbr1 inet manual # bridge-stp off
bridge-ports $bridge_ports # bridge-fd 0
bridge-stp off # EOF
bridge-fd 0 # fi
EOF # systemctl restart networking.service
fi # echo "网桥 vmbr1 已创建!"
systemctl restart networking.service
echo "网桥 vmbr1 已创建!"
# 检测AppArmor模块 # 检测AppArmor模块
if ! dpkg -s apparmor > /dev/null 2>&1; then if ! dpkg -s apparmor > /dev/null 2>&1; then