Files
pterodactyl_addon/uninstall.sh
2026-06-11 20:33:44 -05:00

54 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# =============================================================================
# Pterodactyl Advanced Admin Addons — Uninstaller
# Author : Ball Studios <https://git.balls.studio>
# Usage : bash <(curl -fsSL https://git.balls.studio/BallStudios/pterodactyl_addon/raw/branch/main/uninstall.sh)
# =============================================================================
set -euo pipefail
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; BOLD='\033[1m'; NC='\033[0m'
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
step() { echo -e "\n${BOLD}$*${NC}"; }
PANEL_DIR="${1:-/var/www/pterodactyl}"
PHP_BIN="$(command -v php)"
echo -e "\n${BOLD}${RED}Pterodactyl Advanced Admin Addons — Uninstaller${NC}"
warn "This will remove ALL addon data from the database!"
read -rp "Type 'uninstall' to confirm: " CONFIRM
[[ "$CONFIRM" == "uninstall" ]] || { info "Aborted."; exit 0; }
[[ $EUID -eq 0 ]] || error "Must be run as root."
[[ -f "${PANEL_DIR}/artisan" ]] || error "Panel not found at ${PANEL_DIR}."
step "Rolling back database migrations..."
cd "$PANEL_DIR"
$PHP_BIN artisan migrate:rollback --path=database/migrations/addon --force
success "Migrations rolled back."
step "Rolling back patches..."
$PHP_BIN artisan addon:patch rollback 2>/dev/null || warn "Manual patch rollback required — see patches/PATCHES.md"
step "Removing addon files..."
rm -rf "${PANEL_DIR}/app/Addons/AdvancedAdmin"
rm -f "${PANEL_DIR}/config/advanced-admin.php"
rm -rf "${PANEL_DIR}/config/addon-commands"
rm -f "${PANEL_DIR}/routes/addon-client.php"
rm -f "${PANEL_DIR}/routes/addon-application.php"
rm -rf "${PANEL_DIR}/resources/scripts/addons/advanced-admin"
rm -rf "${PANEL_DIR}/database/migrations/addon"
rm -rf "${PANEL_DIR}/storage/app/addons/revisions"
success "Files removed."
step "Rebuilding frontend..."
export NODE_OPTIONS="${NODE_OPTIONS:---openssl-legacy-provider}"
yarn --cwd "$PANEL_DIR" build:production
success "Frontend rebuilt."
step "Clearing caches..."
$PHP_BIN artisan optimize:clear && $PHP_BIN artisan optimize
success "Uninstall complete."