Skip to content

Commit 78c8933

Browse files
authored
Disable 'pve-enterprise' and 'ceph enterprise' repositories using 'Enabled: false' instead of commenting out lines; add 'Enabled: false' to new repository entries. (#8399)
1 parent c16e187 commit 78c8933

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

tools/pve/post-pbs-install.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ You normally need a valid subscription for this.
204204
Disable it (recommended)?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
205205
case $CHOICE in
206206
yes)
207-
sed -i '/pbs-enterprise/ s/^/# /' /etc/apt/sources.list.d/pbs-enterprise.sources
207+
msg_info "Disabling 'pbs-enterprise' repository"
208+
# Use Enabled: false instead of commenting to avoid malformed entry
209+
if grep -q "^Enabled:" /etc/apt/sources.list.d/pbs-enterprise.sources 2>/dev/null; then
210+
sed -i 's/^Enabled:.*/Enabled: false/' /etc/apt/sources.list.d/pbs-enterprise.sources
211+
else
212+
echo "Enabled: false" >>/etc/apt/sources.list.d/pbs-enterprise.sources
213+
fi
208214
msg_ok "Disabled 'pbs-enterprise' repository"
209215
;;
210216
no)
@@ -213,11 +219,12 @@ Disable it (recommended)?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
213219
esac
214220
else
215221
cat >/etc/apt/sources.list.d/pbs-enterprise.sources <<EOF
216-
# Types: deb
217-
# URIs: https://enterprise.proxmox.com/debian/pbs
218-
# Suites: trixie
219-
# Components: pbs-enterprise
220-
# Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
222+
Types: deb
223+
URIs: https://enterprise.proxmox.com/debian/pbs
224+
Suites: trixie
225+
Components: pbs-enterprise
226+
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
227+
Enabled: false
221228
EOF
222229
msg_ok "Added 'pbs-enterprise' repository (disabled)"
223230
fi
@@ -239,11 +246,12 @@ EOF
239246
# --- Test repo (pbs-test, renamed) ---
240247
if ! component_exists_in_sources "pbs-test"; then
241248
cat >/etc/apt/sources.list.d/pbs-test.sources <<EOF
242-
# Types: deb
243-
# URIs: http://download.proxmox.com/debian/pbs
244-
# Suites: trixie
245-
# Components: pbs-test
246-
# Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
249+
Types: deb
250+
URIs: http://download.proxmox.com/debian/pbs
251+
Suites: trixie
252+
Components: pbs-test
253+
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
254+
Enabled: false
247255
EOF
248256
msg_ok "Added 'pbs-test' repository (disabled)"
249257
else

tools/pve/post-pve-install.sh

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ start_routines_9() {
197197

198198
# Check sources.list
199199
if [[ -f "$listfile" ]] && grep -qE '^\s*deb ' "$listfile"; then
200-
(( ++LEGACY_COUNT ))
200+
((++LEGACY_COUNT))
201201
fi
202202

203203
# Check .list files
@@ -289,11 +289,15 @@ EOF
289289
msg_ok "Kept 'pve-enterprise' repository"
290290
;;
291291
disable)
292-
msg_info "Disabling (commenting) 'pve-enterprise' repository"
293-
# Comment out every non-comment line in the file that has 'pve-enterprise' in Components
292+
msg_info "Disabling 'pve-enterprise' repository"
293+
# Use Enabled: false instead of commenting to avoid malformed entry
294294
for file in /etc/apt/sources.list.d/*.sources; do
295295
if grep -q "Components:.*pve-enterprise" "$file"; then
296-
sed -i '/^\s*Types:/,/^$/s/^\([^#].*\)$/# \1/' "$file"
296+
if grep -q "^Enabled:" "$file"; then
297+
sed -i 's/^Enabled:.*/Enabled: false/' "$file"
298+
else
299+
echo "Enabled: false" >>"$file"
300+
fi
297301
fi
298302
done
299303
msg_ok "Disabled 'pve-enterprise' repository"
@@ -346,10 +350,15 @@ EOF
346350
msg_ok "Kept 'ceph enterprise' repository"
347351
;;
348352
disable)
349-
msg_info "Disabling (commenting) 'ceph enterprise' repository"
353+
msg_info "Disabling 'ceph enterprise' repository"
354+
# Use Enabled: false instead of commenting to avoid malformed entry
350355
for file in /etc/apt/sources.list.d/*.sources; do
351356
if grep -q "enterprise.proxmox.com.*ceph" "$file"; then
352-
sed -i '/^\s*Types:/,/^$/s/^\([^#].*\)$/# \1/' "$file"
357+
if grep -q "^Enabled:" "$file"; then
358+
sed -i 's/^Enabled:.*/Enabled: false/' "$file"
359+
else
360+
echo "Enabled: false" >>"$file"
361+
fi
353362
fi
354363
done
355364
msg_ok "Disabled 'ceph enterprise' repository"
@@ -472,7 +481,17 @@ EOF
472481
;;
473482
no)
474483
msg_error "Selected no to Adding 'ceph package repositories'"
475-
find /etc/apt/sources.list.d/ -type f \( -name "*.sources" -o -name "*.list" \) \
484+
# Use Enabled: false for .sources files, comment for .list files
485+
for file in /etc/apt/sources.list.d/*.sources; do
486+
if grep -q "enterprise.proxmox.com.*ceph" "$file" 2>/dev/null; then
487+
if grep -q "^Enabled:" "$file"; then
488+
sed -i 's/^Enabled:.*/Enabled: false/' "$file"
489+
else
490+
echo "Enabled: false" >>"$file"
491+
fi
492+
fi
493+
done
494+
find /etc/apt/sources.list.d/ -type f -name "*.list" \
476495
-exec sed -i '/enterprise.proxmox.com.*ceph/s/^/# /' {} \;
477496
msg_ok "Disabled all Ceph Enterprise repositories"
478497
;;
@@ -491,11 +510,12 @@ EOF
491510
yes)
492511
msg_info "Adding 'pve-test' repository (deb822, disabled)"
493512
cat >/etc/apt/sources.list.d/pve-test.sources <<EOF
494-
# Types: deb
495-
# URIs: http://download.proxmox.com/debian/pve
496-
# Suites: trixie
497-
# Components: pve-test
498-
# Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
513+
Types: deb
514+
URIs: http://download.proxmox.com/debian/pve
515+
Suites: trixie
516+
Components: pve-test
517+
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
518+
Enabled: false
499519
EOF
500520
msg_ok "Added 'pve-test' repository"
501521
;;

0 commit comments

Comments
 (0)