@@ -3895,91 +3895,24 @@ def upgrade(branch):
3895
3895
except :
3896
3896
pass
3897
3897
3898
- #command = 'csf -uf'
3899
- #Upgrade.executioner(command, 'fix csf if there', 0)
3900
-
3898
+ # Remove CSF if installed and restore firewalld (CSF is being discontinued on August 31, 2025)
3901
3899
if os .path .exists ('/etc/csf' ):
3902
- ##### Function to backup custom csf files and restore
3903
-
3904
- from datetime import datetime
3905
-
3906
- # List of files to backup
3907
- FILES = [
3908
- "/etc/csf/csf.allow" ,
3909
- "/etc/csf/csf.deny" ,
3910
- "/etc/csf/csf.conf" ,
3911
- "/etc/csf/csf.ignore" ,
3912
- "/etc/csf/csf.rignore" ,
3913
- "/etc/csf/csf.blocklists" ,
3914
- "/etc/csf/csf.dyndns"
3915
- ]
3916
-
3917
- # Directory for backups
3918
- BACKUP_DIR = f"/home/cyberpanel/csf_backup_{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} "
3919
-
3920
- # Backup function
3921
- def backup_files ():
3922
- os .makedirs (BACKUP_DIR , exist_ok = True )
3923
- for file in FILES :
3924
- if os .path .exists (file ):
3925
- shutil .copy (file , BACKUP_DIR )
3926
- print (f"Backed up: { file } " )
3927
- else :
3928
- print (f"File not found, skipping: { file } " )
3929
-
3930
- # Restore function
3931
- def restore_files ():
3932
- for file in FILES :
3933
- backup_file = os .path .join (BACKUP_DIR , os .path .basename (file ))
3934
- if os .path .exists (backup_file ):
3935
- try :
3936
- shutil .copy (backup_file , file )
3937
- print (f"Restored: { file } " )
3938
- except Exception as e :
3939
- print (f"Failed to restore { file } : { str (e )} " )
3940
- else :
3941
- print (f"Backup not found for: { file } " )
3942
-
3943
- # Backup the files
3944
- print ("Backing up files..." )
3945
- backup_files ()
3946
-
3900
+ print ("CSF detected - removing CSF and restoring firewalld..." )
3901
+ print ("Note: ConfigServer Firewall (CSF) is being discontinued on August 31, 2025" )
3902
+
3903
+ # Remove CSF and restore firewalld
3947
3904
execPath = "sudo /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/csf.py"
3948
3905
execPath = execPath + " removeCSF"
3949
- Upgrade .executioner (execPath , 'Remove CSF before reinstall' , 0 )
3950
-
3951
- execPath = "sudo /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/csf.py"
3952
- execPath = execPath + " installCSF"
3953
- Upgrade .executioner (execPath , 'Install CSF' , 0 )
3954
-
3955
- # Restore the files AFTER installation
3956
- print ("Restoring CSF configuration files..." )
3957
- restore_files ()
3906
+ Upgrade .executioner (execPath , 'Remove CSF and restore firewalld' , 0 )
3958
3907
3959
- # Restart CSF to apply restored configuration
3960
- command = 'csf -r'
3961
- Upgrade .executioner (command , 'Restart CSF with restored config' , 0 )
3908
+ print ("CSF has been removed and firewalld has been restored." )
3962
3909
3963
3910
3964
3911
3912
+ # Remove configservercsf directory if it exists
3965
3913
if os .path .exists ('/usr/local/CyberCP/configservercsf' ):
3966
- command = 'rm -f /usr/local/CyberCP/configservercsf/signals.py'
3967
- Upgrade .executioner (command , 'remove /usr/local/CyberCP/configservercsf/signals.py' , 1 )
3968
-
3969
- sed_commands = [
3970
- 'sed -i "s/url(r\' ^configservercsf/path(\' configservercsf/g" /usr/local/CyberCP/CyberCP/urls.py' ,
3971
- 'sed -i "s/from django.conf.urls import url/from django.urls import path/g" /usr/local/CyberCP/configservercsf/urls.py' ,
3972
- 'sed -i "s/import signals/from . import signals/g" /usr/local/CyberCP/configservercsf/apps.py' ,
3973
- 'sed -i "s/url(r\' ^$\' /path(\' \' /g" /usr/local/CyberCP/configservercsf/urls.py' ,
3974
- 'sed -i "s|url(r\' ^iframe/$\' |path(\' iframe/\' |g" /usr/local/CyberCP/configservercsf/urls.py' ,
3975
- 'sed -i -E "s/from.*, response/from plogical.httpProc import httpProc/g" /usr/local/CyberCP/configservercsf/views.py' ,
3976
- 'find /usr/local/CyberCP -name "*.pyc" -delete' ,
3977
- 'find /usr/local/CyberCP -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true' ,
3978
- 'killall lswsgi'
3979
- ]
3980
-
3981
- for cmd in sed_commands :
3982
- Upgrade .executioner (cmd , 'fix csf if there' , 1 )
3914
+ command = 'rm -rf /usr/local/CyberCP/configservercsf'
3915
+ Upgrade .executioner (command , 'Remove configservercsf directory' , 1 )
3983
3916
3984
3917
3985
3918
0 commit comments