2025-09-11 20:04:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Test Plugin Installation Script for CyberPanel
|
2025-09-11 20:17:54 +02:00
|
|
|
# Multi-OS Compatible Installation Script
|
|
|
|
|
# Supports: Ubuntu, Debian, AlmaLinux, RockyLinux, RHEL, CloudLinux, CentOS
|
2025-09-11 20:04:09 +02:00
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Colors for output
|
|
|
|
|
RED='\033[0;31m'
|
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
|
BLUE='\033[0;34m'
|
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
|
PLUGIN_NAME="testPlugin"
|
|
|
|
|
PLUGIN_DIR="/home/cyberpanel/plugins"
|
|
|
|
|
CYBERPANEL_DIR="/usr/local/CyberCP"
|
|
|
|
|
GITHUB_REPO="https://github.com/cyberpanel/testPlugin.git"
|
|
|
|
|
TEMP_DIR="/tmp/cyberpanel_plugin_install"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# OS Detection Variables
|
|
|
|
|
OS_NAME=""
|
|
|
|
|
OS_VERSION=""
|
|
|
|
|
OS_ARCH=""
|
|
|
|
|
PYTHON_CMD=""
|
|
|
|
|
PIP_CMD=""
|
|
|
|
|
SERVICE_CMD=""
|
|
|
|
|
WEB_SERVER=""
|
|
|
|
|
|
2025-09-11 20:04:09 +02:00
|
|
|
# Function to print colored output
|
|
|
|
|
print_status() {
|
|
|
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_success() {
|
|
|
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_warning() {
|
|
|
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_error() {
|
|
|
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to detect operating system
|
|
|
|
|
detect_os() {
|
|
|
|
|
print_status "Detecting operating system..."
|
|
|
|
|
|
|
|
|
|
if [ -f /etc/os-release ]; then
|
|
|
|
|
. /etc/os-release
|
|
|
|
|
OS_NAME="$ID"
|
|
|
|
|
OS_VERSION="$VERSION_ID"
|
|
|
|
|
elif [ -f /etc/redhat-release ]; then
|
|
|
|
|
OS_NAME="rhel"
|
|
|
|
|
OS_VERSION=$(cat /etc/redhat-release | grep -oE '[0-9]+\.[0-9]+' | head -1)
|
|
|
|
|
elif [ -f /etc/debian_version ]; then
|
|
|
|
|
OS_NAME="debian"
|
|
|
|
|
OS_VERSION=$(cat /etc/debian_version)
|
|
|
|
|
else
|
|
|
|
|
print_error "Unable to detect operating system"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Detect architecture
|
|
|
|
|
OS_ARCH=$(uname -m)
|
|
|
|
|
|
|
|
|
|
print_success "Detected: $OS_NAME $OS_VERSION ($OS_ARCH)"
|
|
|
|
|
|
|
|
|
|
# Set OS-specific configurations
|
|
|
|
|
configure_os_specific
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to configure OS-specific settings
|
|
|
|
|
configure_os_specific() {
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
PYTHON_CMD="python3"
|
|
|
|
|
PIP_CMD="pip3"
|
|
|
|
|
SERVICE_CMD="systemctl"
|
|
|
|
|
WEB_SERVER="apache2"
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
PYTHON_CMD="python3"
|
|
|
|
|
PIP_CMD="pip3"
|
|
|
|
|
SERVICE_CMD="systemctl"
|
|
|
|
|
WEB_SERVER="httpd"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
print_warning "Unknown OS: $OS_NAME. Using default configurations."
|
|
|
|
|
PYTHON_CMD="python3"
|
|
|
|
|
PIP_CMD="pip3"
|
|
|
|
|
SERVICE_CMD="systemctl"
|
|
|
|
|
WEB_SERVER="httpd"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
print_status "Using Python: $PYTHON_CMD"
|
|
|
|
|
print_status "Using Pip: $PIP_CMD"
|
|
|
|
|
print_status "Using Service Manager: $SERVICE_CMD"
|
|
|
|
|
print_status "Using Web Server: $WEB_SERVER"
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:04:09 +02:00
|
|
|
# Function to check if running as root
|
|
|
|
|
check_root() {
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
|
print_error "This script must be run as root"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to check if CyberPanel is installed
|
|
|
|
|
check_cyberpanel() {
|
|
|
|
|
if [ ! -d "$CYBERPANEL_DIR" ]; then
|
|
|
|
|
print_error "CyberPanel is not installed at $CYBERPANEL_DIR"
|
2025-09-11 20:17:54 +02:00
|
|
|
print_error "Please install CyberPanel first: https://cyberpanel.net/docs/"
|
2025-09-11 20:04:09 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2025-09-11 20:17:54 +02:00
|
|
|
|
|
|
|
|
# Check if CyberPanel is running
|
|
|
|
|
if ! $SERVICE_CMD is-active --quiet lscpd; then
|
|
|
|
|
print_warning "CyberPanel service (lscpd) is not running. Starting it..."
|
|
|
|
|
$SERVICE_CMD start lscpd
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
print_success "CyberPanel installation verified"
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to check Python installation
|
|
|
|
|
check_python() {
|
|
|
|
|
print_status "Checking Python installation..."
|
|
|
|
|
|
|
|
|
|
if ! command -v $PYTHON_CMD &> /dev/null; then
|
|
|
|
|
print_error "Python3 is not installed. Installing..."
|
|
|
|
|
install_python
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check Python version (require 3.6+)
|
|
|
|
|
PYTHON_VERSION=$($PYTHON_CMD -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
|
|
|
|
PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1)
|
|
|
|
|
PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d. -f2)
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 6 ]); then
|
|
|
|
|
print_error "Python 3.6+ is required. Found: $PYTHON_VERSION"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
print_success "Python $PYTHON_VERSION is available"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to install Python if needed
|
|
|
|
|
install_python() {
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
apt-get update
|
|
|
|
|
apt-get install -y python3 python3-pip python3-venv
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
if command -v dnf &> /dev/null; then
|
|
|
|
|
dnf install -y python3 python3-pip
|
|
|
|
|
elif command -v yum &> /dev/null; then
|
|
|
|
|
yum install -y python3 python3-pip
|
|
|
|
|
else
|
|
|
|
|
print_error "No package manager found (dnf/yum)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to check pip installation
|
|
|
|
|
check_pip() {
|
|
|
|
|
print_status "Checking pip installation..."
|
|
|
|
|
|
|
|
|
|
if ! command -v $PIP_CMD &> /dev/null; then
|
|
|
|
|
print_error "pip3 is not installed. Installing..."
|
|
|
|
|
install_pip
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
print_success "pip3 is available"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to install pip if needed
|
|
|
|
|
install_pip() {
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
apt-get install -y python3-pip
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
if command -v dnf &> /dev/null; then
|
|
|
|
|
dnf install -y python3-pip
|
|
|
|
|
elif command -v yum &> /dev/null; then
|
|
|
|
|
yum install -y python3-pip
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to check required packages
|
|
|
|
|
check_packages() {
|
|
|
|
|
print_status "Checking required packages..."
|
|
|
|
|
|
|
|
|
|
# Check for git
|
|
|
|
|
if ! command -v git &> /dev/null; then
|
|
|
|
|
print_error "git is not installed. Installing..."
|
|
|
|
|
install_git
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check for curl
|
|
|
|
|
if ! command -v curl &> /dev/null; then
|
|
|
|
|
print_error "curl is not installed. Installing..."
|
|
|
|
|
install_curl
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
print_success "All required packages are available"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to install git
|
|
|
|
|
install_git() {
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
apt-get update
|
|
|
|
|
apt-get install -y git
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
if command -v dnf &> /dev/null; then
|
|
|
|
|
dnf install -y git
|
|
|
|
|
elif command -v yum &> /dev/null; then
|
|
|
|
|
yum install -y git
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to install curl
|
|
|
|
|
install_curl() {
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
apt-get update
|
|
|
|
|
apt-get install -y curl
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
if command -v dnf &> /dev/null; then
|
|
|
|
|
dnf install -y curl
|
|
|
|
|
elif command -v yum &> /dev/null; then
|
|
|
|
|
yum install -y curl
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to create plugin directory
|
|
|
|
|
create_plugin_directory() {
|
|
|
|
|
print_status "Creating plugin directory structure..."
|
|
|
|
|
|
|
|
|
|
# Create main plugin directory
|
2025-09-11 20:04:09 +02:00
|
|
|
mkdir -p "$PLUGIN_DIR"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Create CyberPanel plugin directory
|
|
|
|
|
mkdir -p "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
|
|
|
|
|
# Set proper permissions
|
|
|
|
|
chown -R cyberpanel:cyberpanel "$PLUGIN_DIR" 2>/dev/null || chown -R root:root "$PLUGIN_DIR"
|
|
|
|
|
chmod -R 755 "$PLUGIN_DIR"
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
chown -R cyberpanel:cyberpanel "$CYBERPANEL_DIR/$PLUGIN_NAME" 2>/dev/null || chown -R root:root "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
chmod -R 755 "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
|
|
|
|
|
print_success "Plugin directory structure created"
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to download plugin
|
2025-09-11 20:04:09 +02:00
|
|
|
download_plugin() {
|
|
|
|
|
print_status "Downloading plugin from GitHub..."
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Clean up temp directory
|
2025-09-11 20:04:09 +02:00
|
|
|
rm -rf "$TEMP_DIR"
|
2025-09-11 20:17:54 +02:00
|
|
|
mkdir -p "$TEMP_DIR"
|
2025-09-11 20:04:09 +02:00
|
|
|
|
|
|
|
|
# Clone the repository
|
2025-09-11 20:17:54 +02:00
|
|
|
if ! git clone "$GITHUB_REPO" "$TEMP_DIR"; then
|
|
|
|
|
print_error "Failed to download plugin from GitHub"
|
|
|
|
|
print_error "Please check your internet connection and try again"
|
2025-09-11 20:04:09 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
print_success "Plugin downloaded successfully"
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to install plugin files
|
2025-09-11 20:17:54 +02:00
|
|
|
install_plugin_files() {
|
2025-09-11 20:04:09 +02:00
|
|
|
print_status "Installing plugin files..."
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Copy plugin files
|
|
|
|
|
cp -r "$TEMP_DIR"/* "$CYBERPANEL_DIR/$PLUGIN_NAME/"
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Create symlink
|
|
|
|
|
ln -sf "$CYBERPANEL_DIR/$PLUGIN_NAME" "$PLUGIN_DIR/$PLUGIN_NAME"
|
|
|
|
|
|
|
|
|
|
# Set proper ownership and permissions
|
|
|
|
|
chown -R cyberpanel:cyberpanel "$CYBERPANEL_DIR/$PLUGIN_NAME" 2>/dev/null || chown -R root:root "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
2025-09-11 20:04:09 +02:00
|
|
|
chmod -R 755 "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Make scripts executable
|
|
|
|
|
chmod +x "$CYBERPANEL_DIR/$PLUGIN_NAME/install.sh" 2>/dev/null || true
|
2025-09-11 20:04:09 +02:00
|
|
|
|
|
|
|
|
print_success "Plugin files installed"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to update Django settings
|
|
|
|
|
update_django_settings() {
|
|
|
|
|
print_status "Updating Django settings..."
|
|
|
|
|
|
|
|
|
|
SETTINGS_FILE="$CYBERPANEL_DIR/cyberpanel/settings.py"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Check if plugin is already in INSTALLED_APPS
|
|
|
|
|
if ! grep -q "'$PLUGIN_NAME'" "$SETTINGS_FILE"; then
|
|
|
|
|
# Add plugin to INSTALLED_APPS
|
|
|
|
|
sed -i "/INSTALLED_APPS = \[/a\ '$PLUGIN_NAME'," "$SETTINGS_FILE"
|
|
|
|
|
print_success "Added $PLUGIN_NAME to INSTALLED_APPS"
|
2025-09-11 20:04:09 +02:00
|
|
|
else
|
2025-09-11 20:17:54 +02:00
|
|
|
print_warning "$PLUGIN_NAME already in INSTALLED_APPS"
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to update URL configuration
|
|
|
|
|
update_urls() {
|
|
|
|
|
print_status "Updating URL configuration..."
|
|
|
|
|
|
|
|
|
|
URLS_FILE="$CYBERPANEL_DIR/cyberpanel/urls.py"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Check if plugin URLs are already included
|
|
|
|
|
if ! grep -q "path(\"$PLUGIN_NAME/\"" "$URLS_FILE"; then
|
|
|
|
|
# Add plugin URLs
|
|
|
|
|
sed -i "/urlpatterns = \[/a\ path(\"$PLUGIN_NAME/\", include(\"$PLUGIN_NAME.urls\"))," "$URLS_FILE"
|
|
|
|
|
print_success "Added $PLUGIN_NAME URLs"
|
2025-09-11 20:04:09 +02:00
|
|
|
else
|
2025-09-11 20:17:54 +02:00
|
|
|
print_warning "$PLUGIN_NAME URLs already configured"
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to run database migrations
|
2025-09-11 20:04:09 +02:00
|
|
|
run_migrations() {
|
2025-09-11 20:17:54 +02:00
|
|
|
print_status "Running database migrations..."
|
2025-09-11 20:04:09 +02:00
|
|
|
|
|
|
|
|
cd "$CYBERPANEL_DIR"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Create migrations
|
|
|
|
|
if ! $PYTHON_CMD manage.py makemigrations $PLUGIN_NAME; then
|
|
|
|
|
print_warning "No migrations to create for $PLUGIN_NAME"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Apply migrations
|
|
|
|
|
if ! $PYTHON_CMD manage.py migrate $PLUGIN_NAME; then
|
|
|
|
|
print_warning "No migrations to apply for $PLUGIN_NAME"
|
|
|
|
|
fi
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
print_success "Database migrations completed"
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to collect static files
|
|
|
|
|
collect_static() {
|
|
|
|
|
print_status "Collecting static files..."
|
|
|
|
|
|
|
|
|
|
cd "$CYBERPANEL_DIR"
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
if ! $PYTHON_CMD manage.py collectstatic --noinput; then
|
|
|
|
|
print_warning "Static file collection failed, but continuing..."
|
|
|
|
|
else
|
|
|
|
|
print_success "Static files collected"
|
|
|
|
|
fi
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to restart services
|
2025-09-11 20:04:09 +02:00
|
|
|
restart_services() {
|
|
|
|
|
print_status "Restarting CyberPanel services..."
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Restart lscpd
|
|
|
|
|
if $SERVICE_CMD is-active --quiet lscpd; then
|
|
|
|
|
$SERVICE_CMD restart lscpd
|
|
|
|
|
print_success "lscpd service restarted"
|
|
|
|
|
else
|
|
|
|
|
print_warning "lscpd service not running"
|
|
|
|
|
fi
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Restart web server
|
|
|
|
|
if $SERVICE_CMD is-active --quiet $WEB_SERVER; then
|
|
|
|
|
$SERVICE_CMD restart $WEB_SERVER
|
|
|
|
|
print_success "$WEB_SERVER service restarted"
|
|
|
|
|
else
|
|
|
|
|
print_warning "$WEB_SERVER service not running"
|
|
|
|
|
fi
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Additional service restart for different OS
|
|
|
|
|
case "$OS_NAME" in
|
|
|
|
|
"ubuntu"|"debian")
|
|
|
|
|
if $SERVICE_CMD is-active --quiet cyberpanel; then
|
|
|
|
|
$SERVICE_CMD restart cyberpanel
|
|
|
|
|
print_success "cyberpanel service restarted"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
"almalinux"|"rocky"|"rhel"|"centos"|"cloudlinux")
|
|
|
|
|
if $SERVICE_CMD is-active --quiet cyberpanel; then
|
|
|
|
|
$SERVICE_CMD restart cyberpanel
|
|
|
|
|
print_success "cyberpanel service restarted"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to verify installation
|
|
|
|
|
verify_installation() {
|
|
|
|
|
print_status "Verifying installation..."
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Check if plugin directory exists
|
|
|
|
|
if [ ! -d "$CYBERPANEL_DIR/$PLUGIN_NAME" ]; then
|
2025-09-11 20:04:09 +02:00
|
|
|
print_error "Plugin directory not found"
|
2025-09-11 20:17:54 +02:00
|
|
|
return 1
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if symlink exists
|
2025-09-11 20:17:54 +02:00
|
|
|
if [ ! -L "$PLUGIN_DIR/$PLUGIN_NAME" ]; then
|
2025-09-11 20:04:09 +02:00
|
|
|
print_error "Plugin symlink not found"
|
2025-09-11 20:17:54 +02:00
|
|
|
return 1
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if meta.xml exists
|
2025-09-11 20:17:54 +02:00
|
|
|
if [ ! -f "$CYBERPANEL_DIR/$PLUGIN_NAME/meta.xml" ]; then
|
|
|
|
|
print_error "Plugin meta.xml not found"
|
|
|
|
|
return 1
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
print_success "Installation verified successfully"
|
2025-09-11 20:17:54 +02:00
|
|
|
return 0
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Function to display installation summary
|
|
|
|
|
display_summary() {
|
2025-09-11 20:04:09 +02:00
|
|
|
echo ""
|
|
|
|
|
echo "=========================================="
|
2025-09-11 20:17:54 +02:00
|
|
|
print_success "Test Plugin Installation Complete!"
|
2025-09-11 20:04:09 +02:00
|
|
|
echo "=========================================="
|
|
|
|
|
echo "Plugin Name: $PLUGIN_NAME"
|
|
|
|
|
echo "Installation Directory: $CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
echo "Plugin Directory: $PLUGIN_DIR/$PLUGIN_NAME"
|
|
|
|
|
echo "Access URL: https://your-domain:8090/testPlugin/"
|
2025-09-11 20:17:54 +02:00
|
|
|
echo "Operating System: $OS_NAME $OS_VERSION ($OS_ARCH)"
|
|
|
|
|
echo "Python Version: $($PYTHON_CMD --version)"
|
2025-09-11 20:04:09 +02:00
|
|
|
echo ""
|
|
|
|
|
echo "Features Installed:"
|
|
|
|
|
echo "✓ Enable/Disable Toggle"
|
|
|
|
|
echo "✓ Test Button with Popup Messages"
|
|
|
|
|
echo "✓ Settings Page"
|
|
|
|
|
echo "✓ Activity Logs"
|
|
|
|
|
echo "✓ Inline Integration"
|
|
|
|
|
echo "✓ Complete Documentation"
|
|
|
|
|
echo "✓ Official CyberPanel Guide"
|
|
|
|
|
echo "✓ Advanced Development Guide"
|
2025-09-11 20:17:54 +02:00
|
|
|
echo "✓ Enterprise-Grade Security"
|
|
|
|
|
echo "✓ Brute Force Protection"
|
|
|
|
|
echo "✓ CSRF Protection"
|
|
|
|
|
echo "✓ XSS Prevention"
|
|
|
|
|
echo "✓ SQL Injection Protection"
|
|
|
|
|
echo "✓ Rate Limiting"
|
|
|
|
|
echo "✓ Security Monitoring"
|
|
|
|
|
echo "✓ Security Information Page"
|
|
|
|
|
echo "✓ Multi-OS Compatibility"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Supported Operating Systems:"
|
|
|
|
|
echo "✓ Ubuntu 22.04, 20.04"
|
|
|
|
|
echo "✓ Debian (compatible)"
|
|
|
|
|
echo "✓ AlmaLinux 8, 9, 10"
|
|
|
|
|
echo "✓ RockyLinux 8, 9"
|
|
|
|
|
echo "✓ RHEL 8, 9"
|
|
|
|
|
echo "✓ CloudLinux 8"
|
|
|
|
|
echo "✓ CentOS 9"
|
2025-09-11 20:04:09 +02:00
|
|
|
echo ""
|
|
|
|
|
echo "To uninstall, run: $0 --uninstall"
|
|
|
|
|
echo "=========================================="
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Function to uninstall plugin
|
|
|
|
|
uninstall_plugin() {
|
2025-09-11 20:17:54 +02:00
|
|
|
print_status "Uninstalling $PLUGIN_NAME..."
|
2025-09-11 20:04:09 +02:00
|
|
|
|
|
|
|
|
# Remove plugin files
|
|
|
|
|
rm -rf "$CYBERPANEL_DIR/$PLUGIN_NAME"
|
|
|
|
|
rm -f "$PLUGIN_DIR/$PLUGIN_NAME"
|
|
|
|
|
|
|
|
|
|
# Remove from Django settings
|
|
|
|
|
SETTINGS_FILE="$CYBERPANEL_DIR/cyberpanel/settings.py"
|
|
|
|
|
if [ -f "$SETTINGS_FILE" ]; then
|
2025-09-11 20:17:54 +02:00
|
|
|
sed -i "/'$PLUGIN_NAME',/d" "$SETTINGS_FILE"
|
|
|
|
|
print_success "Removed $PLUGIN_NAME from INSTALLED_APPS"
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Remove from URLs
|
|
|
|
|
URLS_FILE="$CYBERPANEL_DIR/cyberpanel/urls.py"
|
|
|
|
|
if [ -f "$URLS_FILE" ]; then
|
2025-09-11 20:17:54 +02:00
|
|
|
sed -i "/path(\"$PLUGIN_NAME\/\"/d" "$URLS_FILE"
|
|
|
|
|
print_success "Removed $PLUGIN_NAME URLs"
|
2025-09-11 20:04:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Restart services
|
|
|
|
|
restart_services
|
|
|
|
|
|
|
|
|
|
print_success "Plugin uninstalled successfully"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Main installation function
|
2025-09-11 20:17:54 +02:00
|
|
|
install_plugin() {
|
|
|
|
|
print_status "Starting Test Plugin installation..."
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Detect OS
|
|
|
|
|
detect_os
|
2025-09-11 20:04:09 +02:00
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Check requirements
|
2025-09-11 20:04:09 +02:00
|
|
|
check_root
|
|
|
|
|
check_cyberpanel
|
2025-09-11 20:17:54 +02:00
|
|
|
check_python
|
|
|
|
|
check_pip
|
|
|
|
|
check_packages
|
|
|
|
|
|
|
|
|
|
# Install plugin
|
|
|
|
|
create_plugin_directory
|
2025-09-11 20:04:09 +02:00
|
|
|
download_plugin
|
2025-09-11 20:17:54 +02:00
|
|
|
install_plugin_files
|
2025-09-11 20:04:09 +02:00
|
|
|
update_django_settings
|
|
|
|
|
update_urls
|
|
|
|
|
run_migrations
|
|
|
|
|
collect_static
|
|
|
|
|
restart_services
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Verify installation
|
|
|
|
|
if verify_installation; then
|
|
|
|
|
display_summary
|
|
|
|
|
else
|
|
|
|
|
print_error "Installation verification failed"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Main script logic
|
|
|
|
|
main() {
|
|
|
|
|
case "${1:-}" in
|
|
|
|
|
"--uninstall")
|
|
|
|
|
check_root
|
|
|
|
|
uninstall_plugin
|
|
|
|
|
;;
|
|
|
|
|
"--help"|"-h")
|
|
|
|
|
echo "Usage: $0 [OPTIONS]"
|
|
|
|
|
echo "Options:"
|
|
|
|
|
echo " --uninstall Uninstall the plugin"
|
|
|
|
|
echo " --help, -h Show this help message"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Supported Operating Systems:"
|
|
|
|
|
echo " Ubuntu 22.04, 20.04"
|
|
|
|
|
echo " Debian (compatible)"
|
|
|
|
|
echo " AlmaLinux 8, 9, 10"
|
|
|
|
|
echo " RockyLinux 8, 9"
|
|
|
|
|
echo " RHEL 8, 9"
|
|
|
|
|
echo " CloudLinux 8"
|
|
|
|
|
echo " CentOS 9"
|
|
|
|
|
;;
|
|
|
|
|
"")
|
|
|
|
|
install_plugin
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
print_error "Unknown option: $1"
|
|
|
|
|
echo "Use --help for usage information"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2025-09-11 20:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 20:17:54 +02:00
|
|
|
# Run main function
|
|
|
|
|
main "$@"
|