The script's first command was `sudo apt-get update` under `set -euo
pipefail`. On a system with a broken InfluxData repo, that command exits
100, so the script aborted at line 7 and never reached the InfluxData key
repair further down. The repair code could not run on exactly the systems
it existed to fix.
- Reorder: fetch and install keys before the first apt-get update.
- Drop -e so a failed update cannot abort key repair.
- Verify the fetched key's fingerprint before installing it; a mismatch is
no longer installed after a warning.
- Reuse an existing keyring only if it contains the correct fingerprint;
delete a stale/wrong keyring so it is refetched.
- Remove the [trusted=yes] fallback, which silently disabled signature
verification. If no verifiable key is available, disable the repo
instead.
- Detect VERSION_CODENAME for the Sury source instead of hardcoding
bookworm, so trixie hosts get a valid suite.
- Fail loudly with the apt error if update still fails after repair.