This commit is contained in:
spiritlhl 2023-06-23 05:34:27 +00:00
parent f3490293ec
commit 44f6d55774

View file

@ -103,12 +103,6 @@ if [[ -f "/etc/network/interfaces.new" && -f "/etc/network/interfaces" ]]; then
cp -f /etc/network/interfaces.new /etc/network/interfaces
chattr +i /etc/network/interfaces
fi
chattr -i /etc/network/interfaces
sed -i '/source \/etc\/network\/interfaces\.d\/*/{s/^/#/}' "/etc/network/interfaces"
chattr +i /etc/network/interfaces
chattr -i /etc/network/interfaces.new
sed -i '/source \/etc\/network\/interfaces\.d\/*/{s/^/#/}' "/etc/network/interfaces.new"
chattr +i /etc/network/interfaces.new
# 合并文件
if [[ -f "/etc/network/interfaces.d/50-cloud-init" && -f "/etc/network/interfaces" ]]; then
if [[ ! -f "/etc/network/interfaces" ]]; then
@ -119,6 +113,23 @@ if [[ -f "/etc/network/interfaces.d/50-cloud-init" && -f "/etc/network/interface
rm /etc/network/interfaces.d/50-cloud-init
chattr +i /etc/network/interfaces
fi
# 去除引用
if [[ -f "/etc/network/interfaces" ]]; then
chattr -i /etc/network/interfaces
sed -i '/source \/etc\/network\/interfaces\.d\/*/{s/^/#/}' "/etc/network/interfaces"
chattr +i /etc/network/interfaces
fi
if [[ -f "/etc/network/interfaces.new" ]]; then
chattr -i /etc/network/interfaces.new
sed -i '/source \/etc\/network\/interfaces\.d\/*/{s/^/#/}' "/etc/network/interfaces.new"
chattr +i /etc/network/interfaces.new
fi
# 反加载
if [[ -f "/etc/network/interfaces.new" && -f "/etc/network/interfaces" ]]; then
chattr -i /etc/network/interfaces
cp -f /etc/network/interfaces /etc/network/interfaces.new
chattr +i /etc/network/interfaces
fi
# 允许手动配置
# if ! grep -q "iface ${interface} inet manual" "/etc/network/interfaces"; then
# chattr -i /etc/network/interfaces