Update build_nat_network.sh

This commit is contained in:
spiritlhl 2023-06-12 23:49:23 +08:00 committed by GitHub
parent 66e4287912
commit 69c807e164
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,16 +52,17 @@ fi
if [ -f /etc/network/interfaces ]; then if [ -f /etc/network/interfaces ]; then
cp /etc/network/interfaces /etc/network/interfaces.bak cp /etc/network/interfaces /etc/network/interfaces.bak
fi fi
interfaces_file="" interfaces_file="/etc/network/interfaces"
if [ -f /etc/network/interfaces.d/50-cloud-init ] && [ -f /etc/network/interfaces ]; then
if grep -q "source /etc/network/interfaces.d/*" /etc/network/interfaces; then
interfaces_file="/etc/network/interfaces.d/50-cloud-init"
fi
fi
if [ -z "$interfaces_file" ]; then
interfaces_file="/etc/network/interfaces"
fi
chattr -i "$interfaces_file" chattr -i "$interfaces_file"
# if ! grep -q "auto lo" "$interfaces_file"; then
# echo "auto lo" >> "$interfaces_file"
# fi
# if ! grep -q "iface lo inet loopback" "$interfaces_file"; then
# echo "iface lo inet loopback" >> "$interfaces_file"
# fi
if ! grep -q "iface ${interface} inet manual" "$interfaces_file"; then
echo "iface ${interface} inet manual" >> "$interfaces_file"
fi
if grep -q "vmbr0" "$interfaces_file"; then if grep -q "vmbr0" "$interfaces_file"; then
echo "vmbr0 已存在在 ${interfaces_file}" echo "vmbr0 已存在在 ${interfaces_file}"
else else