mirror of
				https://github.com/usmannasir/cyberpanel.git
				synced 2025-10-31 18:36:17 +01:00 
			
		
		
		
	Add local installation support for CyberPanel
- Introduced a new function to install CyberPanel from a local repository if installation files are available. - Updated the installation flow to prioritize local installation before falling back to the direct download method. - Enhanced error handling to provide clearer feedback if local installation files are not found. - Adjusted the installer script to include branch specification for better version control during installation.
This commit is contained in:
		| @@ -597,6 +597,31 @@ cleanup_existing_cyberpanel() { | |||||||
|     echo "  ✅ Cleanup completed" |     echo "  ✅ Cleanup completed" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # Function to install CyberPanel from local repository | ||||||
|  | install_cyberpanel_local() { | ||||||
|  |     echo "  🔄 Using local CyberPanel repository..." | ||||||
|  |      | ||||||
|  |     # Check if we're running from a cloned repository | ||||||
|  |     if [ -d "install" ] && [ -f "install/install.py" ]; then | ||||||
|  |         echo "  ✓ Found local installation files" | ||||||
|  |         echo "  🔄 Starting CyberPanel installation from local repository..." | ||||||
|  |         echo "" | ||||||
|  |          | ||||||
|  |         # Run the Python installer directly | ||||||
|  |         if [ "$DEBUG_MODE" = true ]; then | ||||||
|  |             python3 install/install.py --debug | ||||||
|  |         else | ||||||
|  |             python3 install/install.py | ||||||
|  |         fi | ||||||
|  |          | ||||||
|  |         return $? | ||||||
|  |     else | ||||||
|  |         echo "  ⚠️  Local installation files not found" | ||||||
|  |         echo "  🔄 Falling back to download method..." | ||||||
|  |         install_cyberpanel_direct | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  |  | ||||||
| # Function to install CyberPanel directly using the working method | # Function to install CyberPanel directly using the working method | ||||||
| install_cyberpanel_direct() { | install_cyberpanel_direct() { | ||||||
|     echo "  🔄 Downloading CyberPanel installation files..." |     echo "  🔄 Downloading CyberPanel installation files..." | ||||||
| @@ -635,16 +660,16 @@ install_cyberpanel_direct() { | |||||||
|     cd "$temp_dir" || return 1 |     cd "$temp_dir" || return 1 | ||||||
|      |      | ||||||
|     # Download the working CyberPanel installation files |     # Download the working CyberPanel installation files | ||||||
|     echo "Downloading from: https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" |     echo "Downloading from: https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh" | ||||||
|     # Try development branch first, fallback to stable |     # Try development branch first, fallback to stable | ||||||
|     local installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh" |     local installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh" | ||||||
|      |      | ||||||
|     # Test if the development branch exists |     # Test if the development branch exists by trying to download a small file | ||||||
|     if ! curl -s --head "$installer_url" | grep -q "200 OK"; then |     if curl -s -f -o /dev/null "https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/README.md"; then | ||||||
|  |         echo "    Using development branch (v2.5.5-dev)" | ||||||
|  |     else | ||||||
|         echo "    Development branch not available, falling back to stable" |         echo "    Development branch not available, falling back to stable" | ||||||
|         installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" |         installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" | ||||||
|     else |  | ||||||
|         echo "    Using development branch (v2.5.5-dev)" |  | ||||||
|     fi |     fi | ||||||
|      |      | ||||||
|     curl --silent -o cyberpanel_installer.sh "$installer_url" 2>/dev/null |     curl --silent -o cyberpanel_installer.sh "$installer_url" 2>/dev/null | ||||||
| @@ -722,9 +747,9 @@ install_cyberpanel_direct() { | |||||||
|  |  | ||||||
|     # Run installer and show live output, capturing the password |     # Run installer and show live output, capturing the password | ||||||
|     if [ "$DEBUG_MODE" = true ]; then |     if [ "$DEBUG_MODE" = true ]; then | ||||||
|         ./cyberpanel_installer.sh --debug 2>&1 | tee /var/log/CyberPanel/install_output.log |         ./cyberpanel_installer.sh --debug --branch "$BRANCH_NAME" 2>&1 | tee /var/log/CyberPanel/install_output.log | ||||||
|     else |     else | ||||||
|         ./cyberpanel_installer.sh 2>&1 | tee /var/log/CyberPanel/install_output.log |         ./cyberpanel_installer.sh --branch "$BRANCH_NAME" 2>&1 | tee /var/log/CyberPanel/install_output.log | ||||||
|     fi |     fi | ||||||
|  |  | ||||||
|     local install_exit_code=${PIPESTATUS[0]} |     local install_exit_code=${PIPESTATUS[0]} | ||||||
| @@ -2030,10 +2055,17 @@ start_reinstall() { | |||||||
|      |      | ||||||
|     # Install CyberPanel |     # Install CyberPanel | ||||||
|     echo "Step 5/6: Installing CyberPanel..." |     echo "Step 5/6: Installing CyberPanel..." | ||||||
|     if ! install_cyberpanel; then |     # Try local installation first if available | ||||||
|  |     if [ -d "install" ] && [ -f "install/install.py" ]; then | ||||||
|  |         install_cyberpanel_local | ||||||
|  |     else | ||||||
|  |         install_cyberpanel_direct | ||||||
|  |     fi | ||||||
|  |      | ||||||
|  |     if [ $? -ne 0 ]; then | ||||||
|         print_status "ERROR: CyberPanel installation failed" |         print_status "ERROR: CyberPanel installation failed" | ||||||
|         exit 1 |         exit 1 | ||||||
| fi |     fi | ||||||
|     echo "" |     echo "" | ||||||
|      |      | ||||||
|     # Apply fixes |     # Apply fixes | ||||||
| @@ -2071,7 +2103,14 @@ start_installation() { | |||||||
|      |      | ||||||
|     # Install CyberPanel |     # Install CyberPanel | ||||||
|     echo "Step 3/6: Installing CyberPanel..." |     echo "Step 3/6: Installing CyberPanel..." | ||||||
|     if ! install_cyberpanel; then |     # Try local installation first if available | ||||||
|  |     if [ -d "install" ] && [ -f "install/install.py" ]; then | ||||||
|  |         install_cyberpanel_local | ||||||
|  |     else | ||||||
|  |         install_cyberpanel_direct | ||||||
|  |     fi | ||||||
|  |      | ||||||
|  |     if [ $? -ne 0 ]; then | ||||||
|         print_status "ERROR: CyberPanel installation failed" |         print_status "ERROR: CyberPanel installation failed" | ||||||
|         echo "" |         echo "" | ||||||
|         echo "Would you like to see troubleshooting help? (y/n) [y]: " |         echo "Would you like to see troubleshooting help? (y/n) [y]: " | ||||||
| @@ -2290,7 +2329,14 @@ main() { | |||||||
|                 install_dependencies |                 install_dependencies | ||||||
|                  |                  | ||||||
|                 # Install CyberPanel |                 # Install CyberPanel | ||||||
|                 if ! install_cyberpanel; then |                 # Try local installation first if available | ||||||
|  |                 if [ -d "install" ] && [ -f "install/install.py" ]; then | ||||||
|  |                     install_cyberpanel_local | ||||||
|  |                 else | ||||||
|  |                     install_cyberpanel_direct | ||||||
|  |                 fi | ||||||
|  |                  | ||||||
|  |                 if [ $? -ne 0 ]; then | ||||||
|                     print_status "ERROR: CyberPanel installation failed" |                     print_status "ERROR: CyberPanel installation failed" | ||||||
|                     echo "" |                     echo "" | ||||||
|                     echo "Would you like to see troubleshooting help? (y/n) [y]: " |                     echo "Would you like to see troubleshooting help? (y/n) [y]: " | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user