Files
unraid-podman/plugin/sbin/podman-verify-packages.sh
maggesandClaude Sonnet 5 2b79411b68 Replace vendored docker-compose with podman-compose
podman-compose and docker-compose aren't discovered the same way by
`podman compose` - verified live (a fake-binary test reading podman's own
provider-search error output) that docker-compose is searched for by
exact path across a fixed list of CLI-plugin directories, while
podman-compose is instead looked up as a plain command on $PATH. This
package installs to /usr/local/bin/podman-compose accordingly, not under
any cli-plugins/ directory.

Unlike docker-compose (a single static Go binary), podman-compose is a
Python script with two runtime dependencies neither of which ship with
Unraid's own Python3 - PyYAML and python-dotenv, vendored here as plain
pure-Python source (no C extension build; PyYAML's own fallback handles
its optional C accelerator being absent).

Verified end-to-end on a real host: with the previous docker-compose
binary temporarily moved aside to confirm podman-compose was actually the
one invoked, `podman compose up/ps/down` ran a real compose project
correctly, including a live HTTP check against the started service.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 18:35:38 +00:00

128 lines
4.9 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# plugin/sbin/podman-verify-packages.sh
#
# "Pakete prüfen" — verifies the eleven packages this plugin ships are
# actually installed, at the version the plugin expects, and that the
# backed-up .txz copies (see podman-backup.sh) haven't bit-rotted on disk.
#
# Three checks per package:
# 1. Installed: Slackware records every installed package under
# /var/log/packages/<name>-<version>-<arch>-<build><tag> — its mere
# existence IS the install record (standard Slackware pkgtools
# convention, nothing custom here).
# 2. Expected version: compared against
# /usr/local/share/unraid-podman/installed-versions.env, written by
# plugin/podman.plg's postinstall step at install/update time.
# 3. Backup integrity: if a backed-up .txz exists for the installed
# version (see podman-backup.sh), its current SHA256 is re-checked
# against the .sha256 sidecar recorded at build time — catches flash
# storage corruption on the backup copy before it's needed for a
# rollback.
#
# Usage:
# podman-verify-packages.sh # human-readable report
# podman-verify-packages.sh --quiet # exit code only, minimal output
#
# Exit code: 0 if everything checks out, 1 if any package has a problem.
# =============================================================================
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./podman-common.sh
. "$SCRIPT_DIR/podman-common.sh"
INSTALLED_VERSIONS_FILE="/usr/local/share/unraid-podman/installed-versions.env"
PACKAGES="podman conmon crun netavark aardvark-dns passt fuse-overlayfs catatonit nftables podman-compose unraid-podman"
QUIET=0
[ "${1:-}" = "--quiet" ] && QUIET=1
report() {
[ "$QUIET" -eq 0 ] && echo "$1"
}
if [ ! -f "$INSTALLED_VERSIONS_FILE" ]; then
podman_log_error "verify: $INSTALLED_VERSIONS_FILE missing — plugin install metadata not found"
exit 1
fi
# shellcheck source=/dev/null
. "$INSTALLED_VERSIONS_FILE"
if [ -z "${PLUGIN_VERSION:-}" ]; then
podman_log_error "verify: PLUGIN_VERSION not recorded in $INSTALLED_VERSIONS_FILE"
exit 1
fi
PROBLEMS=0
for name in $PACKAGES; do
entity_prefix=$(echo "$name" | tr '[:lower:]-' '[:upper:]_')
expected_version_var="${entity_prefix}_INSTALLED_VERSION"
expected_version="${!expected_version_var:-}"
report "== $name =="
if [ -z "$expected_version" ]; then
report " expected version: UNKNOWN (not recorded in $INSTALLED_VERSIONS_FILE)"
PROBLEMS=$((PROBLEMS + 1))
continue
fi
report " expected version: $expected_version"
# --- Check 1: installed -----------------------------------------------
installed_record=$(find /var/log/packages -maxdepth 1 -name "${name}-*" -print 2> /dev/null | head -n1)
if [ -z "$installed_record" ]; then
report " installed: NO"
podman_log_error "verify: $name is not installed (no /var/log/packages/$name-* record)"
PROBLEMS=$((PROBLEMS + 1))
continue
fi
installed_basename=$(basename "$installed_record")
report " installed package: $installed_basename"
# --- Check 2: version matches expectation ------------------------------
case "$installed_basename" in
"${name}-${expected_version}-"*)
report " version match: OK"
;;
*)
report " version match: MISMATCH (installed record does not match expected $expected_version)"
podman_log_error "verify: $name installed record '$installed_basename' does not match expected version $expected_version"
PROBLEMS=$((PROBLEMS + 1))
;;
esac
# --- Check 3: backup artifact integrity, if present --------------------
# Packages of all components released together as one plugin version
# are grouped under a single PLUGIN_VERSION directory (not per-component
# version) — a rollback targets "go back to plugin release X", matching
# podman-backup.sh's restore-packages <plugin-version>.
backup_dir="$PODMAN_BACKUP_DIR/packages/$PLUGIN_VERSION"
backup_txz=$(find "$backup_dir" -maxdepth 1 -name "${name}-*.txz" 2> /dev/null | head -n1)
if [ -n "$backup_txz" ] && [ -f "$backup_txz.sha256" ]; then
if ( cd "$(dirname "$backup_txz")" && sha256sum -c "$(basename "$backup_txz").sha256" > /dev/null 2>&1 ); then
report " backup integrity: OK ($backup_txz)"
else
report " backup integrity: CORRUPT ($backup_txz)"
podman_log_error "verify: backup artifact $backup_txz failed checksum verification"
PROBLEMS=$((PROBLEMS + 1))
fi
else
report " backup integrity: no backup artifact on file (nothing to verify)"
fi
done
report ""
if [ "$PROBLEMS" -gt 0 ]; then
report "$PROBLEMS problem(s) found."
podman_notify "Podman package verification found problems" \
"$PROBLEMS issue(s) found — see $PODMAN_PLUGIN_LOG for details." \
"warning"
exit 1
fi
report "All packages verified OK."
exit 0