diff --git a/CyberCP/urls.py b/CyberCP/urls.py index 18467e668..e6ccfaa15 100644 --- a/CyberCP/urls.py +++ b/CyberCP/urls.py @@ -24,6 +24,13 @@ from firewall import views as firewall_views # includes each installed plugin (under /plugins//) so settings and # other plugin pages work for any installed plugin. +# Optional app: may be missing after clean clone or git clean -fd (not in all repo trees) +_optional_email_marketing = [] +try: + _optional_email_marketing.append(path('emailMarketing/', include('emailMarketing.urls'))) +except ModuleNotFoundError: + pass + urlpatterns = [ # Serve static files first (before catch-all routes) re_path(r'^static/(?P.*)$', serve, {'document_root': settings.STATIC_ROOT}), @@ -47,7 +54,7 @@ urlpatterns = [ path('api/', include('api.urls')), path('filemanager/', include('filemanager.urls')), path('emailPremium/', include('emailPremium.urls')), - path('emailMarketing/', include('emailMarketing.urls')), # Default-installed (sidebar links to it) + *_optional_email_marketing, path('manageservices/', include('manageServices.urls')), path('plugins/', include('pluginHolder.urls')), path('cloudAPI/', include('cloudAPI.urls')), diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 2527c3f0b..b397860a6 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -1395,6 +1395,44 @@ fi echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Main_Upgrade function completed" | tee -a /var/log/cyberpanel_upgrade_debug.log } +# Sync /usr/local/CyberCP to the latest commit of the upgrade branch so Version Management +# page shows Current commit matching Latest (avoids "please upgrade" when upgrade already ran). +# Backs up and restores CyberCP/settings.py so production DB/config are not overwritten by the repo. +Sync_CyberCP_To_Latest() { + if [[ ! -d /usr/local/CyberCP/.git ]]; then + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] No .git in /usr/local/CyberCP, skipping sync" | tee -a /var/log/cyberpanel_upgrade_debug.log + return 0 + fi + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Syncing /usr/local/CyberCP to latest commit for branch: $Branch_Name" | tee -a /var/log/cyberpanel_upgrade_debug.log + # Backup production settings so sync does not overwrite DB credentials / local config + if [[ -f /usr/local/CyberCP/CyberCP/settings.py ]]; then + cp /usr/local/CyberCP/CyberCP/settings.py /tmp/cyberpanel_settings_backup.py + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Backed up settings.py for restore after sync" | tee -a /var/log/cyberpanel_upgrade_debug.log + fi + ( + cd /usr/local/CyberCP + git fetch origin 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log + if git show-ref -q "refs/remotes/origin/$Branch_Name"; then + git checkout -B "$Branch_Name" "origin/$Branch_Name" 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log + else + git checkout "$Branch_Name" 2>/dev/null || true + git pull --ff-only origin "$Branch_Name" 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log || true + fi + ) + local sync_code=$? + # Restore production settings so panel keeps working (DB, secrets, etc.) + if [[ -f /tmp/cyberpanel_settings_backup.py ]]; then + cp /tmp/cyberpanel_settings_backup.py /usr/local/CyberCP/CyberCP/settings.py + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Restored settings.py after sync" | tee -a /var/log/cyberpanel_upgrade_debug.log + fi + if [[ $sync_code -eq 0 ]]; then + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Sync completed. Current HEAD: $(git -C /usr/local/CyberCP rev-parse HEAD 2>/dev/null || echo 'unknown')" | tee -a /var/log/cyberpanel_upgrade_debug.log + else + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Sync returned code $sync_code (non-fatal)" | tee -a /var/log/cyberpanel_upgrade_debug.log + fi + return 0 +} + Post_Upgrade_System_Tweak() { if [[ "$Server_OS" = "CentOS" ]] ; then @@ -1816,6 +1854,7 @@ echo -e " 1. Access your CyberPanel at the URL above" echo -e " 2. Change the default admin password" echo -e " 3. Configure your domains and websites" echo -e " 4. Check system status in the dashboard" +echo -e " 5. Check DB version with: mariadb -V (use mariadb, not mysql, to avoid deprecation warning)" echo -e "\n🧹 Cleaning up temporary files..." rm -rf /root/cyberpanel_upgrade_tmp @@ -1883,6 +1922,8 @@ Pre_Upgrade_Required_Components Main_Upgrade +Sync_CyberCP_To_Latest + Post_Upgrade_System_Tweak Post_Install_Display_Final_Info