From 48c8dfc66c4f3a32b9bd5baa6faf0271365b41f8 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Wed, 24 May 2023 15:21:19 +0800 Subject: [PATCH] Update install_pve.sh --- scripts/install_pve.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/install_pve.sh b/scripts/install_pve.sh index d35436f..77d6001 100644 --- a/scripts/install_pve.sh +++ b/scripts/install_pve.sh @@ -93,6 +93,16 @@ if [ -f "/etc/cloud/cloud.cfg" ]; then sed -E -i 's/disable_root:[[:space:]]*true/disable_root: false/g' "/etc/cloud/cloud.cfg" echo "change disable_root to false" fi + chattr -i /etc/cloud/cloud.cfg + content=$(cat /etc/cloud/cloud.cfg) + line_number=$(grep -n "^system_info:" "$file" | cut -d ':' -f 1) + if [ -n "$line_number" ]; then + lines_after_system_info=$(echo "$content" | sed -n "$((line_number+1)),\$p") + if [ -n "$lines_after_system_info" ]; then + updated_content=$(echo "$content" | sed "$((line_number+1)),\$d") + echo "$updated_content" > "$file" + fi + fi chattr +i /etc/cloud/cloud.cfg fi }