#!/bin/bash # System Commands Handler # Handles all system subcommands by calling core functions # Reclaim Docker disk space — SAFE scope only: build cache + dangling # (untagged) images. Never prunes volumes (app data) or tagged/in-use images, # so nothing an app relies on is removed. runFileOp targets the correct daemon # (rootless: as the install user with DOCKER_HOST set). reclaimDockerSpace() { isHeader "Reclaiming Docker Space" isNotice "Safe scope: build cache + dangling images only (no volumes, no in-use images)." local cache_out image_out cache_out=$(runFileOp docker builder prune -f 2>&1) checkSuccess "Pruned build cache" echo "$cache_out" | grep -i "Total:" | sed 's/^/ /' image_out=$(runFileOp docker image prune -f 2>&1) checkSuccess "Pruned dangling images" echo "$image_out" | grep -i "Total reclaimed space" | sed 's/^/ /' isSuccessful "Reclaim complete" } cliHandleSystemCommands() { local action="$initial_command2" case "$action" in "status") tagsValidateShowSystemStatus ;; "update") checkUpdates ;; "reset") runReinstall ;; "reclaim") reclaimDockerSpace ;; *) isNotice "Invalid system command: $action" cliShowSystemHelp ;; esac }