mirror of
				https://github.com/usmannasir/cyberpanel.git
				synced 2025-10-31 10:26:01 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import CyberCPLogFileWriter as logging
 | |
| import subprocess
 | |
| import shlex
 | |
| 
 | |
| class modSec:
 | |
|     installLogPath = "/home/cyberpanel/modSecInstallLog"
 | |
| 
 | |
|     @staticmethod
 | |
|     def installModSec(install, modSecInstall):
 | |
|         try:
 | |
| 
 | |
|             command = 'sudo yum install ols-modsecurity -y'
 | |
| 
 | |
|             cmd = shlex.split(command)
 | |
| 
 | |
|             with open(modSec.installLogPath, 'w') as f:
 | |
|                 res = subprocess.call(cmd, stdout=f)
 | |
| 
 | |
|             if res == 1:
 | |
|                 writeToFile = open(modSec.installLogPath, 'a')
 | |
|                 writeToFile.writelines("Can not be installed.[404]\n")
 | |
|                 writeToFile.close()
 | |
|                 logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
 | |
|                 return 0
 | |
|             else:
 | |
|                 writeToFile = open(modSec.installLogPath, 'a')
 | |
|                 writeToFile.writelines("ModSecurity Installed.[200]\n")
 | |
|                 writeToFile.close()
 | |
| 
 | |
|             return 1
 | |
|         except BaseException, msg:
 | |
|             logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installModSec]") |