Add RESTful API support for listing child domains: Implement listChildDomainsJson endpoint in the API, allowing users to retrieve child domain details with authentication. Update README to document the new API functionality and usage examples. Remove obsolete utility scripts for Windows and Linux to streamline the project.

https://github.com/usmannasir/cyberpanel/issues/1120
This commit is contained in:
Master3395
2025-09-21 19:52:05 +02:00
parent c2b0eb0a20
commit a959efc6a4
9 changed files with 147 additions and 886 deletions

View File

@@ -32,6 +32,53 @@ Web Hosting Control Panel powered by OpenLiteSpeed, designed to simplify hosting
- 🤖 **AI-Powered Security Scanner** for enhanced protection.
- 🔐 **Advanced 2FA Authentication** - TOTP and WebAuthn/Passkey support.
- 📊 **Monthly Bandwidth Reset** - Automatic bandwidth usage reset (Fixed in latest version).
- 🔗 **RESTful API** - Complete API for automation and integration including `listChildDomainsJson` endpoint.
---
## 🔗 **RESTful API**
CyberPanel provides a comprehensive RESTful API for automation and integration:
### **Available API Endpoints**
- **Website Management**: Create, delete, suspend, and manage websites
- **User Management**: Create, delete, and manage user accounts
- **Package Management**: List and manage hosting packages
- **Child Domains**: List child domains with `listChildDomainsJson` endpoint
- **Firewall**: Add and delete firewall rules
- **Backups**: Manage AWS backups and remote transfers
- **System Info**: Get CyberPanel version and system status
### **API Authentication**
All API endpoints require authentication using admin credentials:
```bash
curl -X POST http://your-server:8090/api/listChildDomainsJson \
-H "Content-Type: application/json" \
-d '{
"adminUser": "your_admin_username",
"adminPass": "your_admin_password"
}'
```
### **Response Format**
API responses are returned in JSON format with consistent error handling:
```json
[
{
"parent_site": "example.com",
"domain": "subdomain.example.com",
"path": "/home/example.com/public_html/subdomain",
"ssl": 1,
"php_version": "8.1",
"ip_address": "192.168.1.100"
}
]
```
---
@@ -45,7 +92,6 @@ CyberPanel comes with comprehensive documentation and step-by-step guides:
- 🔐 **[2FA Authentication Guide](guides/2FA_AUTHENTICATION_GUIDE.md)** - Complete Two-Factor Authentication and WebAuthn setup
- 📧 **[Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md)** - Email marketing platform setup
- 🎨 **[Custom CSS Guide](guides/CUSTOM_CSS_GUIDE.md)** - Create custom themes for CyberPanel 2.5.5-dev
- 🛠️ **[Utility Scripts](utils/README.md)** - Installation, upgrade, and maintenance scripts for Windows and Linux
---

View File

@@ -30,6 +30,7 @@ urlpatterns = [
re_path(r'^cyberPanelVersion$', views.cyberPanelVersion, name='cyberPanelVersion'),
re_path(r'^runAWSBackups$', views.runAWSBackups, name='runAWSBackups'),
re_path(r'^submitUserCreation$', views.submitUserCreation, name='submitUserCreation'),
re_path(r'^listChildDomainsJson$', views.listChildDomainsJson, name='listChildDomainsJson'),
# AI Scanner API endpoints for external workers
re_path(r'^ai-scanner/authenticate$', views.aiScannerAuthenticate, name='aiScannerAuthenticateAPI'),

View File

@@ -831,6 +831,84 @@ def submitUserCreation(request):
return HttpResponse(json_data)
@csrf_exempt
def listChildDomainsJson(request):
try:
if request.method != 'POST':
data_ret = {"status": 0, 'error_message': "Only POST method allowed."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=405)
try:
data = json.loads(request.body)
adminUser = data['adminUser']
adminPass = data['adminPass']
# Additional security: validate critical fields for dangerous characters
is_valid, error_msg = validate_api_input(adminUser, "adminUser")
if not is_valid:
data_ret = {"status": 0, 'error_message': error_msg}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=400)
except (json.JSONDecodeError, KeyError):
data_ret = {"status": 0, 'error_message': "Invalid JSON or missing adminUser/adminPass fields."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=400)
try:
admin = Administrator.objects.get(userName=adminUser)
except Administrator.DoesNotExist:
data_ret = {"status": 0, 'error_message': "Administrator not found."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=404)
if admin.api == 0:
data_ret = {"status": 0, 'error_message': "API Access Disabled."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=403)
if not hashPassword.check_password(admin.password, adminPass):
data_ret = {"status": 0, 'error_message': "Invalid password."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=401)
# Get child domains
from websiteFunctions.models import ChildDomains
child_domains = ChildDomains.objects.all()
# Get machine IP
try:
ipFile = "/etc/cyberpanel/machineIP"
with open(ipFile, 'r') as f:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
except BaseException as msg:
logging.writeToFile(f"Failed to read machine IP, error: {str(msg)}")
ipAddress = "192.168.100.1"
json_data = []
for items in child_domains:
dic = {
'parent_site': items.master.domain,
'domain': items.domain,
'path': items.path,
'ssl': items.ssl,
'php_version': items.phpSelection,
'ip_address': ipAddress
}
json_data.append(dic)
final_json = json.dumps(json_data, indent=2)
return HttpResponse(final_json, content_type='application/json')
except Exception as msg:
data_ret = {'status': 0, 'error_message': f"Internal server error: {str(msg)}"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data, status=500)
@csrf_exempt
def addFirewallRule(request):
try:

View File

@@ -142,6 +142,27 @@ class cyberPanel:
logger.writeforCLI(str(msg), "Error", stack()[0][3])
print(0)
def listChildDomainsJson(self):
try:
child_domains = ChildDomains.objects.all()
ipFile = "/etc/cyberpanel/machineIP"
with open(ipFile, 'r') as f:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
json_data = []
for items in child_domains:
dic = {'parent_site': items.master.domain,
'domain': items.domain,
'path': items.path,
'ssl': items.ssl,
'php_version': items.phpSelection}
json_data.append(dic)
final_json = json.dumps(json_data)
print(final_json)
except BaseException as msg:
logger.writeforCLI(str(msg), "Error", stack()[0][3])
print(0)
def listWebsitesPretty(self):
try:
from prettytable import PrettyTable

View File

@@ -1,202 +0,0 @@
# CyberPanel Utility Scripts
This folder contains utility scripts for CyberPanel installation, maintenance, and troubleshooting.
## 📁 Folder Structure
```
utils/
├── README.md # This file
├── windows/ # Windows-specific scripts
│ ├── cyberpanel_install.bat # Windows installation script
│ ├── cyberpanel_upgrade.bat # Windows upgrade script
│ └── install_webauthn.bat # WebAuthn setup for Windows
└── linux/ # Linux-specific scripts
└── install_webauthn.sh # WebAuthn setup for Linux
```
## 🪟 Windows Scripts
**⚠️ IMPORTANT**: These Windows scripts are for **development and testing purposes only**. CyberPanel is designed for Linux systems and does not officially support Windows for production use.
### Development Scripts
#### `cyberpanel_install.bat`
**Purpose**: Set up CyberPanel development environment on Windows
**Requirements**:
- Windows 7/8.1/10/11
- Administrator privileges
- Python 3.8+ installed
- Internet connection
**Limitations**:
- No web server (OpenLiteSpeed/LiteSpeed)
- No system services (MariaDB, PowerDNS)
- Limited functionality
- Development/testing only
**Usage**:
1. Right-click and select "Run as administrator"
2. Follow the on-screen prompts
3. Access CyberPanel at `http://localhost:8090`
**Features**:
- Automatic Python environment setup
- Virtual environment creation
- Source code download
- Requirements installation
- Admin user creation
- Windows service setup
#### `cyberpanel_upgrade.bat`
**Purpose**: Upgrade existing CyberPanel installation
**Requirements**:
- Existing CyberPanel installation
- Administrator privileges
- Internet connection
**Usage**:
1. Right-click and select "Run as administrator"
2. Script will automatically backup and upgrade
3. Restart CyberPanel after completion
**Features**:
- Automatic backup creation
- Source code update
- Requirements upgrade
- Database migration
- Service restart
#### `install_webauthn.bat`
**Purpose**: Set up WebAuthn/Passkey authentication
**Requirements**:
- CyberPanel already installed
- Administrator privileges
**Usage**:
1. Run as administrator
2. Follow configuration prompts
3. Access User Management to enable WebAuthn
## 🐧 Linux Scripts
### Installation Scripts
#### `install_webauthn.sh`
**Purpose**: Set up WebAuthn/Passkey authentication on Linux
**Requirements**:
- CyberPanel installed
- Root privileges
**Usage**:
```bash
sudo ./install_webauthn.sh
```
**Features**:
- Database migration
- Static files setup
- Service configuration
- Permission fixing
## 🚀 Quick Start
### Windows Users
1. **First Installation**:
```cmd
# Run as administrator
cyberpanel_install.bat
```
2. **Upgrade Existing Installation**:
```cmd
# Run as administrator
cyberpanel_upgrade.bat
```
3. **Enable WebAuthn**:
```cmd
# Run as administrator
install_webauthn.bat
```
### Linux Users
1. **Fix Installation Issues**:
```bash
sudo ./fix_cyberpanel_install.sh
```
2. **Enable WebAuthn**:
```bash
sudo ./install_webauthn.sh
```
## 🔧 Troubleshooting
### Common Windows Issues
#### "Python not found" Error
- **Solution**: Install Python 3.8+ from [python.org](https://python.org)
- **Important**: Check "Add Python to PATH" during installation
#### "Access Denied" Error
- **Solution**: Right-click script and select "Run as administrator"
- **Alternative**: Open Command Prompt as administrator
#### "Failed to install requirements" Error
- **Solution**: Check internet connection
- **Alternative**: Try running script again
- **Advanced**: Install requirements manually with pip
### Common Linux Issues
#### "Permission denied" Error
- **Solution**: Run with `sudo` or as root user
- **Example**: `sudo ./script.sh`
#### "Command not found" Error
- **Solution**: Ensure script is executable
- **Fix**: `chmod +x script.sh`
#### "Django not found" Error
- **Solution**: Run the fix script first
- **Alternative**: Reinstall CyberPanel
## 📚 Additional Resources
### Documentation
- **Main Guide**: [2FA Authentication Guide](../guides/2FA_AUTHENTICATION_GUIDE.md)
- **Troubleshooting**: [Troubleshooting Guide](../guides/TROUBLESHOOTING.md)
- **Complete Index**: [Guides Index](../guides/INDEX.md)
### Support
- **CyberPanel Forums**: https://community.cyberpanel.net
- **GitHub Issues**: https://github.com/usmannasir/cyberpanel/issues
- **Discord Server**: https://discord.gg/cyberpanel
## ⚠️ Important Notes
### Security
- Always run scripts as administrator/root when required
- Change default passwords immediately after installation
- Keep CyberPanel updated regularly
### Backups
- The upgrade script automatically creates backups
- Store backups in a safe location
- Test restore procedures regularly
### Compatibility
- Windows scripts tested on Windows 7/8.1/10/11
- Linux scripts tested on Ubuntu, Debian, AlmaLinux, RockyLinux
- Python 3.8+ required for all scripts
---
**Note**: These utility scripts are provided as-is. Always test in a non-production environment first and ensure you have proper backups before running any scripts.
*Last updated: January 2025*

View File

@@ -1,150 +0,0 @@
#!/bin/bash
# WebAuthn Installation Script for CyberPanel
# This script helps install and configure WebAuthn/Passkey authentication
echo "=========================================="
echo "CyberPanel WebAuthn Installation Script"
echo "=========================================="
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (use sudo)"
exit 1
fi
# Check if CyberPanel is installed
if [ ! -d "/usr/local/CyberCP" ]; then
echo "Error: CyberPanel not found at /usr/local/CyberCP"
echo "Please install CyberPanel first"
exit 1
fi
echo "✓ CyberPanel installation found"
# Navigate to CyberPanel directory
cd /usr/local/CyberCP
# Check if Django is available
if ! python3 -c "import django" 2>/dev/null; then
echo "Error: Django not found. Please ensure CyberPanel is properly installed"
exit 1
fi
echo "✓ Django installation found"
# Run database migrations
echo "Running database migrations..."
python3 manage.py makemigrations loginSystem
if [ $? -eq 0 ]; then
echo "✓ Database migrations created"
else
echo "Error: Failed to create migrations"
exit 1
fi
python3 manage.py migrate
if [ $? -eq 0 ]; then
echo "✓ Database migrations applied"
else
echo "Error: Failed to apply migrations"
exit 1
fi
# Check if static files directory exists
if [ ! -d "static/loginSystem" ]; then
echo "Creating static files directory..."
mkdir -p static/loginSystem
fi
# Copy WebAuthn JavaScript file if it doesn't exist
if [ ! -f "static/loginSystem/webauthn.js" ]; then
echo "WebAuthn JavaScript file not found. Please ensure webauthn.js is in static/loginSystem/"
echo "You can copy it from the source files"
fi
# Set proper permissions
echo "Setting file permissions..."
chown -R lscpd:lscpd /usr/local/CyberCP/static/loginSystem/
chmod -R 755 /usr/local/CyberCP/static/loginSystem/
# Test the installation
echo "Testing WebAuthn installation..."
python3 -c "
import sys
sys.path.append('/usr/local/CyberCP')
try:
from loginSystem.webauthn_models import WebAuthnCredential, WebAuthnChallenge, WebAuthnSettings
print('✓ WebAuthn models imported successfully')
except ImportError as e:
print(f'Error importing WebAuthn models: {e}')
sys.exit(1)
try:
from loginSystem.webauthn_backend import WebAuthnBackend
backend = WebAuthnBackend()
print('✓ WebAuthn backend initialized successfully')
except Exception as e:
print(f'Error initializing WebAuthn backend: {e}')
sys.exit(1)
"
if [ $? -eq 0 ]; then
echo "✓ WebAuthn installation test passed"
else
echo "Error: WebAuthn installation test failed"
exit 1
fi
# Create configuration file
echo "Creating WebAuthn configuration..."
cat > /usr/local/CyberCP/webauthn_config.py << 'EOF'
# WebAuthn Configuration for CyberPanel
# Update these values according to your setup
WEBAUTHN_CONFIG = {
'RP_ID': 'cyberpanel.local', # Replace with your actual domain
'RP_NAME': 'CyberPanel',
'ORIGIN': 'https://cyberpanel.local:8090', # Replace with your actual origin
'CHALLENGE_TIMEOUT': 300, # 5 minutes
'MAX_CREDENTIALS_PER_USER': 10,
'DEFAULT_TIMEOUT_SECONDS': 60,
}
# Instructions:
# 1. Update RP_ID to your actual domain (e.g., 'yourdomain.com')
# 2. Update ORIGIN to your actual origin (e.g., 'https://yourdomain.com:8090')
# 3. Restart CyberPanel after making changes
EOF
echo "✓ Configuration file created at /usr/local/CyberCP/webauthn_config.py"
# Restart CyberPanel services
echo "Restarting CyberPanel services..."
systemctl restart lscpd
if [ $? -eq 0 ]; then
echo "✓ CyberPanel services restarted"
else
echo "Warning: Failed to restart CyberPanel services. Please restart manually"
fi
echo ""
echo "=========================================="
echo "WebAuthn Installation Complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Update the configuration file: /usr/local/CyberCP/webauthn_config.py"
echo "2. Replace 'cyberpanel.local' with your actual domain"
echo "3. Replace 'https://cyberpanel.local:8090' with your actual origin"
echo "4. Restart CyberPanel: systemctl restart lscpd"
echo "5. Access CyberPanel and go to User Management to enable WebAuthn"
echo ""
echo "Features available:"
echo "- Passkey registration and management"
echo "- Passwordless login option"
echo "- Multiple device support"
echo "- Admin management interface"
echo ""
echo "For more information, see: /usr/local/CyberCP/to-do/WEBAUTHN_IMPLEMENTATION.md"
echo ""

View File

@@ -1,241 +0,0 @@
@echo off
REM CyberPanel Windows Installation Script
REM This script installs CyberPanel on Windows systems
echo ==========================================
echo CyberPanel Windows Installation Script
echo ==========================================
echo.
REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo ERROR: This script must be run as administrator
echo Please right-click and select "Run as administrator"
pause
exit /b 1
)
echo [OK] Running with administrator privileges
echo.
REM Check Windows version
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if "%VERSION%" == "10.0" (
echo [OK] Windows 10/11 detected
) else if "%VERSION%" == "6.3" (
echo [OK] Windows 8.1 detected
) else if "%VERSION%" == "6.1" (
echo [OK] Windows 7 detected
) else (
echo [WARNING] Unsupported Windows version detected: %VERSION%
echo CyberPanel may not work properly on this version
pause
)
echo.
echo Checking system requirements...
REM Check if Python is installed
python --version >nul 2>&1
if %errorLevel% neq 0 (
echo [ERROR] Python is not installed or not in PATH
echo Please install Python 3.8+ from https://python.org
echo Make sure to check "Add Python to PATH" during installation
pause
exit /b 1
) else (
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Python %PYTHON_VERSION% found
)
REM Check if pip is available
pip --version >nul 2>&1
if %errorLevel% neq 0 (
echo [ERROR] pip is not available
echo Please install pip or reinstall Python with pip
pause
exit /b 1
) else (
echo [OK] pip is available
)
REM Check available disk space
for /f "tokens=3" %%i in ('dir /-c %SystemDrive%\ ^| find "bytes free"') do set FREE_SPACE=%%i
if %FREE_SPACE% LSS 10737418240 (
echo [WARNING] Less than 10GB free space available
echo CyberPanel requires at least 10GB of free space
pause
)
echo.
echo ==========================================
echo CyberPanel Installation
echo ==========================================
echo.
REM Create CyberPanel directory
set CYBERPANEL_DIR=C:\usr\local\CyberCP
if not exist "%CYBERPANEL_DIR%" (
echo Creating CyberPanel directory...
mkdir "%CYBERPANEL_DIR%" 2>nul
if %errorLevel% neq 0 (
echo [ERROR] Failed to create directory %CYBERPANEL_DIR%
echo Please ensure you have sufficient permissions
pause
exit /b 1
)
echo [OK] Directory created: %CYBERPANEL_DIR%
) else (
echo [OK] Directory already exists: %CYBERPANEL_DIR%
)
REM Navigate to CyberPanel directory
cd /d "%CYBERPANEL_DIR%"
REM Create virtual environment
echo Creating Python virtual environment...
python -m venv . --system-site-packages
if %errorLevel% neq 0 (
echo [ERROR] Failed to create virtual environment
pause
exit /b 1
)
echo [OK] Virtual environment created
REM Activate virtual environment
echo Activating virtual environment...
call Scripts\activate.bat
if %errorLevel% neq 0 (
echo [ERROR] Failed to activate virtual environment
pause
exit /b 1
)
echo [OK] Virtual environment activated
REM Upgrade pip
echo Upgrading pip...
python -m pip install --upgrade pip setuptools wheel
if %errorLevel% neq 0 (
echo [WARNING] Failed to upgrade pip, continuing anyway...
)
REM Download CyberPanel source
echo Downloading CyberPanel source code...
if exist "cyberpanel" (
echo [INFO] CyberPanel source already exists, updating...
cd cyberpanel
git pull origin stable
if %errorLevel% neq 0 (
echo [WARNING] Failed to update source, using existing version
)
cd ..
) else (
echo Cloning CyberPanel repository...
git clone https://github.com/usmannasir/cyberpanel.git
if %errorLevel% neq 0 (
echo [ERROR] Failed to clone CyberPanel repository
echo Please check your internet connection
pause
exit /b 1
)
echo [OK] Source code downloaded
)
REM Navigate to CyberPanel source
cd cyberpanel
REM Install requirements
echo Installing Python requirements...
echo This may take several minutes...
pip install --default-timeout=3600 -r requirments.txt
if %errorLevel% neq 0 (
echo [ERROR] Failed to install requirements
echo Please check your internet connection and try again
pause
exit /b 1
)
echo [OK] Requirements installed
REM Create necessary directories
echo Creating necessary directories...
if not exist "static" mkdir static
if not exist "logs" mkdir logs
if not exist "static\loginSystem" mkdir static\loginSystem
if not exist "static\userManagment" mkdir static\userManagment
echo [OK] Directories created
REM Set up Django
echo Setting up Django...
python manage.py collectstatic --noinput
if %errorLevel% neq 0 (
echo [WARNING] Failed to collect static files, continuing...
)
REM Create superuser (optional)
echo.
echo ==========================================
echo User Account Setup
echo ==========================================
echo.
set /p CREATE_ADMIN="Do you want to create an admin user now? (y/n): "
if /i "%CREATE_ADMIN%"=="y" (
echo Creating admin user...
python manage.py createsuperuser
if %errorLevel% neq 0 (
echo [WARNING] Failed to create superuser
echo You can create one later with: python manage.py createsuperuser
) else (
echo [OK] Admin user created
)
) else (
echo [INFO] Skipping admin user creation
echo You can create one later with: python manage.py createsuperuser
)
REM Create startup script
echo Creating startup script...
(
echo @echo off
echo cd /d "%CYBERPANEL_DIR%\cyberpanel"
echo call ..\Scripts\activate.bat
echo python manage.py runserver 0.0.0.0:8090
) > start_cyberpanel.bat
REM Create service script
echo Creating Windows service script...
(
echo @echo off
echo REM CyberPanel Windows Service
echo net start CyberPanel
echo if %%errorLevel%% neq 0 ^(
echo echo Starting CyberPanel service...
echo sc create CyberPanel binPath= "%CYBERPANEL_DIR%\cyberpanel\start_cyberpanel.bat" start= auto
echo sc start CyberPanel
echo ^)
) > install_service.bat
echo.
echo ==========================================
echo Installation Complete!
echo ==========================================
echo.
echo CyberPanel has been installed to: %CYBERPANEL_DIR%\cyberpanel
echo.
echo To start CyberPanel:
echo 1. Run: start_cyberpanel.bat
echo 2. Open your browser to: http://localhost:8090
echo.
echo To install as Windows service:
echo 1. Run: install_service.bat as administrator
echo.
echo Default login credentials:
echo Username: admin
echo Password: 123456
echo.
echo IMPORTANT: Change the default password immediately!
echo.
echo For more information, see the documentation at:
echo https://cyberpanel.net/docs/
echo.
pause

View File

@@ -1,165 +0,0 @@
@echo off
REM CyberPanel Windows Upgrade Script
REM This script upgrades an existing CyberPanel installation
echo ==========================================
echo CyberPanel Windows Upgrade Script
echo ==========================================
echo.
REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo ERROR: This script must be run as administrator
echo Please right-click and select "Run as administrator"
pause
exit /b 1
)
echo [OK] Running with administrator privileges
echo.
REM Check if CyberPanel is installed
set CYBERPANEL_DIR=C:\usr\local\CyberCP
if not exist "%CYBERPANEL_DIR%" (
echo [ERROR] CyberPanel not found at %CYBERPANEL_DIR%
echo Please run the installation script first
pause
exit /b 1
)
echo [OK] CyberPanel installation found
echo.
REM Create backup
echo Creating backup of current installation...
set BACKUP_DIR=%CYBERPANEL_DIR%_backup_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set BACKUP_DIR=%BACKUP_DIR: =0%
if exist "%BACKUP_DIR%" rmdir /s /q "%BACKUP_DIR%"
xcopy "%CYBERPANEL_DIR%" "%BACKUP_DIR%" /E /I /H /Y >nul
if %errorLevel% neq 0 (
echo [WARNING] Failed to create backup, continuing anyway...
) else (
echo [OK] Backup created: %BACKUP_DIR%
)
REM Navigate to CyberPanel directory
cd /d "%CYBERPANEL_DIR%"
REM Activate virtual environment
echo Activating virtual environment...
if not exist "Scripts\activate.bat" (
echo [ERROR] Virtual environment not found
echo Please reinstall CyberPanel
pause
exit /b 1
)
call Scripts\activate.bat
if %errorLevel% neq 0 (
echo [ERROR] Failed to activate virtual environment
pause
exit /b 1
)
echo [OK] Virtual environment activated
REM Navigate to CyberPanel source
cd cyberpanel
REM Stop any running CyberPanel processes
echo Stopping CyberPanel processes...
taskkill /f /im python.exe 2>nul
taskkill /f /im lscpd.exe 2>nul
echo [OK] Processes stopped
REM Update source code
echo Updating CyberPanel source code...
git fetch origin
if %errorLevel% neq 0 (
echo [WARNING] Failed to fetch updates, continuing with current version...
) else (
git reset --hard origin/stable
if %errorLevel% neq 0 (
echo [WARNING] Failed to reset to latest version, continuing...
) else (
echo [OK] Source code updated
)
)
REM Upgrade pip and requirements
echo Upgrading Python packages...
python -m pip install --upgrade pip setuptools wheel
if %errorLevel% neq 0 (
echo [WARNING] Failed to upgrade pip, continuing...
)
REM Install/upgrade requirements
echo Installing/upgrading requirements...
pip install --upgrade --default-timeout=3600 -r requirments.txt
if %errorLevel% neq 0 (
echo [ERROR] Failed to install/upgrade requirements
echo Please check your internet connection and try again
pause
exit /b 1
)
echo [OK] Requirements updated
REM Run database migrations
echo Running database migrations...
python manage.py makemigrations
if %errorLevel% neq 0 (
echo [WARNING] Failed to create migrations, continuing...
) else (
python manage.py migrate
if %errorLevel% neq 0 (
echo [WARNING] Failed to apply migrations, continuing...
) else (
echo [OK] Database migrations completed
)
)
REM Collect static files
echo Collecting static files...
python manage.py collectstatic --noinput
if %errorLevel% neq 0 (
echo [WARNING] Failed to collect static files, continuing...
) else (
echo [OK] Static files collected
)
REM Update startup script
echo Updating startup script...
(
echo @echo off
echo cd /d "%CYBERPANEL_DIR%\cyberpanel"
echo call ..\Scripts\activate.bat
echo python manage.py runserver 0.0.0.0:8090
) > start_cyberpanel.bat
REM Test installation
echo Testing installation...
python manage.py check
if %errorLevel% neq 0 (
echo [WARNING] Installation check failed, but continuing...
) else (
echo [OK] Installation check passed
)
echo.
echo ==========================================
echo Upgrade Complete!
echo ==========================================
echo.
echo CyberPanel has been upgraded successfully
echo.
echo To start CyberPanel:
echo 1. Run: start_cyberpanel.bat
echo 2. Open your browser to: http://localhost:8090
echo.
echo Backup location: %BACKUP_DIR%
echo.
echo If you encounter any issues, you can restore from backup:
echo 1. Stop CyberPanel
echo 2. Delete current installation
echo 3. Restore from backup directory
echo.
pause

View File

@@ -1,127 +0,0 @@
@echo off
REM WebAuthn Installation Script for CyberPanel (Windows)
REM This script helps install and configure WebAuthn/Passkey authentication
echo ==========================================
echo CyberPanel WebAuthn Installation Script
echo ==========================================
REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Please run as administrator
pause
exit /b 1
)
REM Check if CyberPanel is installed
if not exist "C:\usr\local\CyberCP" (
echo Error: CyberPanel not found at C:\usr\local\CyberCP
echo Please install CyberPanel first
pause
exit /b 1
)
echo [OK] CyberPanel installation found
REM Navigate to CyberPanel directory
cd /d C:\usr\local\CyberCP
REM Check if Python is available
python --version >nul 2>&1
if %errorLevel% neq 0 (
echo Error: Python not found. Please ensure CyberPanel is properly installed
pause
exit /b 1
)
echo [OK] Python installation found
REM Run database migrations
echo Running database migrations...
python manage.py makemigrations loginSystem
if %errorLevel% equ 0 (
echo [OK] Database migrations created
) else (
echo Error: Failed to create migrations
pause
exit /b 1
)
python manage.py migrate
if %errorLevel% equ 0 (
echo [OK] Database migrations applied
) else (
echo Error: Failed to apply migrations
pause
exit /b 1
)
REM Check if static files directory exists
if not exist "static\loginSystem" (
echo Creating static files directory...
mkdir static\loginSystem
)
REM Check if WebAuthn JavaScript file exists
if not exist "static\loginSystem\webauthn.js" (
echo Warning: WebAuthn JavaScript file not found
echo Please ensure webauthn.js is in static\loginSystem\
echo You can copy it from the source files
)
REM Test the installation
echo Testing WebAuthn installation...
python -c "import sys; sys.path.append('C:/usr/local/CyberCP'); from loginSystem.webauthn_models import WebAuthnCredential, WebAuthnChallenge, WebAuthnSettings; print('[OK] WebAuthn models imported successfully')"
if %errorLevel% equ 0 (
echo [OK] WebAuthn installation test passed
) else (
echo Error: WebAuthn installation test failed
pause
exit /b 1
)
REM Create configuration file
echo Creating WebAuthn configuration...
(
echo # WebAuthn Configuration for CyberPanel
echo # Update these values according to your setup
echo.
echo WEBAUTHN_CONFIG = {
echo 'RP_ID': 'cyberpanel.local', # Replace with your actual domain
echo 'RP_NAME': 'CyberPanel',
echo 'ORIGIN': 'https://cyberpanel.local:8090', # Replace with your actual origin
echo 'CHALLENGE_TIMEOUT': 300, # 5 minutes
echo 'MAX_CREDENTIALS_PER_USER': 10,
echo 'DEFAULT_TIMEOUT_SECONDS': 60,
echo }
echo.
echo # Instructions:
echo # 1. Update RP_ID to your actual domain ^(e.g., 'yourdomain.com'^)
echo # 2. Update ORIGIN to your actual origin ^(e.g., 'https://yourdomain.com:8090'^)
echo # 3. Restart CyberPanel after making changes
) > webauthn_config.py
echo [OK] Configuration file created at C:\usr\local\CyberCP\webauthn_config.py
echo.
echo ==========================================
echo WebAuthn Installation Complete!
echo ==========================================
echo.
echo Next steps:
echo 1. Update the configuration file: C:\usr\local\CyberCP\webauthn_config.py
echo 2. Replace 'cyberpanel.local' with your actual domain
echo 3. Replace 'https://cyberpanel.local:8090' with your actual origin
echo 4. Restart CyberPanel services
echo 5. Access CyberPanel and go to User Management to enable WebAuthn
echo.
echo Features available:
echo - Passkey registration and management
echo - Passwordless login option
echo - Multiple device support
echo - Admin management interface
echo.
echo For more information, see: C:\usr\local\CyberCP\to-do\WEBAUTHN_IMPLEMENTATION.md
echo.
pause