FileRun/uninstall.sh
2025-11-30 13:56:02 +00:00

37 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
# --- Configuration ---
COMPOSE_FILE="docker-compose.yml"
DATA_DIRS=("db_data" "filerun_html" "user_data")
# ---------------------
echo "🛑 Stopping and removing all services defined in ${COMPOSE_FILE}..."
# docker compose down: Stops containers, removes containers, and removes networks
# --volumes: Removes anonymous volumes, though we are using named directories.
docker compose -f "${COMPOSE_FILE}" down --volumes
if [ $? -ne 0 ]; then
echo "❌ Docker Compose failed to stop and remove services. Aborting data removal."
exit 1
fi
echo "---"
echo "🗑️ Removing persistent data directories..."
for dir in "${DATA_DIRS[@]}"; do
if [ -d "$dir" ]; then
echo " -> Removing directory: ${dir}/"
# The 'rm -rf' command deletes the directory and all its contents
sudo rm -rf "$dir"
if [ $? -eq 0 ]; then
echo " [SUCCESS]"
else
echo " [FAILED] Could not remove ${dir}. Manual intervention may be required."
fi
else
echo " -> Directory not found: ${dir}/ (Skipping)"
fi
done
echo "---"
echo "✅ Uninstallation complete. All data and services have been removed."