From 69c807e1642faac94ccce7d81941ffd599869742 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Mon, 12 Jun 2023 23:49:23 +0800 Subject: [PATCH] Update build_nat_network.sh --- scripts/build_nat_network.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/build_nat_network.sh b/scripts/build_nat_network.sh index ced9134..1d5a44c 100644 --- a/scripts/build_nat_network.sh +++ b/scripts/build_nat_network.sh @@ -52,16 +52,17 @@ fi if [ -f /etc/network/interfaces ]; then cp /etc/network/interfaces /etc/network/interfaces.bak fi -interfaces_file="" -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 +interfaces_file="/etc/network/interfaces" 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 echo "vmbr0 已存在在 ${interfaces_file}" else