From f36af5af6452cd04b1f19c686574acd27258dc51 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Wed, 6 Aug 2025 22:37:13 +0200 Subject: [PATCH] Update update-pve.sh --- scripts/global/update-pve.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/global/update-pve.sh b/scripts/global/update-pve.sh index d0ca7b1..57323c3 100644 --- a/scripts/global/update-pve.sh +++ b/scripts/global/update-pve.sh @@ -72,14 +72,27 @@ update_pve9() { fi - disable_sources_repo() { - local file="$1" - if [[ -f "$file" ]] && grep -q "^Enabled: *true" "$file"; then - sed -i 's/^Enabled: *true/Enabled: false/' "$file" - return 0 +disable_sources_repo() { + local file="$1" + if [[ -f "$file" ]]; then + sed -i ':a;/^\n*$/{$d;N;ba}' "$file" + + if grep -q "^Enabled:" "$file"; then + sed -i 's/^Enabled:.*$/Enabled: false/' "$file" + else + echo "Enabled: false" >> "$file" fi - return 1 - } + + if ! grep -q "^Types: " "$file"; then + msg_warn "$(translate "Malformed .sources file detected, removing: $(basename "$file")")" + rm -f "$file" + fi + return 0 + fi + return 1 +} + + if disable_sources_repo "/etc/apt/sources.list.d/pve-enterprise.sources"; then @@ -93,6 +106,7 @@ update_pve9() { fi + [ -f /etc/apt/sources.list.d/pve-public-repo.list ] && rm -f /etc/apt/sources.list.d/pve-public-repo.list [ -f /etc/apt/sources.list.d/pve-install-repo.list ] && rm -f /etc/apt/sources.list.d/pve-install-repo.list