Switch and upgrade:
### 1. Remove the enterprise repos (401 without a subscription key)
### and any old-style .list files, so nothing conflicts.
rm -f /etc/apt/sources.list.d/pve-enterprise.list \
/etc/apt/sources.list.d/pve-enterprise.sources \
/etc/apt/sources.list.d/ceph.list \
/etc/apt/sources.list.d/ceph.sources \
/etc/apt/sources.list.d/pve-no-subscription.list
### 2. Add the free repos in deb822 format (the PVE 9 standard).
### Signed-By pins each repo to the Proxmox key instead of trusting
### every key in the global keyring.
cat > /etc/apt/sources.list.d/proxmox.sources <<'EOF'
Types: deb
URIs: http://download.proxmox.com/debian/pve
Suites: trixie
Components: pve-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
### 3. Same for Ceph. Drop this file if you do not use Ceph at all.
cat > /etc/apt/sources.list.d/ceph.sources <<'EOF'
Types: deb
URIs: http://download.proxmox.com/debian/ceph-squid
Suites: trixie
Components: no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
### 4. No debconf wizards, no prompts. See explanation above.
export DEBIAN_FRONTEND=noninteractive
APTOPTS='-y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold'
### 5. Wipe the package cache. This throws away the corrupt
### pve-firmware .deb that killed the previous run, forcing a fresh download.
apt-get clean
### 6. Refresh package lists from the new repos.
apt-get update
### 7. Finish the half-applied upgrade: configure everything that was
### unpacked but never configured when dpkg aborted.
apt-get $APTOPTS --fix-broken install
### 8. The actual upgrade. dist-upgrade (not upgrade) because PVE
### upgrades routinely add and remove packages, e.g. new kernel versions.
apt-get $APTOPTS dist-upgrade
### 9. Safety net: configure anything still left unconfigured.
dpkg --configure -a
### 10. Show the resulting versions so you can confirm it worked.
pveversion -v
Remove nag:
F=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
cp -n "$F" "$F.orig"
sed -Ei 's/(checked_command: *function *\(orig_cmd\) *\{)/\1 orig_cmd(); return;/' "$F"
if [ "$(grep -c 'orig_cmd(); return;' "$F")" != "1" ]; then
echo "PATCH FAILED - pattern not found"; grep -n 'checked_command' "$F"
else
cat > /etc/apt/apt.conf.d/no-nag-script <<'EOF'
DPkg::Post-Invoke { "dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ $? -eq 1 ]; then sed -Ei 's/(checked_command: *function *\\(orig_cmd\\) *\\{)/\\1 orig_cmd(); return;/' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; fi"; };
EOF
systemctl restart pveproxy
echo "patched + apt hook installed"
fi