Files
spark/uninstall.sh

140 lines
4.1 KiB
Bash
Raw Normal View History

feat(migration): Migrate from Node.js to Deno runtime Major migration to Deno runtime following the nupst project pattern: Core Changes: - Created deno.json configuration with tasks, imports, and settings - Created mod.ts as main entry point with Deno permissions - Updated all TypeScript imports from .js to .ts extensions - Replaced Node.js APIs (process.exit) with Deno equivalents (Deno.exit) - Updated path imports to use @std/path from JSR Dependencies: - Migrated all npm dependencies to use npm: prefix in import map - Added Deno standard library imports (@std/path, @std/assert) - Configured import aliases for all @push.rocks and @serve.zone packages Build & Distribution: - Created install.sh for downloading pre-compiled binaries - Created uninstall.sh for clean system removal - Created scripts/compile-all.sh for multi-platform compilation - Supports Linux (x64, ARM64), macOS (x64, ARM64), Windows (x64) Testing: - Migrated tests to Deno test framework using @std/assert - Created test.simple.ts for basic verification - Updated test structure to use Deno.test instead of tap CI/CD: - Created .gitea/workflows/ci.yml for type checking, linting, and builds - Created .gitea/workflows/release.yml for automated releases - Created .gitea/release-template.md for release documentation Cleanup: - Removed package.json, pnpm-lock.yaml, tsconfig.json - Removed Node.js CLI files (cli.js, cli.child.ts, cli.ts.js) - Removed dist_ts/ compiled output directory - Removed npmextra.json configuration This migration enables standalone binary distribution without Node.js runtime dependency while maintaining all existing functionality.
2025-10-23 23:22:16 +00:00
#!/bin/bash
# SPARK Uninstaller Script
# Completely removes SPARK from the system
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (sudo ./uninstall.sh)"
exit 1
fi
# This script can be called directly or through the CLI
# When called through the CLI, environment variables are set
# REMOVE_CONFIG=yes|no - whether to remove configuration files
# REMOVE_DATA=yes|no - whether to remove data files
# If not set through CLI, use defaults
REMOVE_CONFIG=${REMOVE_CONFIG:-"no"}
REMOVE_DATA=${REMOVE_DATA:-"no"}
echo "SPARK Uninstaller"
echo "================="
echo "This will completely remove SPARK from your system."
# Find the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Step 1: Stop and disable the systemd service if it exists
if [ -f "/etc/systemd/system/spark.service" ]; then
echo "Stopping SPARK service..."
systemctl stop spark.service 2>/dev/null
echo "Disabling SPARK service..."
systemctl disable spark.service 2>/dev/null
echo "Removing systemd service file..."
rm -f /etc/systemd/system/spark.service
echo "Reloading systemd daemon..."
systemctl daemon-reload
fi
# Also check for legacy smartdaemon_spark service
if [ -f "/etc/systemd/system/smartdaemon_spark.service" ]; then
echo "Stopping legacy smartdaemon_spark service..."
systemctl stop smartdaemon_spark.service 2>/dev/null
echo "Disabling legacy smartdaemon_spark service..."
systemctl disable smartdaemon_spark.service 2>/dev/null
echo "Removing legacy systemd service file..."
rm -f /etc/systemd/system/smartdaemon_spark.service
echo "Reloading systemd daemon..."
systemctl daemon-reload
fi
# Step 2: Remove global symlinks
if [ -L "/usr/local/bin/spark" ]; then
echo "Removing global symlink from /usr/local/bin/spark..."
rm -f /usr/local/bin/spark
fi
if [ -L "/usr/bin/spark" ]; then
echo "Removing global symlink from /usr/bin/spark..."
rm -f /usr/bin/spark
fi
# Step 3: Remove configuration if requested
if [ "$REMOVE_CONFIG" = "yes" ]; then
if [ -d "/etc/spark" ]; then
echo "Removing configuration directory /etc/spark..."
rm -rf /etc/spark
fi
else
if [ -d "/etc/spark" ]; then
echo "Configuration preserved in /etc/spark (use --remove-config to remove)"
fi
fi
# Step 4: Remove data if requested
if [ "$REMOVE_DATA" = "yes" ]; then
if [ -d "/var/lib/spark" ]; then
echo "Removing data directory /var/lib/spark..."
rm -rf /var/lib/spark
fi
if [ -d "/var/log/spark" ]; then
echo "Removing log directory /var/log/spark..."
rm -rf /var/log/spark
fi
else
if [ -d "/var/lib/spark" ] || [ -d "/var/log/spark" ]; then
echo "Data and logs preserved (use --remove-data to remove)"
fi
fi
# Step 5: Remove installation directory
if [ -d "/opt/spark" ]; then
echo "Removing installation directory /opt/spark..."
rm -rf /opt/spark
fi
# Step 6: Clean up Docker containers and images if any
echo "Checking for SPARK-managed Docker resources..."
# List all containers with spark labels
SPARK_CONTAINERS=$(docker ps -aq --filter "label=com.servezone.spark" 2>/dev/null)
if [ -n "$SPARK_CONTAINERS" ]; then
echo "Stopping and removing SPARK-managed containers..."
docker stop $SPARK_CONTAINERS 2>/dev/null
docker rm $SPARK_CONTAINERS 2>/dev/null
fi
echo ""
echo "================================================"
echo " SPARK Uninstallation Complete"
echo "================================================"
echo ""
echo "SPARK has been removed from your system."
if [ "$REMOVE_CONFIG" = "no" ] && [ -d "/etc/spark" ]; then
echo ""
echo "Configuration has been preserved in /etc/spark"
echo "To remove it, run: sudo rm -rf /etc/spark"
fi
if [ "$REMOVE_DATA" = "no" ]; then
if [ -d "/var/lib/spark" ] || [ -d "/var/log/spark" ]; then
echo ""
echo "Data and logs have been preserved in:"
[ -d "/var/lib/spark" ] && echo " - /var/lib/spark"
[ -d "/var/log/spark" ] && echo " - /var/log/spark"
echo "To remove them, run:"
[ -d "/var/lib/spark" ] && echo " sudo rm -rf /var/lib/spark"
[ -d "/var/log/spark" ] && echo " sudo rm -rf /var/log/spark"
fi
fi
echo ""
echo "Thank you for using SPARK!"
echo ""