fix(uninstall): always run name-based container cleanup + drop CLI hint
Two small uninstall-output tweaks. 1. dockerComposeDownRemove now ALWAYS calls dockerRemoveApp (the `docker ps -aqf name=…` → stop + rm sweep) as a fallback, even when the compose-down step is skipped because the app dir is missing. Before, a partial prior uninstall (compose file gone but containers still running) produced "App directory not found. Skipping container shutdown." and then proceeded as if the uninstall were complete — leaving the actual containers running. The name-based sweep also runs after a successful compose-down to catch anything compose wouldn't pick up (renamed services, orphans from earlier failures). While here: the OS_TYPE gate (only Ubuntu/Debian) is gone too — `docker compose down` works on any OS with docker, and gating it meant Arch/etc. users got NO compose teardown at all. 2. The step-2 header "Keeping Docker images (pass --delete-images to remove)" trimmed to just "Keeping Docker images". The `isNotice` line below already explains the reuse-on-reinstall behaviour; the CLI-flag hint reads as noise in the WebUI task log where users can't act on it anyway. CLI users can still pass --delete-images (cli_app_commands.sh wires it as before) or tick the WebUI's "Also delete docker image" checkbox. Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
parent
e419466257
commit
66e747e1ba
@ -1,30 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Take an app's containers down + remove them. Two paths run in order:
|
||||||
|
#
|
||||||
|
# 1. `docker compose down -v --remove-orphans` from the app dir. Best
|
||||||
|
# path — clean shutdown, named volumes pruned, orphans swept. Only
|
||||||
|
# runs when the compose file is still on disk.
|
||||||
|
#
|
||||||
|
# 2. Name-based fallback (`dockerRemoveApp`): `docker ps -aqf name=$app`
|
||||||
|
# → stop + rm. Always runs, even when compose down succeeded, to
|
||||||
|
# catch containers compose wouldn't pick up — renamed/relabelled
|
||||||
|
# ones, leftovers from a previously-failed uninstall, and the case
|
||||||
|
# the user flagged: app dir already gone, compose step skipped,
|
||||||
|
# containers were still running.
|
||||||
dockerComposeDownRemove()
|
dockerComposeDownRemove()
|
||||||
{
|
{
|
||||||
local app_name="$1"
|
local app_name="$1"
|
||||||
|
|
||||||
if [[ "$app_name" == "" ]]; then
|
if [[ -z "$app_name" ]]; then
|
||||||
isError "No app_name provided, unable to continue..."
|
isError "No app_name provided, unable to continue..."
|
||||||
else
|
return 1
|
||||||
if [[ "$OS_TYPE" == "Ubuntu" || "$OS_TYPE" == "Debian" ]]; then
|
|
||||||
if [[ $CFG_DOCKER_INSTALL_TYPE == "rootless" ]]; then
|
|
||||||
if [[ -d "$containers_dir$app_name" ]]; then
|
|
||||||
local result=$(dockerCommandRunInstallUser "cd $containers_dir$app_name && docker compose down -v --remove-orphans")
|
|
||||||
isNotice "Shutting down & Removing all $app_name container data"
|
|
||||||
dockerRemoveApp $app_name;
|
|
||||||
else
|
|
||||||
isNotice "App directory '$app_name' not found. Skipping container shutdown."
|
|
||||||
fi
|
|
||||||
elif [[ $CFG_DOCKER_INSTALL_TYPE == "rooted" ]]; then
|
|
||||||
if [[ -d "$containers_dir$app_name" ]]; then
|
|
||||||
local result=$(cd $containers_dir$app_name && docker compose down -v --remove-orphans)
|
|
||||||
isNotice "Shutting down & Removing all $app_name container data"
|
|
||||||
dockerRemoveApp $app_name;
|
|
||||||
else
|
|
||||||
isNotice "App directory '$app_name' not found. Skipping container shutdown."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
if [[ -d "$containers_dir$app_name" ]]; then
|
||||||
|
isNotice "Shutting down & removing all $app_name container data"
|
||||||
|
if [[ "$CFG_DOCKER_INSTALL_TYPE" == "rootless" ]]; then
|
||||||
|
dockerCommandRunInstallUser "cd $containers_dir$app_name && docker compose down -v --remove-orphans" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
(cd "$containers_dir$app_name" && docker compose down -v --remove-orphans) >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
isNotice "App directory '$app_name' not found — falling back to name-based container cleanup."
|
||||||
|
fi
|
||||||
|
|
||||||
|
dockerRemoveApp "$app_name"
|
||||||
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ dockerUninstallApp()
|
|||||||
echo ""
|
echo ""
|
||||||
dockerRemoveAppImages $stored_app_name;
|
dockerRemoveAppImages $stored_app_name;
|
||||||
else
|
else
|
||||||
echo "---- $menu_number. Keeping Docker images (pass --delete-images to remove)"
|
echo "---- $menu_number. Keeping Docker images"
|
||||||
echo ""
|
echo ""
|
||||||
isNotice "Docker images for '$stored_app_name' left in place. A reinstall will reuse them."
|
isNotice "Docker images for '$stored_app_name' left in place. A reinstall will reuse them."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user