Files
unraid-podman/plugin/sbin/podman-uninstall-cleanup.sh
maggesandClaude Sonnet 5 e2fefcdf9c
Build Packages / Build .txz packages (push) Failing after 9s
Lint / ShellCheck (push) Failing after 43s
Lint / Validate .plg XML (push) Successful in 10s
Lint / EditorConfig (push) Failing after 6s
Add reproducible build system, native Unraid plugin, and WebUI
- versions.env pins podman, conmon, crun, netavark, aardvark-dns, passt,
  and fuse-overlayfs to verified upstream source checksums; SlackBuild
  recipes, scripts/build-packages.sh, checksums.sh, release.sh, and
  update-versions.sh implement the reproducible pipeline; GitHub Actions
  workflows build in a Slackware container and publish releases without
  committing any binaries.

- plugin/podman.plg installs/updates/removes all eight packages (the
  seven components plus the plugin's own unraid-podman scaffolding
  package) via upgradepkg, using the official Unraid array-event hook
  mechanism (event/disks_mounted, event/stopping) instead of editing
  /boot/config/go. rc.podman and the sbin/ helper scripts implement
  storage creation, config seeding/sync, preflight checks, autostart
  with per-container Safe-Mode, and package verify/update/rollback.

- webui/plugins/podman implements the Dashboard, Containers, Pods,
  Images, Volumes, Networks, Logs, Terminal, Compose, and Settings
  panels against the approved mockup (webui/mockups/prototype.html),
  talking to podman system service exclusively via PodmanClient.php
  (libpod REST API over the Unix socket), with two documented
  exceptions: Terminal's one-shot exec model and Compose's use of the
  podman compose CLI, since libpod has no REST equivalent for either.

- docs/ARCHITECTURE.md and docs/ROADMAP.md record the design decisions
  and honest current status (syntax-checked, unit- and
  integration-tested against fake sockets/servers; not yet run against
  a real Unraid/Podman/Slackware system).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-11 10:51:14 +00:00

95 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# plugin/sbin/podman-uninstall-cleanup.sh
#
# "Beim Entfernen sauber aufräumen" — run by plugin/podman.plg's <FILE
# Run="removepkg"> block when the plugin is uninstalled via Unraid's Plugins
# page. Two-tier cleanup, matching docs/ARCHITECTURE.md section 3.2 /
# section 17:
#
# ALWAYS removed (installed software, safe to regenerate):
# - running containers/service stopped cleanly
# - runtime config under /etc/containers, /var/run/podman
# - staged helper scripts, templates, WebUI files, event hooks
#
# NOT applicable: this project has no /boot/config/go entry to clean up
# in the first place — it hooks the official Unraid plugin event
# mechanism (/usr/local/emhttp/plugins/podman/event/*, see
# plugin/event/disks_mounted's header comment) instead of editing go,
# so removepkg-ing the unraid-podman package (done by podman.plg right
# after this script runs) already removes those hooks along with
# everything else under /usr/local/emhttp/plugins/podman/.
#
# PRESERVED BY DEFAULT (user data — see docs/INSTALL.md "Uninstallation"):
# - /boot/config/plugins/podman/ (settings, autostart list, backups)
# - $STORAGE_PATH (podman.img — every image/container/volume the user
# has)
#
# Full data removal is opt-in only, via:
# podman-uninstall-cleanup.sh --purge-data
# never the default, and never triggered automatically — deleting a user's
# containers/images without an explicit, separate confirmation is exactly
# the kind of destructive-by-surprise behavior this project avoids (see
# docs/ARCHITECTURE.md "Nicht-Ziele" around data safety).
# =============================================================================
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./podman-common.sh
. "$SCRIPT_DIR/podman-common.sh"
PURGE_DATA=0
[ "${1:-}" = "--purge-data" ] && PURGE_DATA=1
podman_log "uninstall: starting cleanup (purge-data=$PURGE_DATA)"
# -----------------------------------------------------------------------------
# 1. Stop podman cleanly if it's running, so containers shut down properly
# and the storage loopback is unmounted before we remove anything else.
# -----------------------------------------------------------------------------
if [ -x /etc/rc.d/rc.podman ]; then
podman_log "uninstall: stopping podman"
/etc/rc.d/rc.podman stop || podman_log_error "uninstall: rc.podman stop reported an error (continuing cleanup anyway)"
fi
# -----------------------------------------------------------------------------
# 2. Remove runtime state (RAM-root anyway, but tidy up now rather than
# waiting for the next reboot to implicitly clear it).
# -----------------------------------------------------------------------------
podman_log "uninstall: removing runtime state"
rm -rf "$PODMAN_ETC_DIR" "$PODMAN_RUN_DIR"
# -----------------------------------------------------------------------------
# 3. Remove staged files this plugin installed outside of package-managed
# paths. This is technically redundant with podman.plg's removepkg of
# the unraid-podman package that immediately follows this script (see
# that package's manifest — it owns exactly these paths), but doing it
# explicitly here too means this script is also safe to run manually as
# a standalone repair tool without relying on removepkg bookkeeping.
# -----------------------------------------------------------------------------
podman_log "uninstall: removing plugin scaffolding"
rm -rf /usr/local/share/unraid-podman
rm -rf /usr/local/emhttp/plugins/podman
rm -f /etc/rc.d/rc.podman
# -----------------------------------------------------------------------------
# 4. User data — preserved unless --purge-data was explicitly passed.
# -----------------------------------------------------------------------------
if [ "$PURGE_DATA" -eq 1 ]; then
podman_load_cfg
podman_log "uninstall: --purge-data given, removing user data"
if [ -n "${STORAGE_PATH:-}" ] && [ -d "$STORAGE_PATH" ]; then
podman_log "uninstall: removing $STORAGE_PATH (images, containers, volumes, logs)"
rm -rf "${STORAGE_PATH:?}"
fi
podman_log "uninstall: removing $PODMAN_BOOT_DIR (settings, autostart, backups)"
rm -rf "${PODMAN_BOOT_DIR:?}"
else
podman_log "uninstall: preserving $PODMAN_BOOT_DIR and podman's storage path (pass --purge-data to remove them too)"
fi
podman_log "uninstall: cleanup complete"