mirror of
https://github.com/thelittlerocket/pve.git
synced 2024-11-15 19:44:38 +08:00
Update build_backend.sh
This commit is contained in:
parent
66a178d92e
commit
e3970e507e
1 changed files with 43 additions and 45 deletions
|
@ -13,51 +13,49 @@ pvesh create /pools --poolid mypool
|
|||
_green "资源池 mypool 已创建!"
|
||||
|
||||
# 创建网桥
|
||||
#!/bin/bash
|
||||
|
||||
# 选择桥接接口的标准
|
||||
bridge_interface_pattern="eth*"
|
||||
interfaces=($(ls /sys/class/net))
|
||||
for interface in ${interfaces[@]}; do
|
||||
if [[ $interface != "lo" ]] && [[ $interface =~ $bridge_interface_pattern ]]; then
|
||||
bridge_ports="$interface"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z $bridge_ports ]]; then
|
||||
echo "错误:找不到可用网络接口"
|
||||
exit 1
|
||||
fi
|
||||
ipv4_address="192.168.1.1"
|
||||
ipv4_netmask="255.255.255.0"
|
||||
ipv6_address=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $2;exit}' | cut -d'/' -f1)
|
||||
ipv6_netmask=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $4;exit}' | cut -d'/' -f1)
|
||||
cat <<EOF > /etc/network/interfaces.d/vmbr1.cfg
|
||||
auto vmbr1
|
||||
iface vmbr1 inet static
|
||||
address $ipv4_address
|
||||
netmask $ipv4_netmask
|
||||
bridge_ports $bridge_ports
|
||||
bridge_stp off
|
||||
bridge_fd 0
|
||||
iface vmbr1 inet6 static
|
||||
address $ipv6_address
|
||||
netmask $ipv6_netmask
|
||||
EOF
|
||||
if grep -q "iface vmbr1" /etc/network/interfaces; then
|
||||
echo "网桥 vmbr1 已经在 Proxmox VE 配置中"
|
||||
else
|
||||
# 添加到配置文件
|
||||
cat <<EOF >> /etc/network/interfaces
|
||||
# Proxmox VE bridge vmbr1
|
||||
iface vmbr1 inet manual
|
||||
bridge-ports $bridge_ports
|
||||
bridge-stp off
|
||||
bridge-fd 0
|
||||
EOF
|
||||
fi
|
||||
systemctl restart networking.service
|
||||
echo "网桥 vmbr1 已创建!"
|
||||
# # 选择桥接接口的标准
|
||||
# bridge_interface_pattern="eth*"
|
||||
# interfaces=($(ls /sys/class/net))
|
||||
# for interface in ${interfaces[@]}; do
|
||||
# if [[ $interface != "lo" ]] && [[ $interface =~ $bridge_interface_pattern ]]; then
|
||||
# bridge_ports="$interface"
|
||||
# break
|
||||
# fi
|
||||
# done
|
||||
# if [[ -z $bridge_ports ]]; then
|
||||
# echo "错误:找不到可用网络接口"
|
||||
# exit 1
|
||||
# fi
|
||||
# ipv4_address="192.168.1.1"
|
||||
# ipv4_netmask="255.255.255.0"
|
||||
# ipv6_address=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $2;exit}' | cut -d'/' -f1)
|
||||
# ipv6_netmask=$(ip -6 addr show dev $bridge_ports | awk '/inet6/{print $4;exit}' | cut -d'/' -f1)
|
||||
# cat <<EOF > /etc/network/interfaces.d/vmbr1.cfg
|
||||
# auto vmbr1
|
||||
# iface vmbr1 inet static
|
||||
# address $ipv4_address
|
||||
# netmask $ipv4_netmask
|
||||
# bridge_ports $bridge_ports
|
||||
# bridge_stp off
|
||||
# bridge_fd 0
|
||||
# iface vmbr1 inet6 static
|
||||
# address $ipv6_address
|
||||
# netmask $ipv6_netmask
|
||||
# EOF
|
||||
# if grep -q "iface vmbr1" /etc/network/interfaces; then
|
||||
# echo "网桥 vmbr1 已经在 Proxmox VE 配置中"
|
||||
# else
|
||||
# # 添加到配置文件
|
||||
# cat <<EOF >> /etc/network/interfaces
|
||||
# # Proxmox VE bridge vmbr1
|
||||
# iface vmbr1 inet manual
|
||||
# bridge-ports $bridge_ports
|
||||
# bridge-stp off
|
||||
# bridge-fd 0
|
||||
# EOF
|
||||
# fi
|
||||
# systemctl restart networking.service
|
||||
# echo "网桥 vmbr1 已创建!"
|
||||
|
||||
# 检测AppArmor模块
|
||||
if ! dpkg -s apparmor > /dev/null 2>&1; then
|
||||
|
|
Loading…
Reference in a new issue