mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
This commit is contained in:
@@ -1352,12 +1352,6 @@ Automatic backup failed for %s on %s.
|
|||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
print("Version ID Error: %s"%str(msg))
|
print("Version ID Error: %s"%str(msg))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
print('%s. [SendToS3Cloud]' % (str(msg)))
|
print('%s. [SendToS3Cloud]' % (str(msg)))
|
||||||
logging.writeToFile('%s. [SendToS3Cloud]' % (str(msg)))
|
logging.writeToFile('%s. [SendToS3Cloud]' % (str(msg)))
|
||||||
|
|||||||
@@ -547,21 +547,36 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp-modsecurity-crs-3.0-mas
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def disableOWASP():
|
def disableOWASP():
|
||||||
try:
|
try:
|
||||||
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
|
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||||
|
confData = open(confFile).readlines()
|
||||||
|
conf = open(confFile, 'w')
|
||||||
|
|
||||||
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
for items in confData:
|
||||||
confData = open(confFile).readlines()
|
if items.find('modsec/owasp') > -1:
|
||||||
conf = open(confFile, 'w')
|
continue
|
||||||
|
else:
|
||||||
|
conf.writelines(items)
|
||||||
|
|
||||||
for items in confData:
|
conf.close()
|
||||||
if items.find('modsec/owasp') > -1:
|
installUtilities.reStartLiteSpeed()
|
||||||
continue
|
|
||||||
else:
|
|
||||||
conf.writelines(items)
|
|
||||||
|
|
||||||
conf.close()
|
print("1,None")
|
||||||
installUtilities.reStartLiteSpeed()
|
else:
|
||||||
|
confFile = os.path.join("/usr/local/lsws/conf/modsec.conf")
|
||||||
|
confData = open(confFile).readlines()
|
||||||
|
conf = open(confFile, 'w')
|
||||||
|
|
||||||
print("1,None")
|
for items in confData:
|
||||||
|
if items.find('modsec/owasp') > -1:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
conf.writelines(items)
|
||||||
|
|
||||||
|
conf.close()
|
||||||
|
installUtilities.reStartLiteSpeed()
|
||||||
|
|
||||||
|
print("1,None")
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
logging.CyberCPLogFileWriter.writeToFile(
|
||||||
|
|||||||
@@ -1286,42 +1286,48 @@ class WebsiteManager:
|
|||||||
|
|
||||||
RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
|
RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
|
||||||
Rconfig = json.loads(RemoteBackupConfigobj.config)
|
Rconfig = json.loads(RemoteBackupConfigobj.config)
|
||||||
provider = Rconfig['Provider']
|
|
||||||
if provider == "Backblaze":
|
|
||||||
EndURl = Rconfig['EndUrl']
|
|
||||||
elif provider == "Amazon":
|
|
||||||
EndURl = "https://s3.us-east-1.amazonaws.com"
|
|
||||||
elif provider == "Wasabi":
|
|
||||||
EndURl = "https://s3.wasabisys.com"
|
|
||||||
|
|
||||||
AccessKey = Rconfig['AccessKey']
|
|
||||||
SecertKey = Rconfig['SecertKey']
|
|
||||||
|
|
||||||
session = boto3.session.Session()
|
|
||||||
|
|
||||||
client = session.client(
|
|
||||||
's3',
|
|
||||||
endpoint_url=EndURl,
|
|
||||||
aws_access_key_id=AccessKey,
|
|
||||||
aws_secret_access_key=SecertKey,
|
|
||||||
verify=False
|
|
||||||
)
|
|
||||||
|
|
||||||
############Creating Bucket
|
|
||||||
BucketName = randomPassword.generate_pass().lower()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.create_bucket(Bucket=BucketName)
|
#This code is only supposed to run if backups are s3, not for SFTP
|
||||||
except BaseException as msg:
|
provider = Rconfig['Provider']
|
||||||
logging.CyberCPLogFileWriter.writeToFile("Creating Bucket Error: %s" % str(msg))
|
if provider == "Backblaze":
|
||||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
EndURl = Rconfig['EndUrl']
|
||||||
json_data = json.dumps(data_ret)
|
elif provider == "Amazon":
|
||||||
return HttpResponse(json_data)
|
EndURl = "https://s3.us-east-1.amazonaws.com"
|
||||||
|
elif provider == "Wasabi":
|
||||||
|
EndURl = "https://s3.wasabisys.com"
|
||||||
|
|
||||||
config = {
|
AccessKey = Rconfig['AccessKey']
|
||||||
'BackupType': BackupType,
|
SecertKey = Rconfig['SecertKey']
|
||||||
'BucketName': BucketName
|
|
||||||
}
|
session = boto3.session.Session()
|
||||||
|
|
||||||
|
client = session.client(
|
||||||
|
's3',
|
||||||
|
endpoint_url=EndURl,
|
||||||
|
aws_access_key_id=AccessKey,
|
||||||
|
aws_secret_access_key=SecertKey,
|
||||||
|
verify=False
|
||||||
|
)
|
||||||
|
|
||||||
|
############Creating Bucket
|
||||||
|
BucketName = randomPassword.generate_pass().lower()
|
||||||
|
|
||||||
|
try:
|
||||||
|
client.create_bucket(Bucket=BucketName)
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile("Creating Bucket Error: %s" % str(msg))
|
||||||
|
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
config = {
|
||||||
|
'BackupType': BackupType,
|
||||||
|
'BucketName': BucketName
|
||||||
|
}
|
||||||
|
except BaseException as msg:
|
||||||
|
config = {}
|
||||||
|
pass
|
||||||
|
|
||||||
svobj = RemoteBackupSchedule(RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
|
svobj = RemoteBackupSchedule(RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
|
||||||
timeintervel=Backfrequency, fileretention=FileRetention,
|
timeintervel=Backfrequency, fileretention=FileRetention,
|
||||||
|
|||||||
Reference in New Issue
Block a user