Add installation summary feature to cyberpanel.sh and install.py

Implemented a comprehensive installation summary function in both cyberpanel.sh and install.py. The summary includes installation status, system resource usage, and troubleshooting steps for failed installations. Enhanced user feedback during the installation process to improve clarity and support for users.
This commit is contained in:
Master3395 2025-09-24 00:45:34 +02:00
parent 77a3dc8368
commit 93448a44b3
2 changed files with 211 additions and 4 deletions

View File

@ -2165,13 +2165,125 @@ fi
/usr/local/CyberPanel-venv/bin/python install.py "${Final_Flags[@]}"
# Installation summary function
show_installation_summary() {
local install_status=$1
local start_time=$2
local end_time=$(date +%s)
local elapsed_time=$((end_time - start_time))
local elapsed_minutes=$((elapsed_time / 60))
local elapsed_seconds=$((elapsed_time % 60))
# Get system info
local memory_usage=$(free -m | awk 'NR==2{printf "%s/%sMB (%.1f%%)", $3,$2,$3*100/$2 }')
local disk_usage=$(df -h / | awk 'NR==2{print $5}' | sed 's/%//')
local cpu_cores=$(nproc)
local load_avg=$(uptime | awk -F'load average:' '{print $2}' | awk '{print $1}' | sed 's/,//')
echo ""
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ 📊 CYBERPANEL INSTALLATION SUMMARY ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
if [ "$install_status" = "SUCCESS" ]; then
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ ✅ INSTALLATION STATUS: SUCCESSFUL ║"
echo "║ ║"
echo "║ 🌐 ACCESS YOUR CYBERPANEL: ║"
echo "║ • URL: https://$Server_IP:8090 ║"
echo "║ • Username: admin ║"
if [[ "$Custom_Pass" = "True" ]]; then
echo "║ • Password: ***** (custom password) ║"
else
echo "║ • Password: $Admin_Pass"
fi
echo "║ ║"
echo "║ 🎉 ALL COMPONENTS INSTALLED SUCCESSFULLY! 🎉 ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
else
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ ❌ INSTALLATION STATUS: FAILED ║"
echo "║ ║"
echo "║ 🔍 TROUBLESHOOTING STEPS: ║"
echo "║ 1. Check the installation logs: ║"
echo "║ • Main log: /var/log/installLogs.txt ║"
echo "║ • Debug log: /var/log/cyberpanel/cyberpanel_install_debug_*.log ║"
echo "║ ║"
echo "║ 2. Common issues and solutions: ║"
echo "║ • Insufficient memory: Ensure at least 1GB RAM available ║"
echo "║ • Disk space: Ensure at least 10GB free space ║"
echo "║ • Network issues: Check internet connectivity ║"
echo "║ • Repository errors: Try running 'yum clean all' or 'apt update' ║"
echo "║ ║"
echo "║ 3. Get help: ║"
echo "║ • Community: https://community.cyberpanel.net ║"
echo "║ • Documentation: https://cyberpanel.net/KnowledgeBase/ ║"
echo "║ • GitHub Issues: https://github.com/usmannasir/cyberpanel/issues ║"
echo "║ ║"
echo "║ 🛠️ RETRY INSTALLATION: ║"
echo "║ bash <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh) --debug ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
fi
echo ""
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ 📈 SYSTEM INFORMATION: ║"
echo "║ • OS: $Server_OS $Server_OS_Version"
echo "║ • CPU Cores: $cpu_cores"
echo "║ • Load Average: $load_avg"
echo "║ • Memory Usage: $memory_usage"
echo "║ • Disk Usage: ${disk_usage}% ║"
echo "║ • Install Time: ${elapsed_minutes}m ${elapsed_seconds}s ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
# Show recent errors if installation failed
if [ "$install_status" = "FAILED" ]; then
echo ""
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ 🚨 RECENT ERRORS: ║"
echo "║ ║"
# Show last 10 lines of install log with errors
if [ -f "/var/log/installLogs.txt" ]; then
echo "║ From /var/log/installLogs.txt: ║"
tail -10 /var/log/installLogs.txt | while read line; do
if [ ${#line} -gt 100 ]; then
echo "${line:0:100}... ║"
else
printf "║ %-100s ║\n" "$line"
fi
done
fi
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
fi
echo ""
}
# Record installation start time
INSTALL_START_TIME=$(date +%s)
if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt >/dev/null; then
echo -e "\nCyberPanel installation sucessfully completed...\n"
echo -e "\nCyberPanel installation successfully completed...\n"
Debug_Log2 "Main installation completed...,70"
show_installation_summary "SUCCESS" "$INSTALL_START_TIME"
else
echo -e "Oops, something went wrong..."
Debug_Log2 "Oops, something went wrong... [404]"
exit
echo -e "Installation encountered issues..."
Debug_Log2 "Installation encountered issues... [404]"
show_installation_summary "FAILED" "$INSTALL_START_TIME"
exit 1
fi
}

View File

@ -3693,8 +3693,103 @@ echo $oConfig->Save() ? 'Done' : 'Error';
# These services require database tables that are created by Django migrations
checks.startDeferredServices()
# Installation summary
show_installation_summary()
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!,80")
def show_installation_summary():
"""Display comprehensive installation summary"""
try:
import time
import subprocess
print("\n" + "="*80)
print("📊 CYBERPANEL INSTALLATION SUMMARY")
print("="*80)
# Check component status
components = {
"CyberPanel Core": check_service_status("lscpd"),
"OpenLiteSpeed": check_service_status("lsws"),
"MariaDB/MySQL": check_service_status("mysql") or check_service_status("mariadb"),
"PowerDNS": check_service_status("pdns") or check_service_status("pdns-server"),
"Pure-FTPd": check_service_status("pure-ftpd"),
"Postfix": check_service_status("postfix"),
"Dovecot": check_service_status("dovecot"),
"SnappyMail": check_file_exists("/usr/local/CyberCP/public/snappymail"),
"phpMyAdmin": check_file_exists("/usr/local/CyberCP/public/phpmyadmin")
}
print("\n🔧 COMPONENT STATUS:")
print("-" * 50)
for component, status in components.items():
if status:
print(f"{component:<20} - INSTALLED & RUNNING")
else:
print(f"{component:<20} - NOT AVAILABLE")
# System information
try:
memory_info = subprocess.check_output("free -m", shell=True).decode()
memory_line = [line for line in memory_info.split('\n') if 'Mem:' in line][0]
memory_parts = memory_line.split()
total_mem = memory_parts[1]
used_mem = memory_parts[2]
mem_percent = (int(used_mem) / int(total_mem)) * 100
disk_info = subprocess.check_output("df -h /", shell=True).decode()
disk_line = [line for line in disk_info.split('\n') if '/dev/' in line][0]
disk_parts = disk_line.split()
disk_usage = disk_parts[4]
print(f"\n📈 SYSTEM RESOURCES:")
print(f" • Memory Usage: {used_mem}MB / {total_mem}MB ({mem_percent:.1f}%)")
print(f" • Disk Usage: {disk_usage}")
print(f" • CPU Cores: {subprocess.check_output('nproc', shell=True).decode().strip()}")
except Exception as e:
print(f"\n📈 SYSTEM RESOURCES: Unable to retrieve ({str(e)})")
# Installation time
try:
if hasattr(show_installation_summary, 'start_time'):
elapsed = time.time() - show_installation_summary.start_time
minutes = int(elapsed // 60)
seconds = int(elapsed % 60)
print(f" • Install Time: {minutes}m {seconds}s")
except:
pass
print("\n" + "="*80)
except Exception as e:
print(f"\n⚠️ Could not generate installation summary: {str(e)}")
def check_service_status(service_name):
"""Check if a service is running"""
try:
result = subprocess.run(['systemctl', 'is-active', service_name],
capture_output=True, text=True)
return result.returncode == 0
except:
return False
def check_file_exists(file_path):
"""Check if a file or directory exists"""
try:
return os.path.exists(file_path)
except:
return False
# Set installation start time
import time
show_installation_summary.start_time = time.time()
if __name__ == "__main__":
main()