usmannasir / cyberpanel

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

[BUG] Al9 Upgrading overwrites settings.py #1291

Closed SaJeTek-Developer closed 4 months ago

SaJeTek-Developer commented 4 months ago

Describe the bug When you run the upgrade script, it overwrites all files in /usr/local/CyberCP/CyberCP which causes the upgrade to fail and also causes the backend to be inaccessible. This is due to the difference in DB credentials in the settings.py file.

To Reproduce What steps did you take when the issue occurred?

  1. Run the upgrade script

Operating system: Almalinux 9

CyberPanel version: 2.3.5

Additional context One workaround for now is for me to set the immutable atttribute on my settings.py file before running the upgrade script. chattr +i /usr/local/CyberCP/CyberCP/settings.py

I was able to pull my credentials back from /root/.my.cnf and /etc/pure-ftpd/pureftpd-mysql.conf

usmannasir commented 4 months ago

Hi,

When CyberPanel upgrades it saves credentials and repopulate this file. Because sometimes there are changes to settings.py, so you should not chattr it.

thanks

SaJeTek-Developer commented 4 months ago

So What I would have done is to run the update which updated the settings.py file which in turn crashed the installation. Then put back my credentials and chattr the file and rerun the update which completed successfully then remove the chattr.

This was how I was able to successfully update.

There should be a way for the upgrade script to preserver the user's DB credentials when updating that file. That should fix the issue.

usmannasir commented 4 months ago

As you can see it is done here: https://github.com/usmannasir/cyberpanel/blob/106420aa01cd8dbfe606a2439eac70e5d7eb5e17/plogical/upgrade.py#L2098

SaJeTek-Developer commented 4 months ago

Yes it's there but it doesn't seem to be taking effect. I ran the update again and the issue persists.

I to replicate on another machine tomorrow running Almalinux 9

SaJeTek-Developer commented 4 months ago

Unable to replicate on another machine with Almalinux 9. I was able to narrow down the issue and resolve.