This commit is contained in:
usmannasir
2024-07-03 13:54:51 +05:00
16 changed files with 18105 additions and 22 deletions

View File

@@ -63,7 +63,9 @@ class CageFS:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Checking if LVE Kernel is loaded ..\n", 1)
if ProcessUtilities.outputExecutioner('uname -a').find('lve') == -1:
if ProcessUtilities.outputExecutioner('uname -a').find('lve') > -1 or ProcessUtilities.outputExecutioner('lsmod').find('lve') > -1:
pass
else:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"CloudLinux is installed but kernel is not loaded, please reboot your server to load appropriate kernel. [404]\n", 1)
return 0

View File

@@ -751,7 +751,7 @@ class BackupManager:
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'restoreStatus': 0, 'error_message': str(msg)}
final_dic = {'restoreStatus': 0, 'error_message': str(msg), 'abort': 0, 'running': 'Running..', 'status': ''}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
@@ -2073,6 +2073,12 @@ class BackupManager:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
from IncBackups.models import OneClickBackups
ocb = OneClickBackups.objects.get(pk = request.GET.get('id'), owner=admin)
@@ -2170,6 +2176,11 @@ class BackupManager:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
data = json.loads(request.body)
id = data['idValue']
folder = data['folder']

View File

@@ -12,10 +12,10 @@
<div class="container">
<div id="page-title">
<h2>{% trans "One-click Backups" %} - <a target="_blank"
href="https://cyberpanel.net/KnowledgeBase/home/add-destination-scheduled-local-sftp-remote-backups/"
href="https://youtu.be/mLjMg8Anq70"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Remote Backups" %}</span></a>
title=""><span>{% trans "One-Click Backup Docs" %}</span></a>
</h2>
<p>{% trans "On this page you purchase and manage one-click backups." %}</p>
</div>

View File

@@ -121,7 +121,7 @@ elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
Server_OS="CloudLinux"
elif grep -q -E "Rocky Linux" /etc/os-release ; then
Server_OS="RockyLinux"
elif grep -q "AlmaLinux-8" /etc/os-release ; then
elif grep -q -E "AlmaLinux-8|AlmaLinux-9" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10|Ubuntu 22.04" /etc/os-release ; then
Server_OS="Ubuntu"
@@ -417,6 +417,22 @@ EOF
dnf install epel-release -y
dnf install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-connector-c-devel curl-devel git platform-python-devel tar socat bind-utils
dnf install gpgme-devel -y
dnf install python3 -y
fi
elif [[ "$Server_OS_Version" = "9" ]] ; then
rm -f /etc/yum.repos.d/CentOS-PowerTools-CyberPanel.repo
if [[ "$Server_Country" = "CN" ]] ; then
dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el9.noarch.rpm
else
dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el9.noarch.rpm
fi
dnf install epel-release -y
dnf install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-connector-c-devel curl-devel git platform-python-devel tar socat bind-utils
dnf install gpgme-devel -y
dnf install python3 -y

View File

@@ -1,5 +1,5 @@
<div style="margin-top: 11%;" class="server-message">
<h1 style="font-size: 85px;margin: 0;font-weight: 300; line-height: 1.1;color:grey;text-align: center;">CyberPanel Installed</h1>
<h2 style="margin-top: 2%;margin-bottom: 2%;font-weight: 300; line-height: 1.1;color: #a56565;;text-align: center;">You have successfully installed CyberPanel, please remove this page and upload your website. :)</h2>
<p style="font-size: 35px;margin: 1%;font-weight: 300; line-height: 1.1;color:grey;text-align: center;"><a href="http://cyberpanel.net">CyberPanel</a> <a href="https://community.cyberpanel.net/">Forums</a> <a href="https://community.cyberpanel.net/docs">Documentation</a></p>
<p style="font-size: 35px;margin: 1%;font-weight: 300; line-height: 1.1;color:grey;text-align: center;"><a href="http://cyberpanel.net">Hosting Control Panel</a> <a href="https://community.cyberpanel.net/">Forums</a> <a href="https://community.cyberpanel.net/docs">Documentation</a></p>
</div>

View File

@@ -40,15 +40,17 @@ CloudLinux8 = 0
def FetchCloudLinuxAlmaVersionVersion():
if os.path.exists('/etc/os-release'):
data = open('/etc/os-release', 'r').read()
if (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.9') > -1 or data.find('Anatoly Levchenko') > -1):
if (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.9') > -1 or data.find('Anatoly Levchenko') > -1 or data.find('VERSION="8.') > -1):
return 'cl-89'
elif (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.8') > -1 or data.find('Anatoly Filipchenko') > -1):
return 'cl-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.9') > -1 or data.find('Midnight Oncilla') > -1):
elif (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('9.4') > -1 or data.find('VERSION="9.') > -1):
return 'cl-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.9') > -1 or data.find('Midnight Oncilla') > -1 or data.find('VERSION="8.') > -1):
return 'al-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.7') > -1 or data.find('Stone Smilodon') > -1):
return 'al-87'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('9.4') > -1 or data.find('9.3') > -1 or data.find('Shamrock Pampas') > -1 or data.find('Seafoam Ocelot') > -1):
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('9.4') > -1 or data.find('9.3') > -1 or data.find('Shamrock Pampas') > -1 or data.find('Seafoam Ocelot') > -1 or data.find('VERSION="9.') > -1):
return 'al-93'
else:
return -1

View File

@@ -40,15 +40,17 @@ def get_Ubuntu_release():
def FetchCloudLinuxAlmaVersionVersion():
if os.path.exists('/etc/os-release'):
data = open('/etc/os-release', 'r').read()
if (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.9') > -1 or data.find('Anatoly Levchenko') > -1):
if (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.9') > -1 or data.find('Anatoly Levchenko') > -1 or data.find('VERSION="8.') > -1):
return 'cl-89'
elif (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('8.8') > -1 or data.find('Anatoly Filipchenko') > -1):
return 'cl-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.9') > -1 or data.find('Midnight Oncilla') > -1):
elif (data.find('CloudLinux') > -1 or data.find('cloudlinux') > -1) and (data.find('9.4') > -1 or data.find('VERSION="9.') > -1):
return 'cl-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.9') > -1 or data.find('Midnight Oncilla') > -1 or data.find('VERSION="8.') > -1):
return 'al-88'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('8.7') > -1 or data.find('Stone Smilodon') > -1):
return 'al-87'
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('9.4') > -1 or data.find('9.3') > -1 or data.find('Shamrock Pampas') > -1 or data.find('Seafoam Ocelot') > -1):
elif (data.find('AlmaLinux') > -1 or data.find('almalinux') > -1) and (data.find('9.4') > -1 or data.find('9.3') > -1 or data.find('Shamrock Pampas') > -1 or data.find('Seafoam Ocelot') > -1 or data.find('VERSION="9.') > -1):
return 'al-93'
else:
return -1

22
langcomp.sh Executable file
View File

@@ -0,0 +1,22 @@
# Create message files for all the languages
django-admin makemessages -l zh-Hans
django-admin makemessages -l bg
django-admin makemessages -l pt
django-admin makemessages -l ja
django-admin makemessages -l bs
django-admin makemessages -l el
django-admin makemessages -l ru
django-admin makemessages -l tr
django-admin makemessages -l es
django-admin makemessages -l fr
django-admin makemessages -l pl
django-admin makemessages -l vi
django-admin makemessages -l it
django-admin makemessages -l de
django-admin makemessages -l id
django-admin makemessages -l bn
# Translate the .po files
# Compile the message files
django-admin compilemessages

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -657,11 +657,14 @@ Automatic backup failed for %s on %s.
continue
try:
command = f'find cpbackups -type f -mtime +{destinationConfig["retention"]} -exec rm -f {{}} \\;'
ssh.exec_command(command)
command = f'find cpbackups -type f -mtime +{jobConfig["retention"]} -exec rm -f {{}} \\;'
logging.writeToFile(command)
except:
ssh.exec_command(command)
command = 'find cpbackups -type d -empty -delete'
ssh.exec_command(command)
except BaseException as msg:
logging.writeToFile(f'Failed to delete old backups, Error {str(msg)}')
pass
# Execute the command to create the remote directory
@@ -805,6 +808,79 @@ Automatic backup failed for %s on %s.
backupjob.config = json.dumps(jobConfig)
backupjob.save()
### check if todays backups are fine
from IncBackups.models import OneClickBackups
try:
ocb = OneClickBackups.objects.get(sftpUser=destinationConfig['username'])
from plogical.acl import ACLManager
for site in websites:
from datetime import datetime, timedelta
Yesterday = (datetime.now() - timedelta(days=1)).strftime("%m.%d.%Y")
print(f'date of yesterday {Yesterday}')
# Command to list directories under the specified path
command = f"ls -d {finalPath}/*"
# Execute the command
stdin, stdout, stderr = ssh.exec_command(command)
# Read the results
directories = stdout.read().decode().splitlines()
print(f'directories of {str(directories)}')
try:
startCheck = 0
for directory in directories:
if directory.find(site.domain):
print(f'site in backup, no need to notify {site.domain}')
startCheck = 1
break
if startCheck:
'send notification that backup failed'
import requests
# Define the URL of the endpoint
url = 'http://platform.cyberpersons.com/Billing/BackupFailedNotify' # Replace with your actual endpoint URL
# Define the payload to send in the POST request
payload = {
'sub': ocb.subscription,
'subject': f'Failed to backup {site.domain} on {ACLManager.fetchIP()}.',
'message':f'Hi, \n\n Failed to create backup for {site.domain} on on {ACLManager.fetchIP()}. \n\n Please contact our support team at: http://platform.cyberpersons.com\n\nThank you.',
# Replace with the actual SSH public key
'sftpUser': ocb.sftpUser,
'serverIP': ACLManager.fetchIP(), # Replace with the actual server IP
}
# Convert the payload to JSON format
headers = {'Content-Type': 'application/json'}
dataRet = json.dumps(payload)
# Make the POST request
response = requests.post(url, headers=headers, data=dataRet)
# # Handle the response
# # Handle the response
# if response.status_code == 200:
# response_data = response.json()
# if response_data.get('status') == 1:
except:
pass
except:
pass
@staticmethod
def fetchAWSKeys():
path = '/home/cyberpanel/.aws'

View File

@@ -829,6 +829,29 @@ class ApplicationInstaller(multi.Thread):
if result.find('Success:') == -1:
raise BaseException(result)
### install CyberSMTP
command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp plugin install https://github.com/usmannasir/CyberSMTPs/archive/refs/heads/main.zip --allow-root --path=" + finalPath
result = ProcessUtilities.outputExecutioner(command, externalApp)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(str(result))
if result.find('Success:') == -1:
raise BaseException(result)
command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp plugin activate CyberSMTPs --allow-root --path=" + finalPath
result = ProcessUtilities.outputExecutioner(command, externalApp)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(str(result))
if result.find('Success:') == -1:
raise BaseException(result)
try:
if self.extraArgs['updates']:
if self.extraArgs['updates'] == 'Disabled':
@@ -6364,6 +6387,15 @@ class ApplicationInstaller(multi.Thread):
logging.statusWriter(self.tempStatusPath, str(msg))
return 0, str(msg)
def UpdateDownloadStatus(self, transferred, total):
percentage = (transferred / total) * 100
statusFile = open(self.tempStatusPath, 'w')
statusFile.writelines(f'{int(percentage)}% of file is downloaded from remote server..,50')
statusFile.close()
def StartOCRestore(self):
try:
@@ -6400,12 +6432,13 @@ class ApplicationInstaller(multi.Thread):
ssh.connect(ip, username=ocb.sftpUser, pkey=key)
sftp = ssh.open_sftp()
sftp.get(f'cpbackups/{folder}/{backupfile}', f'/home/cyberpanel/{backupfile}')
sftp.get(f'cpbackups/{folder}/{backupfile}', f'/home/cyberpanel/{backupfile}', callback=self.UpdateDownloadStatus)
if not os.path.exists('/home/backup'):
command = 'mkdir /home/backup'
ProcessUtilities.executioner(command)
command = f'mv /home/cyberpanel/{backupfile} /home/backup/{backupfile}'
ProcessUtilities.executioner(command)
@@ -6413,6 +6446,12 @@ class ApplicationInstaller(multi.Thread):
wm = BackupManager()
resp = wm.submitRestore({'backupFile': backupfile}, userID)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Download finished..,60")
statusFile.close()
time.sleep(6)
if json.loads(resp.content)['restoreStatus'] == 0:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(f"Failed to restore backup. Error {json.loads(resp.content)['error_message']}. [404]")
@@ -6423,13 +6462,21 @@ class ApplicationInstaller(multi.Thread):
return 0
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'Name of of the backup file downloaded: {backupfile}')
while True:
resp = wm.restoreStatus({'backupFile': backupfile})
resp = json.loads(resp.content)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'Responce from status function: {str(resp)}')
if resp['abort'] == 1 and resp['running'] == 'Completed':
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.writelines("Successfully Restored. [200]")
statusFile.close()
command = f'rm -f /home/backup/{backupfile}'
ProcessUtilities.executioner(command)
@@ -6437,7 +6484,7 @@ class ApplicationInstaller(multi.Thread):
elif resp['abort'] == 1 and resp['running'] == 'Error':
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(
f"Failed to restore backup. Error {resp['status']}. [404]")
f"Failed to restore backup. Error {str(resp['status'])}. [404]")
statusFile.close()
command = f'rm -f /home/backup/{backupfile}'
ProcessUtilities.executioner(command)
@@ -6446,8 +6493,6 @@ class ApplicationInstaller(multi.Thread):
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(f"{resp['status']},60")
statusFile.close()
command = f'rm -f /home/backup/{backupfile}'
ProcessUtilities.executioner(command)
time.sleep(3)
except BaseException as msg:

View File

@@ -1162,6 +1162,18 @@ CREATE TABLE `websiteFunctions_backupsv2` (`id` integer AUTO_INCREMENT NOT NULL
except:
pass
query = "CREATE TABLE `IncBackups_oneclickbackups` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `planName` varchar(100) NOT NULL, `months` varchar(100) NOT NULL, `price` varchar(100) NOT NULL, `customer` varchar(300) NOT NULL, `subscription` varchar(300) NOT NULL UNIQUE, `sftpUser` varchar(100) NOT NULL, `config` longtext NOT NULL, `date` datetime(6) NOT NULL, `state` integer NOT NULL, `owner_id` integer NOT NULL);"
try:
cursor.execute(query)
except:
pass
query = 'ALTER TABLE `IncBackups_oneclickbackups` ADD CONSTRAINT `IncBackups_oneclickb_owner_id_7b4250a4_fk_loginSyst` FOREIGN KEY (`owner_id`) REFERENCES `loginSystem_administrator` (`id`);'
try:
cursor.execute(query)
except:
pass
if Upgrade.FindOperatingSytem() == Ubuntu22:
### If ftp not installed then upgrade will fail so this command should not do exit

View File

@@ -57,7 +57,6 @@ py3dns==3.2.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
pygpgme==0.3
PyNaCl==1.4.0
pyOpenSSL==19.1.0
pyotp==2.4.1