usmannasir / cyberpanel

Cyber Panel - The hosting control panel for OpenLiteSpeed
GNU General Public License v3.0
1.6k stars 612 forks source link

Simple fix for CSF #1328

Closed SaJeTek-Developer closed 1 month ago

SaJeTek-Developer commented 1 month ago

Describe the bug Cyberpanel has disabled csf as there is an issue with the csf Cyberpanel install. However the issue is quite minor and Cyberpanel can make a small adjustment to have it work instead of disabling it totally.

After upgrading to 2.3.7 and enabling Debugging, I manually installed csf in Cyberpanel which caused an error. There are 2 issues with configserver:

  1. Using urls which is removed in Django 4
  2. There is a circular import in /usr/local/CyberCP/configservercsf/apps.py

Solution I know this is not your job to do but: A simple sed would suffice and allow csf to load instead of totally disabling CSF. These commands can run after installing CSF from the panel

sed -i "s/url(r'^configservercsf/path('configservercsf/g" /usr/local/CyberCP/CyberCP/urls.py sed -i "s/from django.conf.urls import url/from django.urls import path/g" /usr/local/CyberCP/configservercsf/urls.py sed -i "s/import signals/import configservercsf.signals/g" /usr/local/CyberCP/configservercsf/apps.py sed -i "s/url(r'^$'/path(''/g" /usr/local/CyberCP/configservercsf/urls.py sed -i "s|url(r'^iframe/\$'|path('iframe/'|g" /usr/local/CyberCP/configservercsf/urls.py `

Operating system: Almalinux 8.10 Almalinux 9.4 Ubuntu 20.04

CyberPanel version: 2.3.7

SaJeTek-Developer commented 1 month ago

I am currently using a script which does this for me and also restores my csf configurated which is stored in a zip file.

sh <(curl https://sajetekengineering.com/wp-content/uploads/cyberpanel/install_csf_cyberpanel.sh || wget -O - https://sajetekengineering.com/wp-content/uploads/cyberpanel/install_csf_cyberpanel.sh)

The script will ask for the absolute path of my zip file, install csf and restore my configurations. The issue is, that a backup of csf has to be done every time before upgrading Cyberpanel and the script also has to be run after upgrading since the Cyberpanel upgrade script removes csf.

SaJeTek-Developer commented 1 month ago

I've submitted my findings to Configserver who will provide a fix for the issues. I've also submitted a fix for the menu which get's truncated on the Configserver page.

All fixes are added to the script.

usmannasir commented 1 month ago

it is added, thanks alot @SaJeTek-Developer

SaJeTek-Developer commented 1 month ago

Hi @usmannasir can you also add the fix for the menu. Their current implementation breaks the side menu.

sed -i -E "s/from.*, response/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py
sed -i -E "s#^(\s*)return render.*index\.html.*#\1proc = httpProc(request, 'configservercsf/index.html', None, 'admin')\n\1return proc.render()#g" /usr/local/CyberCP/configservercsf/views.py
usmannasir commented 1 month ago

it is done, thank you

SaJeTek-Developer commented 1 month ago

Hi @usmannasir

There was a mistype: Please change response to render: i.e. change

sed -i -E "s/from.*, response/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py to sed -i -E "s/from.*, render/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py