diff --git a/cyberpanel.sh b/cyberpanel.sh index d578f9149..94e41268c 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -597,6 +597,31 @@ cleanup_existing_cyberpanel() { 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 install_cyberpanel_direct() { echo " 🔄 Downloading CyberPanel installation files..." @@ -635,16 +660,16 @@ install_cyberpanel_direct() { cd "$temp_dir" || return 1 # 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 local installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh" - # Test if the development branch exists - if ! curl -s --head "$installer_url" | grep -q "200 OK"; then + # Test if the development branch exists by trying to download a small file + 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" installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" - else - echo " Using development branch (v2.5.5-dev)" fi 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 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 - ./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 local install_exit_code=${PIPESTATUS[0]} @@ -2030,10 +2055,17 @@ start_reinstall() { # Install 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" - exit 1 -fi + exit 1 + fi echo "" # Apply fixes @@ -2071,7 +2103,14 @@ start_installation() { # Install 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" echo "" echo "Would you like to see troubleshooting help? (y/n) [y]: " @@ -2290,7 +2329,14 @@ main() { install_dependencies # 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" echo "" echo "Would you like to see troubleshooting help? (y/n) [y]: "