From a7623019be50013fb39fbea06b07c574836f66aa Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 18:42:12 -0400 Subject: [PATCH] rm cleanup --- root/usr/libexec/apps/whoogle/whoogle.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/root/usr/libexec/apps/whoogle/whoogle.sh b/root/usr/libexec/apps/whoogle/whoogle.sh index 189d4fc..180342a 100755 --- a/root/usr/libexec/apps/whoogle/whoogle.sh +++ b/root/usr/libexec/apps/whoogle/whoogle.sh @@ -121,8 +121,17 @@ case ${ACTION} in do_install_detail ;; "rm") - docker rm -f whoogle-search - ;; + IMAGE_NAME=$(uci get whoogle.@whoogle[0].image_name 2>/dev/null) + [ -z "$IMAGE_NAME" ] && IMAGE_NAME="benbusby/whoogle-search" + CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}') + echo "Stopping and removing containers..." + for ID in $CONTAINER_IDS; do + docker stop "$ID" + docker rm "$ID" + done + docker rmi -f "$IMAGE_NAME" + rm -r /opt/docker2/compose/whoogle-app 2>/dev/null + ;; "start" | "stop" | "restart") docker ${ACTION} whoogle-search ;;