Merge branch 'v2.1.3-dev' of https://github.com/usmannasir/cyberpanel into v2.1.3-dev

This commit is contained in:
habi
2022-05-11 12:51:47 +05:00
19 changed files with 118 additions and 46 deletions

View File

@@ -4,8 +4,8 @@ class CLMain():
def __init__(self):
self.path = '/usr/local/CyberCP/version.txt'
#versionInfo = json.loads(open(self.path, 'r').read())
self.version = '2.1'
self.build = '2'
self.version = '2.3'
self.build = '1'
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)

View File

@@ -72,7 +72,7 @@ class secMiddleware:
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
if request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
if request.build_absolute_uri().find('api/remoteTransfer') > -1 or request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
continue
if key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \

View File

@@ -435,10 +435,14 @@ def remoteTransfer(request):
## Accounts to transfer is a path to file, containing accounts.
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py"
execPath = execPath + " remoteTransfer --ipAddress " + ipAddress + " --dir " + dir + " --accountsToTransfer " + path
execPath = execPath + " remoteTransfer --ipAddress " + ipAddress.rstrip('\n') + " --dir " + dir + " --accountsToTransfer " + path
ProcessUtilities.popenExecutioner(execPath)
if os.path.exists('/usr/local/CyberCP/debug'):
logging.writeToFile('Repor of %s' % repr(execPath))
return HttpResponse(json.dumps({"transferStatus": 1, "dir": dir}))
##

View File

@@ -1163,6 +1163,10 @@ class BackupManager:
r = requests.post(url, data=finalData, verify=False)
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'Remote transfer initiation status: %s' % (r.text)
logging.CyberCPLogFileWriter.writeToFile(message)
data = json.loads(r.text)
if data['transferStatus'] == 1:

View File

@@ -114,7 +114,7 @@
<div ng-hide="driveHidden" id="checkret" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label>
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %} (<a href="https://cyberpanel.net/cyberpanel-addons">Paid Feature</a> )</label>
<div class="col-sm-6">
<select id="fileretention" ng-model="Retentiontime" ng-change="changeRetention()" class="form-control">
<option value="1d">1 days</option>

View File

@@ -58,6 +58,8 @@
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestBuild }} </div>
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Commit :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestcomit }} </div>
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "# commits since update :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ numCommits }} </div>
</div>
@@ -84,4 +86,4 @@
</div>
{% endblock %}
{% endblock %}

View File

@@ -18,8 +18,8 @@ from plogical.httpProc import httpProc
# Create your views here.
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
@ensure_csrf_cookie
@@ -120,6 +120,14 @@ def versionManagment(request):
Currentcomt = output.rstrip("\n")
notechk = True;
command ="git fetch"
output = ProcessUtilities.outputExecutioner(command)
command ="git -C /usr/local/CyberCP/ log %s..%s --pretty=oneline | wc -l" % ( Currentcomt, latestcomit)
output = ProcessUtilities.outputExecutioner(command)
numCommits = output.rstrip("\n")
if(Currentcomt == latestcomit):
notechk = False;
@@ -127,7 +135,7 @@ def versionManagment(request):
template = 'baseTemplate/versionManagment.html'
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck" : notechk }
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck" : notechk, "numCommits": numCommits }
proc = httpProc(request, template, finalData, 'versionManagement')

View File

@@ -1635,13 +1635,13 @@ echo " Panel password: ***** "
else
echo " Panel password: $Admin_Pass "
fi
echo " Visit: https://$Server_IP:7080 "
echo " WebAdmin console username: admin "
echo " WebAdmin console password: $Webadmin_Pass "
echo " "
echo " Visit: https://$Server_IP:8090/rainloop/?admin "
echo " Rainloop Admin username: admin "
echo " Rainloop Admin password: $RainloopAdminPass "
#echo " Visit: https://$Server_IP:7080 "
#echo " WebAdmin console username: admin "
#echo " WebAdmin console password: $Webadmin_Pass "
#echo " "
#echo " Visit: https://$Server_IP:8090/rainloop/?admin "
#echo " Rainloop Admin username: admin "
#echo " Rainloop Admin password: $RainloopAdminPass "
echo " "
echo -e " Run \e[31mcyberpanel help\e[39m to get FAQ info"
echo -e " Run \e[31mcyberpanel upgrade\e[39m to upgrade it to latest version."

View File

@@ -224,7 +224,8 @@ def FileManagerRoot(request):
if(Status == 1):
template = 'baseTemplate/FileManager.html'
else:
return redirect("https://cyberpanel.net/adons")
return redirect("https://cyberpanel.net/cyberpanel-addons")
except BaseException as msg:
template = 'baseTemplate/FileManager.html'

View File

@@ -14,8 +14,8 @@ from os.path import *
from stat import *
import stat
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', 'nums': '0123456789', 'big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
@@ -2047,6 +2047,8 @@ milter_default_action = accept
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'yum install -y restic'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'restic self-update'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
else:
command = 'apt-get update -y'
@@ -2054,6 +2056,9 @@ milter_default_action = accept
command = 'apt-get install restic -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'restic self-update'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
except:
pass

View File

@@ -18,8 +18,8 @@ from django.http import HttpResponse
from django.utils import translation
# Create your views here.
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
def verifyLogin(request):

View File

@@ -1,11 +1,9 @@
#!/usr/local/CyberCP/bin/python
import os.path
import sys
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
import django
django.setup()
from IncBackups.IncBackupsControl import IncJobs
from IncBackups.models import BackupJob
@@ -24,7 +22,6 @@ import requests
import socket
from websiteFunctions.models import NormalBackupJobs, NormalBackupJobLogs
from boto3.s3.transfer import TransferConfig
try:
from s3Backups.models import BackupPlan, BackupLogs
import boto3
@@ -235,6 +232,11 @@ class IncScheduler(multi.Thread):
@staticmethod
def runGoogleDriveBackups(type):
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S")
backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime
@@ -252,10 +254,11 @@ class IncScheduler(multi.Thread):
drive.files().list(pageSize=10, fields="files(id, name)").execute()
except BaseException as msg:
try:
import requests
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData
)
gDriveData['token'] = json.loads(r.text)['access_token']
credentials = google.oauth2.credentials.Credentials(gDriveData['token'],
@@ -280,11 +283,6 @@ class IncScheduler(multi.Thread):
folderIDIP = gDriveData['folderIDIP']
except:
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
## Create CyberPanel Folder
file_metadata = {
@@ -349,6 +347,7 @@ class IncScheduler(multi.Thread):
try:
drive.files().create(body=file_metadata, media_body=media, fields='id').execute()
except:
import requests
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
r = requests.post("https://platform.cyberpersons.com/refreshToken", data=finalData
)
@@ -381,7 +380,7 @@ class IncScheduler(multi.Thread):
print("job com[leted")
logging.writeToFile('job completed')
#logging.writeToFile('job completed')
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
@@ -461,8 +460,6 @@ class IncScheduler(multi.Thread):
except BaseException as msg:
logging.writeToFile('job not completed [ERROR:]..%s'%msg)
except BaseException as msg:
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
message='[Completely] Job failed, Error message: %s.' % (str(msg))).save()

View File

@@ -12,8 +12,8 @@ from plogical.acl import ACLManager
from packages.models import Package
from baseTemplate.models import version
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
if not os.geteuid() == 0:
sys.exit("\nOnly root can run this script\n")

View File

@@ -89,8 +89,21 @@ class backupSchedule:
ifRunning = ProcessUtilities.outputExecutioner('ps aux')
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'Output of px aux when running remote backup status check: %s' % (ifRunning)
logging.CyberCPLogFileWriter.writeToFile(message)
if (ifRunning.find('startBackup') > -1 or ifRunning.find('BackupRoot') > -1) and ifRunning.find('/%s/' % (backupDomain)):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'If running found.'
logging.CyberCPLogFileWriter.writeToFile(message)
if os.path.exists(status):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'If running found. and status file exists'
logging.CyberCPLogFileWriter.writeToFile(message)
status = open(status, 'r').read()
time.sleep(2)
@@ -115,6 +128,9 @@ class backupSchedule:
return 1, tempStoragePath
elif status.find("[5009]") > -1:
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'If running found. status file exists but error'
logging.CyberCPLogFileWriter.writeToFile(message)
## removing status file, so that backup can re-run
try:
command = 'sudo rm -f ' + status
@@ -150,6 +166,9 @@ class backupSchedule:
return 0, tempStoragePath
elif os.path.exists(schedulerPath):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'If running found. status file exists, scheduler path also exists hence killed'
logging.CyberCPLogFileWriter.writeToFile(message)
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (
open(schedulerPath, 'r').read()),
backupSchedule.ERROR)
@@ -157,8 +176,15 @@ class backupSchedule:
command = 'rm -rf %s' % (tempStoragePath)
ProcessUtilities.normalExecutioner(command)
return 0, 'Backup process killed.'
else:
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'If running not found.'
logging.CyberCPLogFileWriter.writeToFile(message)
if os.path.exists(status):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'if running not found, Status file exists'
logging.CyberCPLogFileWriter.writeToFile(message)
status = open(status, 'r').read()
time.sleep(2)
@@ -182,6 +208,11 @@ class backupSchedule:
pass
return 1, tempStoragePath
elif os.path.exists(schedulerPath):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'if running not found, Status file exists, scheduler path exists thus killed.'
logging.CyberCPLogFileWriter.writeToFile(message)
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (open(schedulerPath, 'r').read()),
backupSchedule.ERROR)
os.remove(schedulerPath)
@@ -189,13 +220,23 @@ class backupSchedule:
ProcessUtilities.normalExecutioner(command)
return 0, 'Backup process killed.'
else:
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'Status file does not exists.'
logging.CyberCPLogFileWriter.writeToFile(message)
if killCounter == 1:
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'if running not found, Status file does not exists, kill counter 1, thus killed'
logging.CyberCPLogFileWriter.writeToFile(message)
command = 'rm -rf %s' % (tempStoragePath)
ProcessUtilities.normalExecutioner(command)
return 0, 'Backup process killed without reporting any error. [184]'
elif os.path.exists(schedulerPath):
if os.path.exists('/usr/local/CyberCP/debug'):
message = 'if running not found, Status file does not exists, scheduler path found thus killed'
logging.CyberCPLogFileWriter.writeToFile(message)
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (
open(schedulerPath, 'r').read()),
backupSchedule.ERROR)

View File

@@ -48,8 +48,8 @@ try:
except:
pass
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
## I am not the monster that you think I am..
@@ -645,7 +645,7 @@ class backupUtilities:
dbName = database.find('dbName').text
if VERSION == '2.1' and int(BUILD) >= 1:
if (VERSION == '2.1' or VERSION == '2.3') and int(BUILD) >= 1:
logging.CyberCPLogFileWriter.writeToFile('Backup version 2.1.1+ detected..')
databaseUsers = database.findall('databaseUsers')
@@ -912,7 +912,7 @@ class backupUtilities:
dbName = database.find('dbName').text
if VERSION == '2.1' and int(BUILD) >= 1:
if (VERSION == '2.1' or VERSION == '2.3') and int(BUILD) >= 1:
logging.CyberCPLogFileWriter.writeToFile('Backup version 2.1.1+ detected..')
@@ -963,6 +963,7 @@ class backupUtilities:
# /home/backup/backup-example.com-02.13.2018_10-24-52/public_html.tar.gz
## Moving above v2.0.0 extracting webhome data is not required, thus commenting below lines
if not twoPointO:
tar = tarfile.open(pathToCompressedHome)
tar.extractall(websiteHome)

View File

@@ -225,7 +225,8 @@ class ProcessUtilities(multi.Thread):
command = 'sudo %s' % (command)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(ProcessUtilities.token + command)
if command.find('cat') == -1:
logging.writeToFile(ProcessUtilities.token + command)
if dir == None:
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
@@ -238,8 +239,11 @@ class ProcessUtilities(multi.Thread):
else:
command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command)
command = command.replace('sudo', '')
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command)
if command.find('cat') == -1:
logging.writeToFile(command)
sock.sendall(command.encode('utf-8'))

View File

@@ -16,8 +16,8 @@ from CyberCP import settings
import random
import string
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
CENTOS7 = 0
CENTOS8 = 1
@@ -2341,6 +2341,8 @@ echo $oConfig->Save() ? 'Done' : 'Error';
if Upgrade.installedOutput.find('restic') == -1:
command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
command = 'restic self-update'
Upgrade.executioner(command, 'Install Restic')
else:
if Upgrade.installedOutput.find('restic/bionic,now 0.8') == -1:
@@ -2349,6 +2351,9 @@ echo $oConfig->Save() ? 'Done' : 'Error';
command = 'apt-get install restic -y'
Upgrade.executioner(command, 'Install Restic')
command = 'restic self-update'
Upgrade.executioner(command, 'Install Restic')
@staticmethod
def UpdateMaxSSLCons():

View File

@@ -25,8 +25,8 @@ EXPIRE = 3
### Version
VERSION = '2.1'
BUILD = 2
VERSION = '2.3'
BUILD = 1
def serverStatusHome(request):
proc = httpProc(request, 'serverStatus/index.html',

View File

@@ -1 +1 @@
{"version":"2.1","build":1}
{"version":"2.3","build":1}