diff --git a/CPScripts/mailscannerinstaller.sh b/CPScripts/mailscannerinstaller.sh new file mode 100644 index 000000000..f91acaa7c --- /dev/null +++ b/CPScripts/mailscannerinstaller.sh @@ -0,0 +1,353 @@ +#!/bin/bash +#systemctl stop firewalld + +echo 'backup configs'; +cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); +cp /etc/postfix/master.cf /etc/postfix/master.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); +cp /etc/postfix/main.cf /etc/postfix/main.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); +cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext-bak_$(date '+%Y-%m-%d_%H_%M:%S') + + +ZONE=$(firewall-cmd --get-default-zone) +firewall-cmd --zone=$ZONE --add-port=4190/tcp --permanent +systemctl stop firewalld + +echo 'Stop CSF' +csf -x + +MAILSCANNER=/etc/MailScanner + +if [ -d $MAILSCANNER ];then + +echo "MailScanner found. If you wish to reinstall then remove the package and revert" +echo "Postfix back to its original config at /etc/postfix/main.cf and remove" +echo "/etc/MailScanner and /usr/share/MailScanner directories" +exit +fi + +if [ -f /etc/os-release ];then +OS=$(head -1 /etc/os-release) +UBUNTUVERSION=$(sed '6q;d' /etc/os-release) +CENTOSVERSION=$(sed '5q;d' /etc/os-release) +fi + +if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then + +setenforce 0 +yum install -y perl yum-utils perl-CPAN +yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)" + +rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm +export PERL_MM_USE_DEFAULT=1 +curl -L https://cpanmin.us | perl - App::cpanminus +cpanm Encoding::FixLatin +cpanm Digest::SHA1 +cpanm Geo::IP +cpanm Razor2::Client::Agent +cpanm Net::Patricia + +freshclam -v +DIR=/etc/mail/spamassassin + +if [ -d "$DIR" ]; then +sa-update + +else + +echo "Please install spamassassin through the CyberPanel interface before proceeding" + +exit +fi + +elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then + +setenforce 0 +yum install -y perl yum-utils perl-CPAN +dnf --enablerepo=PowerTools install -y perl-IO-stringy +yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav clamav-update "perl(DBD::mysql)" + +rpm -Uvh https://forensics.cert.org/centos/cert/8/x86_64/unrar-5.4.0-1.el8.x86_64.rpm + +export PERL_MM_USE_DEFAULT=1 +curl -L https://cpanmin.us | perl - App::cpanminus +cpanm Encoding::FixLatin +cpanm Digest::SHA1 +cpanm Geo::IP +cpanm Razor2::Client::Agent +cpanm Sys::Hostname::Long +cpanm Sys::SigAction + +freshclam -v + +DIR=/etc/mail/spamassassin + +if [ -d "$DIR" ]; then +sa-update + +else + +echo "Please install spamassassin through the CyberPanel interface before proceeding" + +exit +fi + +elif [ "$OS" = "NAME=\"Ubuntu\"" ];then + + apt-get install -y libmysqlclient-dev + + apt-get install -y cpanminus gcc perl bzip2 zip make patch automake rpm libarchive-zip-perl libfilesys-df-perl libole-storage-lite-perl libsys-hostname-long-perl libsys-sigaction-perl libregexp-common-net-cidr-perl libmime-tools-perl libdbd-sqlite3-perl binutils build-essential libfilesys-df-perl zlib1g unzip mlocate clamav libdbd-mysql-perl unrar libclamav-dev libclamav-client-perl libclamunrar9 + +cpanm Encoding::FixLatin +cpanm Digest::SHA1 +cpanm Geo::IP +cpanm Razor2::Client::Agent +cpanm Net::Patricia +cpanm Net::CIDR + +sudo systemctl stop clamav-freshclam.service + +freshclam + +sudo systemctl start clamav-freshclam.service + +DIR=/etc/spamassassin +if [ -d "$DIR" ]; then + +apt-get -y install razor pyzor libencode-detect-perl libgeo-ip-perl libnet-patricia-perl +sa-update +else +echo "Please install spamassassin through the CyberPanel interface before proceeding" +exit +fi + +fi + +echo "header_checks = regexp:/etc/postfix/header_checks" >> /etc/postfix/main.cf +echo "/^Received:/ HOLD" >> /etc/postfix/header_checks + +systemctl restart postfix + +wget https://github.com/MailScanner/v5/archive/master.zip +unzip master.zip + +cd /usr/local/CyberCP/CPScripts/v5-master/builds + +if [ "$OS" = "NAME=\"Ubuntu\"" ];then + +dpkg -i *.noarch.deb + +mkdir /var/run/MailScanner +mkdir /var/lock/subsys +mkdir /var/lock/subsys/MailScanner +chown -R postfix:postfix /var/run/MailScanner +chown -R postfix:postfix /var/lock/subsys/MailScanner +chown -R postfix:postfix /var/spool/MailScanner + +elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then + +rpm -Uvh *.rhel.noarch.rpm + +fi + +mkdir /var/spool/MailScanner/spamassassin + +chown postfix.mtagroup /var/spool/MailScanner/spamassassin +chown root.mtagroup /var/spool/MailScanner/incoming/ +chown postfix.mtagroup /var/spool/MailScanner/milterin +chown postfix.mtagroup /var/spool/MailScanner/milterout +chown postfix.mtagroup /var/spool/postfix/hold +chown postfix.mtagroup /var/spool/postfix/incoming +usermod -a -G mtagroup nobody + +chmod g+rx /var/spool/postfix/incoming +chmod g+rx /var/spool/postfix/hold +chmod -R 0775 /var/spool/postfix/incoming +chmod -R 0775 /var/spool/postfix/hold + +sed -i 's/^Run As User =.*/& postfix/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Run As Group =.*/& postfix/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Incoming Queue Dir =.*/Incoming Queue Dir = \/var\/spool\/postfix\/hold/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Outgoing Queue Dir =.*/Outgoing Queue Dir = \/var\/spool\/postfix\/incoming/' /etc/MailScanner/MailScanner.conf +sed -i 's/^MTA =.*/MTA = postfix/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Quarantine User =.*/& postfix/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Quarantine Group =.*/& mtagroup/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Quarantine Permissions =.*/Quarantine Permissions = 640/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Virus Scanners =.*/Virus Scanners = clamav/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Is Definitely Not Spam =.*/Is Definitely Not Spam = \&SQLWhitelist/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Is Definitely Spam =.*/Is Definitely Spam = \&SQLBlacklist/' /etc/MailScanner/MailScanner.conf +sed -i 's/^SpamAssassin User State Dir =.*/& \/var\/spool\/MailScanner\/spamassassin/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Always Looked Up Last =.*/Always Looked Up Last = \&MailWatchLogging/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Quarantine Whole Message =.*/Quarantine Whole Message = yes/' /etc/MailScanner/MailScanner.conf +sed -i 's/^Spam List =.*/Spam List = SBL + XBL/' /etc/MailScanner/MailScanner.conf + +mkdir /usr/local/CyberCP/public/mailwatch + +cd /usr/local/CyberCP/public/mailwatch + +git clone --depth=1 https://github.com/mailwatch/MailWatch.git --branch 1.2 --single-branch + +mv /usr/local/CyberCP/public/mailwatch/MailWatch/* /usr/local/CyberCP/public/mailwatch/ + +PASSWORD=$(cat /etc/cyberpanel/mysqlPassword) +USER=root +DATABASE=mailscanner +ADMINPASS=$(cat /etc/cyberpanel/adminPass) +mysql -u${USER} -p${PASSWORD} < "/usr/local/CyberCP/public/mailwatch/create.sql" +mysql -u${USER} -p${PASSWORD} -e "use mailscanner"; +mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "GRANT ALL ON mailscanner.* TO root@localhost IDENTIFIED BY '${PASSWORD}';" +mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "FLUSH PRIVILEGES;" +mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "INSERT INTO mailscanner.users SET username = 'admin', password = MD5('${ADMINPASS}'), fullname = 'admin', type = 'A';" + +cp /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php.example /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php + +sed -i "s/^define('DB_USER',.*/define('DB_USER','root');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php +sed -i "s/^define('DB_PASS',.*/define('DB_PASS','${PASSWORD}');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php +sed -i "s/^define('MAILWATCH_HOME',.*/define(\'MAILWATCH_HOME\', \'\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php + +MSDEFAULT=/etc/MailScanner/defaults +if [ -f "$MSDEFAULT" ];then +sed -i 's/^run_mailscanner=.*/run_mailscanner=1/' /etc/MailScanner/defaults +elif [ ! -f "$MSDEFAULT" ];then +touch /etc/MailScanner/defaults +echo "run_mailscanner=1" >> /etc/MailScanner/defaults +fi + +cp /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatchConf.pm /usr/share/MailScanner/perl/custom/ +sed -i 's/^my (\$db_user) = .*/my (\$db_user) = \x27'${USER}'\x27;/' /usr/share/MailScanner/perl/custom/MailWatchConf.pm +sed -i 's/^my (\$db_pass) = .*/my (\$db_pass) = \x27'${PASSWORD}'\x27;/' /usr/share/MailScanner/perl/custom/MailWatchConf.pm +ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatch.pm /usr/share/MailScanner/perl/custom +ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/SQLBlackWhiteList.pm /usr/share/MailScanner/perl/custom +ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/SQLSpamSettings.pm /usr/share/MailScanner/perl/custom +sed -i "s/^\$pathToFunctions =.*/\$pathToFunctions = '\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner\/functions.php';/" /usr/local/CyberCP/public/mailwatch/upgrade.php + +/usr/local/lsws/lsphp72/bin/php /usr/local/CyberCP/public/mailwatch/upgrade.php +systemctl enable mailscanner +systemctl restart mailscanner + +IPADDRESS=$(cat /etc/cyberpanel/machineIP) + + +echo 'Setting up spamassassin and sieve to deliver spam to Junk folder by default' +#echo "If you wish mailscanner/spamassassin to send spam email to a spam folder please follow the tutorial on the Cyberpanel Website" +echo 'Fix protocols' +sed -i 's/^protocols =.*/protocols = imap pop3 lmtp sieve/g' /etc/dovecot/dovecot.conf + + +sed -i "s|^user_query.*|user_query = SELECT '5000' as uid, '5000' as gid, '/home/vmail/%d/%n' as home,mail FROM e_users WHERE email='%u';|g" /etc/dovecot/dovecot-sql.conf.ext + +if [ "$OS" = "NAME=\"Ubuntu\"" ];then +if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ];then + apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm +elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ];then + apt-get install -y libmysqlclient-dev + sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list + apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm +fi + +elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then + + yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts + +elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then + + rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm + dnf --enablerepo=gf-plus upgrade -y dovecot23* + dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole + dnf install -y net-tools postfix-perl-scripts + +fi + + +# Create Sieve files +mkdir -p /etc/dovecot/sieve/global +touch /var/log/{dovecot-lda-errors.log,dovecot-lda.log} +touch /var/log/{dovecot-sieve-errors.log,dovecot-sieve.log} +touch /var/log/{dovecot-lmtp-errors.log,dovecot-lmtp.log} +touch /etc/dovecot/sieve/default.sieve +chown vmail: -R /etc/dovecot/sieve +chown vmail:mail /var/log/dovecot-* + +echo 'Create Sieve Default spam to Junk rule' +cat >> /etc/dovecot/sieve/default.sieve <> /etc/dovecot/dovecot.conf < -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \ or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \ diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index b153a5b9e..618c950a4 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -122,7 +122,8 @@ class IncJobs(multi.Thread): def findRestorePath(self): - if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8 \ + or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: self.restoreTarget = '/' return 1 else: diff --git a/IncBackups/views.py b/IncBackups/views.py index 9ba6b1afc..fe229f0c9 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -100,10 +100,16 @@ def addDestination(request): execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \ - + password + " --port " + port + + password + " --port " + port + ' --user %s' % ('root') + + if os.path.exists(ProcessUtilities.debugPath): + logging.writeToFile(execPath) output = ProcessUtilities.outputExecutioner(execPath) + if os.path.exists(ProcessUtilities.debugPath): + logging.writeToFile(output) + if output.find('1,') > -1: content = '%s\n%s' % (ipAddress, port) diff --git a/WebTerminal/templates/WebTerminal/WebTerminal.html b/WebTerminal/templates/WebTerminal/WebTerminal.html index 81d21e451..75bea2190 100755 --- a/WebTerminal/templates/WebTerminal/WebTerminal.html +++ b/WebTerminal/templates/WebTerminal/WebTerminal.html @@ -7,15 +7,13 @@ {% get_current_language as LANGUAGE_CODE %} - - -

{% trans "Terminal" %} - {% trans "Web Terminal Docs" %}

+ style="height: 23px;line-height: 21px;" + class="btn btn-border btn-alt border-red btn-link font-red" + title="">{% trans "Web Terminal Docs" %}

{% trans "Execute your terminal commands." %}

@@ -50,5 +48,4 @@
- {% endblock %} diff --git a/api/views.py b/api/views.py index e80fa5927..771ab5eb4 100755 --- a/api/views.py +++ b/api/views.py @@ -593,7 +593,6 @@ def runAWSBackups(request): except BaseException as msg: logging.writeToFile(str(msg) + ' [API.runAWSBackups]') - @csrf_exempt def submitUserCreation(request): try: diff --git a/backup/backupManager.py b/backup/backupManager.py index f7181f4ca..eb9f4fe73 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -9,7 +9,7 @@ django.setup() import json from plogical.acl import ACLManager import plogical.CyberCPLogFileWriter as logging -from websiteFunctions.models import Websites, Backups, dest, backupSchedules +from websiteFunctions.models import Websites, Backups, dest, backupSchedules, BackupJob, BackupJobLogs from plogical.virtualHostUtilities import virtualHostUtilities import subprocess import shlex @@ -1115,32 +1115,27 @@ class BackupManager: time.sleep(3) - if os.path.isfile(backupLogPath): - command = "sudo cat " + backupLogPath - status = ProcessUtilities.outputExecutioner(command) + command = "sudo cat " + backupLogPath + status = ProcessUtilities.outputExecutioner(command) - if status.find("completed[success]") > -1: - command = "rm -rf " + removalPath - ProcessUtilities.executioner(command) - data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 1} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) - elif status.find("[5010]") > -1: - command = "sudo rm -rf " + removalPath - ProcessUtilities.executioner(command) - data = {'remoteTransferStatus': 0, 'error_message': status, - "status": "None", "complete": 0} - json_data = json.dumps(data) - return HttpResponse(json_data) - else: - data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 0} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) - else: - data_ret = {'remoteTransferStatus': 0, 'error_message': "No such log found", "status": "None", - "complete": 0} + if status.find("completed[success]") > -1: + command = "rm -rf " + removalPath + ProcessUtilities.executioner(command) + data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) + elif status.find("[5010]") > -1: + command = "sudo rm -rf " + removalPath + ProcessUtilities.executioner(command) + data = {'remoteTransferStatus': 0, 'error_message': status, + "status": "None", "complete": 0} + json_data = json.dumps(data) + return HttpResponse(json_data) + else: + data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 0} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + except BaseException as msg: data = {'remoteTransferStatus': 0, 'error_message': str(msg), "status": "None", "complete": 0} json_data = json.dumps(data) @@ -1191,3 +1186,96 @@ class BackupManager: data = {'cancelStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) + + def backupLogs(self, request = None, userID = None, data = None): + try: + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + all_files = [] + + logFiles = BackupJob.objects.all().order_by('-id') + + for logFile in logFiles: + all_files.append(logFile.logFile) + + return render(request, 'backup/backupLogs.html', {'backups': all_files}) + + except BaseException as msg: + return HttpResponse(str(msg)) + + def fetchLogs(self, userID = None, data = None): + try: + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + page = int(str(data['page']).rstrip('\n')) + recordsToShow = int(data['recordsToShow']) + logFile = data['logFile'] + + logJob = BackupJob.objects.get(logFile=logFile) + + logs = logJob.backupjoblogs_set.all() + + from s3Backups.s3Backups import S3Backups + from plogical.backupSchedule import backupSchedule + + pagination = S3Backups.getPagination(len(logs), recordsToShow) + endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow) + finalLogs = logs[finalPageNumber:endPageNumber] + + json_data = "[" + checker = 0 + counter = 0 + + for log in finalLogs: + + if log.status == backupSchedule.INFO: + status = 'INFO' + else: + status = 'ERROR' + + dic = { + 'LEVEL': status, "Message": log.message + } + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + counter = counter + 1 + + json_data = json_data + ']' + + if logJob.location == backupSchedule.LOCAL: + location = 'local' + else: + location = 'remote' + + + data = { + 'status': 1, + 'error_message': 'None', + 'logs': json_data, + 'pagination': pagination, + 'jobSuccessSites': logJob.jobSuccessSites, + 'jobFailedSites': logJob.jobFailedSites, + 'location': location + } + + + json_data = json.dumps(data) + return HttpResponse(json_data) + + except BaseException as msg: + data = {'remoteRestoreStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data) + return HttpResponse(json_data) diff --git a/backup/static/backup/backup.js b/backup/static/backup/backup.js index a41fffb41..59c654f87 100755 --- a/backup/static/backup/backup.js +++ b/backup/static/backup/backup.js @@ -1347,6 +1347,7 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) { $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); function ListInitialDatas(response) { + $scope.backupProcessStarted = true; if (response.data.remoteTransferStatus === 1) { @@ -1540,4 +1541,68 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) { }); -///** Backup site ends **/// \ No newline at end of file +///** Backup site ends **/// + + +//*** Remote Backup site ****// +app.controller('backupLogsScheduled', function ($scope, $http, $timeout) { + + $scope.cyberpanelLoading = true; + $scope.logDetails = true; + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.fetchLogs = function () { + + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + logFile: $scope.logFile, + recordsToShow: $scope.recordsToShow, + page: $scope.currentPage + }; + + dataurl = "/backup/fetchLogs"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.logDetails = false; + $scope.logs = JSON.parse(response.data.logs); + $scope.pagination = response.data.pagination; + $scope.jobSuccessSites = response.data.jobSuccessSites; + $scope.jobFailedSites = response.data.jobFailedSites; + $scope.location = response.data.location; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + +}); + +///** Backup site ends **/// diff --git a/backup/templates/backup/backupLogs.html b/backup/templates/backup/backupLogs.html new file mode 100755 index 000000000..2736eddef --- /dev/null +++ b/backup/templates/backup/backupLogs.html @@ -0,0 +1,125 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Backup Logs - CyberPanel" %}{% endblock %} +{% block content %} + + {% load static %} + + {% get_current_language as LANGUAGE_CODE %} + + + +
+
+

{% trans "Backup Logs" %}

+

{% trans "On this page you can view detailed logs of your local and remote scheduled backups." %}

+
+ +
+
+

+ {% trans "Backup Logs" %} +

+
+ +
+ + +
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + +
{% trans "Successful Sites" %}{% trans "Failed Sites" %}{% trans "Location" %}
{$ jobSuccessSites $}{$ jobFailedSites $}{$ location $}
+
+
+ +
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + +
{% trans "LEVEL" %}{% trans "Message" %}
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ + +
+ + +{% endblock %} \ No newline at end of file diff --git a/backup/templates/backup/backupSchedule.html b/backup/templates/backup/backupSchedule.html index 69de37618..6fb11b5b5 100755 --- a/backup/templates/backup/backupSchedule.html +++ b/backup/templates/backup/backupSchedule.html @@ -11,7 +11,7 @@

{% trans "Schedule Back up" %} - {% trans "Remote Backups" %}

{% trans "On this page you can schedule Back ups to localhost or remote server (If you have added one)." %}

@@ -20,8 +20,11 @@

- {% trans "Schedule Back up" %} + {% trans "Schedule Back up" %} - {% trans "Backup Logs" %}

diff --git a/backup/urls.py b/backup/urls.py index 0a7164ba2..9d09770a5 100755 --- a/backup/urls.py +++ b/backup/urls.py @@ -48,7 +48,7 @@ urlpatterns = [ url(r'^localInitiate$', views.localInitiate, name='localInitiate'), - - + url(r'^backupLogs$', views.backupLogs, name='backupLogs'), + url(r'^fetchLogs$', views.fetchLogs, name='fetchLogs'), ] \ No newline at end of file diff --git a/backup/views.py b/backup/views.py index ef8842283..bf6512c25 100755 --- a/backup/views.py +++ b/backup/views.py @@ -327,6 +327,23 @@ def cancelRemoteBackup(request): except KeyError: return redirect(loadLoginPage) +def backupLogs(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.backupLogs(request, userID) + except KeyError: + return redirect(loadLoginPage) + +def fetchLogs(request): + try: + userID = request.session['userID'] + + wm = BackupManager() + return wm.fetchLogs(userID, json.loads(request.body)) + + except KeyError: + return redirect(loadLoginPage) @csrf_exempt def localInitiate(request): diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 789de56ea..7b1c21a37 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -765,6 +765,9 @@
  • {% trans "Services Status" %}
  • +
  • {% trans "Package Manager" %} +
  • diff --git a/baseTemplate/views.py b/baseTemplate/views.py index 60494ba00..2fee1a4d1 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -59,7 +59,7 @@ def getAdminStatus(request): pdns = PDNSStatus.objects.get(pk=1) currentACL['dnsAsWhole'] = pdns.serverStatus except: - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: pdnsPath = '/etc/powerdns' else: pdnsPath = '/etc/pdns' diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index d6c9058de..ffab613c2 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -1080,7 +1080,7 @@ class CloudManager: finalData['ramInGB'] = inGB - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/my.cnf') else: finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/mysql/my.cnf') diff --git a/cyberpanel.sh b/cyberpanel.sh index 993cc279d..1f5721acd 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1,6 +1,6 @@ #!/bin/bash -#CyberPanel installer script for CentOS 7.X, CentOS 8.X, CloudLinux 7.X and Ubuntu 18.04 +#CyberPanel installer script for CentOS 7.X, CentOS 8.X, CloudLinux 7.X, Ubuntu 18.04 and Ubuntu 20.04 SUDO_TEST=$(set) @@ -21,14 +21,28 @@ KEY_SIZE="" ADMIN_PASS="1234567" MEMCACHED="ON" REDIS="ON" -TOTAL_RAM=$(free -m | awk '/Mem\:/ { print $2 }') +TOTAL_RAM=$(free -m | awk '/Mem:/ { print $2 }') CENTOS_8="False" +UBUNTU_20="False" WATCHDOG="OFF" BRANCH_NAME="v${TEMP:12:3}.${TEMP:25:1}" VIRT_TYPE="" GIT_URL="github.com/usmannasir/cyberpanel" GIT_CONTENT_URL="raw.githubusercontent.com/usmannasir/cyberpanel" +disable_repos() { + +if [[ $SERVER_OS == "CentOS" ]] ; then + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo +fi + +} check_return() { #check previous command result , 0 = ok , non-0 = something wrong. @@ -45,7 +59,6 @@ if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh chmod 700 /usr/bin/cyberpanel_utility fi - } watchdog_setup() { @@ -404,13 +417,15 @@ if [[ $SERVER_OS == "CentOS" ]] ; then else pip3.6 install virtualenv fi - check_return - fi + check_return + +fi if [[ $SERVER_OS == "Ubuntu" ]] ; then + apt update -y DEBIAN_FRONTEND=noninteractive apt upgrade -y - DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev virtualenv git socat vim + DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev virtualenv git socat vim unzip zip check_return DEBIAN_FRONTEND=noninteractive apt install -y python3-pip @@ -421,6 +436,11 @@ if [[ $SERVER_OS == "Ubuntu" ]] ; then DEBIAN_FRONTEND=noninteractive apt install -y python3-venv check_return + if [[ $UBUNTU_20 == "True" ]] ; then + pip3 install virtualenv==16.7.9 + fi + check_return + fi } @@ -544,6 +564,7 @@ fi check_OS() { echo -e "\nChecking OS..." OUTPUT=$(cat /etc/*release) + if echo $OUTPUT | grep -q "CentOS Linux 7" ; then echo -e "\nDetecting CentOS 7.X...\n" SERVER_OS="CentOS" @@ -562,12 +583,23 @@ elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then echo -e "\nUbuntu 18.04 x32 detected...ths only works on x64 system." exit fi +elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then + if uname -m | grep -q 64 ; then + echo -e "\nDetecting Ubuntu 20.04 ...\n" + SERVER_OS="Ubuntu" + UBUNTU_20="True" + else + echo -e "\nUbuntu 20 x32 detected...ths only works on x64 system." + exit + fi else cat /etc/*release echo -e "\nUnable to detect your OS...\n" - echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n" + echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n" exit 1 fi + + } check_root() { @@ -985,9 +1017,9 @@ if [[ $debug == "0" ]] ; then exit fi -if [[ $debug == "1" ]] ; then - /usr/local/CyberPanel/bin/pip3 install --ignore-installed /usr/local/pip-packs/* +if [[ $debug == "1" ]] ; then + pip3.6 install --ignore-installed /usr/local/pip-packs/* if [[ $REDIS_HOSTING == "Yes" ]] ; then /usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --redis enable else @@ -1009,6 +1041,7 @@ if [[ $REDIS == "ON" ]] ; then fi after_install fi + } pip_virtualenv() { @@ -1025,16 +1058,25 @@ export LC_ALL=en_US.UTF-8 if [[ $DEV == "ON" ]] ; then #install dev branch #wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt - cd /usr/local/ - virtualenv -p /usr/bin/python3 CyberPanel - source /usr/local/CyberPanel/bin/activate - wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip - check_return - unzip /usr/local/cyberpanel-pip.zip -d /usr/local - check_return - pip3.6 install --ignore-installed /usr/local/pip-packs/* - check_return - cd - + virtualenv -p /usr/bin/python3 /usr/local/CyberPanel + + if [[ $UBUNTU_20 == "False" ]] ; then + source /usr/local/CyberPanel/bin/activate + wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip + check_return + unzip /usr/local/cyberpanel-pip.zip -d /usr/local + check_return + pip3.6 install --ignore-installed /usr/local/pip-packs/* + check_return + else + . /usr/local/CyberPanel/bin/activate + wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip + check_return + unzip /usr/local/cyberpanel-pip.zip -d /usr/local + check_return + pip3 install --ignore-installed /usr/local/packages/* + check_return + fi fi if [ -f requirements.txt ] && [ -d cyberpanel ] ; then @@ -1122,13 +1164,24 @@ trusted-host=pypi.python.org EOF fi -virtualenv -p /usr/bin/python3 /usr/local/CyberCP -source /usr/local/CyberCP/bin/activate -pip3.6 install --ignore-installed /usr/local/pip-packs/* -check_return -systemctl restart lscpd fi +virtualenv -p /usr/bin/python3 /usr/local/CyberCP + +if [[ $UBUNTU_20 == "False" ]] ; then + source /usr/local/CyberCP/bin/activate + check_return + pip3 install --ignore-installed /usr/local/pip-packs/* + check_return +else + . /usr/local/CyberCP/bin/activate + check_return + pip3 install --ignore-installed /usr/local/packages/* + check_return +fi + +systemctl restart lscpd + for version in $(ls /usr/local/lsws | grep lsphp); do php_ini=$(find /usr/local/lsws/$version/ -name php.ini) @@ -1251,6 +1304,10 @@ fi fi #fix php.ini & issue +if [[ $UBUNTU_20 == "True" ]] ; then + cp /usr/local/lsws/lsphp73/bin/php /usr/bin +fi + #clear echo "###################################################################" echo " CyberPanel Successfully Installed " @@ -1382,6 +1439,8 @@ else fi } +##START + if [ $# -eq 0 ] ; then echo -e "\nInitializing...\n" else @@ -1480,6 +1539,8 @@ else DOWNLOAD_SERVER="cdn.cyberpanel.sh" fi +##END + check_OS check_virtualization check_root @@ -1488,9 +1549,6 @@ check_process check_provider - - - if [[ $SILENT = "ON" ]] ; then argument_mode else @@ -1511,18 +1569,4 @@ main_install ### Disable Centos Default Repos -disable_repos() { - -if [[ $SERVER_OS == "CentOS" ]] ; then - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo -fi - -} - disable_repos \ No newline at end of file diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index d833ba5f6..2f49f7edf 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -12,6 +12,7 @@ GIT_URL="github.com/usmannasir/cyberpanel" GIT_CONTENT_URL="raw.githubusercontent.com/usmannasir/cyberpanel" SERVER_COUNTRY="unknow" SERVER_COUNTRY=$(curl --silent --max-time 5 https://cyberpanel.sh/?country) +UBUNTU_20="False" ### Update and remove not needed repos @@ -159,6 +160,7 @@ check_root echo -e "\nChecking OS..." OUTPUT=$(cat /etc/*release) + if echo $OUTPUT | grep -q "CentOS Linux 7" ; then echo -e "\nDetecting CentOS 7.X...\n" SERVER_OS="CentOS7" @@ -189,6 +191,10 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then echo -e "\nDetecting Ubuntu 18.04...\n" SERVER_OS="Ubuntu" +elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then + echo -e "\nDetecting Ubuntu 20.04...\n" + SERVER_OS="Ubuntu" + UBUNTU_20="True" else cat /etc/*release echo -e "\nUnable to detect your OS...\n" @@ -236,9 +242,17 @@ else fi rm -f requirments.txt -wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip + +if [[ $UBUNTU_20 == "False" ]] ; then + wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip +else + wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip +fi + check_return rm -rf /usr/local/pip-packs/ +rm -rf /usr/local/packages + unzip /usr/local/cyberpanel-pip.zip -d /usr/local check_return . /usr/local/CyberPanel/bin/activate @@ -247,7 +261,11 @@ check_return if [ $SERVER_OS = "Ubuntu" ] ; then . /usr/local/CyberPanel/bin/activate check_return - pip3 install --ignore-installed /usr/local/pip-packs/* + if [[ $UBUNTU_20 == "False" ]] ; then + pip3 install --ignore-installed /usr/local/pip-packs/* + else + pip3 install --ignore-installed /usr/local/packages/* + fi check_return else source /usr/local/CyberPanel/bin/activate @@ -292,7 +310,11 @@ check_return if [ $SERVER_OS = "Ubuntu" ] ; then . /usr/local/CyberCP/bin/activate check_return - pip3 install --ignore-installed /usr/local/pip-packs/* + if [[ $UBUNTU_20 == "False" ]] ; then + pip3 install --ignore-installed /usr/local/pip-packs/* + else + pip3 install --ignore-installed /usr/local/packages/* + fi check_return else source /usr/local/CyberCP/bin/activate @@ -304,11 +326,15 @@ fi ## +rm -f wsgi-lsapi-1.4.tgz rm -f wsgi-lsapi-1.5.tgz +rm -f wsgi-lsapi-1.6.tgz rm -rf wsgi-lsapi-1.4 -wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.5.tgz -tar xf wsgi-lsapi-1.5.tgz -cd wsgi-lsapi-1.5 +rm -rf wsgi-lsapi-1.5 +rm -rf wsgi-lsapi-1.6 +wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.6.tgz +tar xf wsgi-lsapi-1.6.tgz +cd wsgi-lsapi-1.6 /usr/local/CyberPanel/bin/python ./configure.py make diff --git a/databases/static/databases/databases.js b/databases/static/databases/databases.js index e13d25977..d1e91175b 100755 --- a/databases/static/databases/databases.js +++ b/databases/static/databases/databases.js @@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.dbPassword = randomPassword(12); + $scope.dbPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.dbPassword = randomPassword(12); + $scope.dbPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -493,4 +493,4 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) { } setupPHPMYAdminSession(); -}); \ No newline at end of file +}); diff --git a/dns/models.py b/dns/models.py index c926566db..c42b663ad 100755 --- a/dns/models.py +++ b/dns/models.py @@ -23,7 +23,7 @@ class Records(models.Model): domain_id = models.IntegerField(blank=True, null=True) name = models.CharField(max_length=255, blank=True, null=True) type = models.CharField(max_length=10, blank=True, null=True) - content = models.CharField(max_length=64000, blank=True, null=True) + content = models.CharField(max_length=1000, blank=True, null=True) ttl = models.IntegerField(blank=True, null=True) prio = models.IntegerField(blank=True, null=True) change_date = models.IntegerField(blank=True, null=True) @@ -41,7 +41,7 @@ class Comments(models.Model): type = models.CharField(max_length=10) modified_at = models.IntegerField() account = models.CharField(max_length=40) - comment = models.CharField(max_length=64000) + comment = models.TextField() class Meta: db_table = 'comments' diff --git a/dockerManager/dockerInstall.py b/dockerManager/dockerInstall.py index 8b5220169..83589ad27 100755 --- a/dockerManager/dockerInstall.py +++ b/dockerManager/dockerInstall.py @@ -18,7 +18,9 @@ class DockerInstall: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Starting Docker Installation..\n", 1) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + command = 'sudo dnf install -y docker-ce --nobest' + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos: command = 'sudo yum install -y docker' else: command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io' diff --git a/filemanager/views.py b/filemanager/views.py index 6edc740ea..57a3d5d0f 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -64,10 +64,11 @@ def downloadFile(request): try: userID = request.session['userID'] admin = Administrator.objects.get(pk=userID) - import urllib.parse + from urllib.parse import quote + from django.utils.encoding import iri_to_uri fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:] - fileToDownload = urllib.parse.unquote(fileToDownload) + fileToDownload = iri_to_uri(fileToDownload) domainName = request.GET.get('domainName') diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index a0acd1f53..eaa372adb 100755 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) { text: 'Could not connect to server, please refresh this page', type: 'error' }); - - } } diff --git a/ftp/static/ftp/ftp.js b/ftp/static/ftp/ftp.js index 679a8b5f7..a80377e6b 100755 --- a/ftp/static/ftp/ftp.js +++ b/ftp/static/ftp/ftp.js @@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.ftpPassword = randomPassword(12); + $scope.ftpPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -451,11 +451,11 @@ app.controller('listFTPAccounts', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.ftpPassword = randomPassword(12); + $scope.ftpPassword = randomPassword(16); }; $scope.usePassword = function () { $scope.generatedPasswordView = true; }; -}); \ No newline at end of file +}); diff --git a/highAvailability/haManager.py b/highAvailability/haManager.py index 077ada262..dcda19b6d 100755 --- a/highAvailability/haManager.py +++ b/highAvailability/haManager.py @@ -36,7 +36,7 @@ class HAManager(multi.Thread): def setupNode(self): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: mesg = 'Clusters are only supported on Ubuntu 18.04. [404]' logging.statusWriter(self.data['tempStatusPath'], mesg) return 0 diff --git a/install/cyberpanel.repo b/install/cyberpanel.repo index 7723bb480..4dc23d316 100755 --- a/install/cyberpanel.repo +++ b/install/cyberpanel.repo @@ -1,4 +1,5 @@ -[cyberpanel] -name=Cyber Panel -baseurl=http://repo.cyberpersons.com -gpgcheck=0 \ No newline at end of file +[CyberPanel] +name=CyberPanel +baseurl=https://rep.cyberpanel.net/ +gpgkey=https://rep.cyberpanel.net/RPM-GPG-KEY-cyberpanel +gpgcheck=1 \ No newline at end of file diff --git a/install/install.py b/install/install.py index 411534b69..cfb9eee6e 100755 --- a/install/install.py +++ b/install/install.py @@ -323,7 +323,7 @@ class preFlightsChecks: os._exit(os.EX_SOFTWARE) elif self.distro == centos: - command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm' + command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el7.noarch.rpm' preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) elif self.distro == cent8: command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm' @@ -1494,13 +1494,13 @@ imap_folder_list_limit = 0 def setupPythonWSGI(self): try: - command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz" + command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.6.tgz" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - command = "tar xf wsgi-lsapi-1.4.tgz" + command = "tar xf wsgi-lsapi-1.6.tgz" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - os.chdir("wsgi-lsapi-1.4") + os.chdir("wsgi-lsapi-1.6") command = "/usr/local/CyberPanel/bin/python ./configure.py" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index bba011f20..ec9bd9974 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -7,12 +7,32 @@ import randomPassword import errno import MySQLdb as mariadb import install +from os.path import exists #distros centos=0 ubuntu=1 cent8=2 +def get_Ubuntu_release(): + release = -1 + if exists("/etc/lsb-release"): + distro_file = "/etc/lsb-release" + with open(distro_file) as f: + for line in f: + if line[:16] == "DISTRIB_RELEASE=": + release = float(line[16:]) + + if release == -1: + print("Can't find distro release name in " + distro_file + " - fatal error") + + else: + logging.InstallLog.writeToFile("Can't find linux release file - fatal error") + print("Can't find linux release file - fatal error") + os._exit(os.EX_UNAVAILABLE) + + return release + class InstallCyberPanel: mysql_Root_password = "" @@ -308,8 +328,11 @@ class InstallCyberPanel: conn = mariadb.connect(user='root', passwd=self.mysql_Root_password) cursor = conn.cursor() cursor.execute('set global innodb_file_per_table = on;') - cursor.execute('set global innodb_file_format = Barracuda;') - cursor.execute('set global innodb_large_prefix = on;') + try: + cursor.execute('set global innodb_file_format = Barracuda;') + cursor.execute('set global innodb_large_prefix = on;') + except BaseException as msg: + self.stdOut('%s. [ERROR:335]' % (str(msg))) cursor.close() conn.close() @@ -333,17 +356,18 @@ class InstallCyberPanel: command = 'DEBIAN_FRONTEND=noninteractive apt install pure-ftpd-mysql -y' os.system(command) - command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + if get_Ubuntu_release() == 18.10: + command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) elif self.distro == centos: command = "yum install -y pure-ftpd" @@ -385,8 +409,11 @@ class InstallCyberPanel: except: logging.InstallLog.writeToFile("[ERROR] Could not create directory for FTP SSL") + if (self.distro == centos or self.distro == cent8) or (self.distro == ubuntu and get_Ubuntu_release() == 18.14): + command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem' + else: + command = 'openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem' - command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem' install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) os.chdir(self.cwd) diff --git a/install/pure-ftpd/pure-ftpd.conf b/install/pure-ftpd/pure-ftpd.conf index 1c0af0529..299252b61 100755 --- a/install/pure-ftpd/pure-ftpd.conf +++ b/install/pure-ftpd/pure-ftpd.conf @@ -18,7 +18,7 @@ MaxLoad 4 AntiWarez yes Umask 133:022 MinUID 1000 -UseFtpUsers no +#UseFtpUsers no AllowUserFXP no AllowAnonymousFXP no ProhibitDotFilesWrite no diff --git a/locale/pt-BR/LC_MESSAGES/django.mo b/locale/pt-BR/LC_MESSAGES/django.mo index 8700c1561..ec8862658 100644 Binary files a/locale/pt-BR/LC_MESSAGES/django.mo and b/locale/pt-BR/LC_MESSAGES/django.mo differ diff --git a/locale/pt-BR/LC_MESSAGES/django.po b/locale/pt-BR/LC_MESSAGES/django.po index 12e174b3d..3cb6f2ebc 100644 --- a/locale/pt-BR/LC_MESSAGES/django.po +++ b/locale/pt-BR/LC_MESSAGES/django.po @@ -6189,7 +6189,11 @@ msgstr "Instale o WordPress com LSCache." #: websiteFunctions/templates/websiteFunctions/installWordPress.html:28 msgid "Blog Title" -msgstr "" +msgstr "Título do Blog" + +#: websiteFunctions/templates/websiteFunctions/installWordPress.html:58 +msgid "Leave empty to install in website home directory. (Without preceding slash)" +msgstr "Deixe em branco para instalar no diretório inicial do site. (Sem barra anterior)" #: websiteFunctions/templates/websiteFunctions/launchChild.html:29 msgid "Copy/Sync to Master" diff --git a/locale/pt/LC_MESSAGES/django.mo b/locale/pt/LC_MESSAGES/django.mo index 8700c1561..ec8862658 100755 Binary files a/locale/pt/LC_MESSAGES/django.mo and b/locale/pt/LC_MESSAGES/django.mo differ diff --git a/locale/pt/LC_MESSAGES/django.po b/locale/pt/LC_MESSAGES/django.po index fdf3601b3..153f62d0f 100755 --- a/locale/pt/LC_MESSAGES/django.po +++ b/locale/pt/LC_MESSAGES/django.po @@ -6724,7 +6724,11 @@ msgstr "Instale o WordPress com LSCache." #: websiteFunctions/templates/websiteFunctions/installWordPress.html:28 msgid "Blog Title" -msgstr "" +msgstr "Título do Blog" + +#: websiteFunctions/templates/websiteFunctions/installWordPress.html:58 +msgid "Leave empty to install in website home directory. (Without preceding slash)" +msgstr "Deixe em branco para instalar no diretório inicial do site. (Sem barra anterior)" #: websiteFunctions/templates/websiteFunctions/launchChild.html:32 msgid "Copy/Sync to Master" diff --git a/loginSystem/templates/loginSystem/login.html b/loginSystem/templates/loginSystem/login.html index 4493f80fa..06aecce9b 100755 --- a/loginSystem/templates/loginSystem/login.html +++ b/loginSystem/templates/loginSystem/login.html @@ -197,21 +197,21 @@
    @@ -235,4 +235,4 @@ - \ No newline at end of file + diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index 2463bb94f..a67006543 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -226,6 +226,38 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) + def fixMailSSL(self): + try: + + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + data = json.loads(self.request.body) + selectedDomain = data['selectedDomain'] + + admin = Administrator.objects.get(pk=userID) + + if ACLManager.checkOwnership(selectedDomain, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + website = Websites.objects.get(domain=selectedDomain) + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = '%s setupAutoDiscover --virtualHostName %s --websiteOwner %s' % (execPath, selectedDomain, website.admin.userName) + + ProcessUtilities.executioner(execPath) + + data_ret = {'status': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + def emailForwarding(self): try: userID = self.request.session['userID'] @@ -476,6 +508,19 @@ class MailServerManager: except: raise BaseException('No emails exist for this domain.') + postfixMapPath = '/etc/postfix/vmail_ssl.map' + + if os.path.exists(postfixMapPath): + + postfixMapData = open(postfixMapPath, 'r').read() + + if postfixMapData.find(selectedDomain) == -1: + mailConfigured = 0 + else: + mailConfigured = 1 + else: + mailConfigured = 0 + records = emailDomain.eusers_set.all() json_data = "[" @@ -492,7 +537,7 @@ class MailServerManager: json_data = json_data + ',' + json.dumps(dic) json_data = json_data + ']' - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) + final_json = json.dumps({'status': 1, 'fetchStatus': 1,'serverHostname': 'mail.%s' % (selectedDomain), 'mailConfigured': mailConfigured, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) except BaseException as msg: @@ -607,6 +652,12 @@ class MailServerManager: return ACLManager.loadError() try: + + import tldextract + + extractDomain = tldextract.extract(domainName) + domainName = extractDomain.domain + '.' + extractDomain.suffix + path = "/etc/opendkim/keys/" + domainName + "/default.txt" command = "sudo cat " + path output = ProcessUtilities.outputExecutioner(command, 'opendkim') @@ -617,6 +668,8 @@ class MailServerManager: command = "sudo cat " + path privateKey = ProcessUtilities.outputExecutioner(command, 'opendkim') + DNS.createDKIMRecords(domainName) + data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex], 'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!', 'error_message': "None"} diff --git a/mailServer/static/mailServer/mailServer.js b/mailServer/static/mailServer/mailServer.js index f50b36a45..f46bb4d4a 100755 --- a/mailServer/static/mailServer/mailServer.js +++ b/mailServer/static/mailServer/mailServer.js @@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.emailPassword = randomPassword(12); + $scope.emailPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.emailPassword = randomPassword(12); + $scope.emailPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -1124,6 +1124,7 @@ app.controller('listEmails', function ($scope, $http) { $scope.cyberpanelLoading = true; $scope.emailsAccounts = true; + $scope.mailConfigured = 1; $scope.populateCurrentRecords = function () { $scope.cyberpanelLoading = false; @@ -1151,6 +1152,9 @@ app.controller('listEmails', function ($scope, $http) { if (response.data.status === 1) { $scope.emailsAccounts = false; $scope.records = JSON.parse(response.data.data); + $scope.mailConfigured = response.data.mailConfigured; + $scope.serverHostname = response.data.serverHostname; + new PNotify({ title: 'Success!', text: 'Emails Successfully Fetched.', @@ -1229,6 +1233,55 @@ app.controller('listEmails', function ($scope, $http) { } + }; + + $scope.fixMailSSL = function (email) { + + $scope.cyberpanelLoading = false; + + var url = "/email/fixMailSSL"; + + var data = { + selectedDomain: $scope.selectedDomain, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + if (response.data.status === 1) { + $scope.populateCurrentRecords(); + new PNotify({ + title: 'Success!', + text: 'Configurations applied successfully.', + type: 'success' + }); + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + new PNotify({ + title: 'Error!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + }; $scope.changePasswordInitial = function (email) { @@ -1291,4 +1344,4 @@ app.controller('listEmails', function ($scope, $http) { }); -/* Java script code for List Emails Ends here */ \ No newline at end of file +/* Java script code for List Emails Ends here */ diff --git a/mailServer/templates/mailServer/listEmails.html b/mailServer/templates/mailServer/listEmails.html index 955cdf4f8..8b86a7786 100755 --- a/mailServer/templates/mailServer/listEmails.html +++ b/mailServer/templates/mailServer/listEmails.html @@ -56,7 +56,106 @@
    -
    +
    +
    +

    {% trans "SSL for email is not configured properly, you may get Self-Signed error on mail clients such as Outlook and Thunderbird. More details " %}here.

    +
    + + + +
    + +
    + +

    {% trans "Details To Configure Mail Clients" %}

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {% trans "POP3" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}110
    {% trans "Port" %}995 (SSL)
    {% trans "SSL" %}STARTTLS
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {% trans "IMAP" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}143
    {% trans "Port" %}993 (SSL)
    {% trans "SSL" %}STARTTLS
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {% trans "SMTP" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}25
    {% trans "Port" %}587 (SSL)
    {% trans "Port" %}465 (SSL)
    {% trans "SSL" %}STARTTLS
    +
    + +
    @@ -74,7 +173,8 @@ class="btn btn-border btn-alt border-purple btn-link font-purple" href="#" title="">{% trans 'Change Password' %} - {% trans 'Delete' %} diff --git a/mailServer/urls.py b/mailServer/urls.py index 74d902484..a974c6b64 100755 --- a/mailServer/urls.py +++ b/mailServer/urls.py @@ -20,6 +20,7 @@ urlpatterns = [ url(r'^deleteEmailAccount', views.deleteEmailAccount, name='deleteEmailAccount'), url(r'^getEmailsForDomain$', views.getEmailsForDomain, name='getEmailsForDomain'), url(r'^submitEmailDeletion', views.submitEmailDeletion, name='submitEmailDeletion'), + url(r'^fixMailSSL', views.fixMailSSL, name='fixMailSSL'), ## Change email password diff --git a/mailServer/views.py b/mailServer/views.py index 337567c07..12ce04a91 100755 --- a/mailServer/views.py +++ b/mailServer/views.py @@ -91,6 +91,18 @@ def submitEmailDeletion(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) +def fixMailSSL(request): + try: + + msM = MailServerManager(request) + coreResult = msM.fixMailSSL() + + return coreResult + except KeyError as msg: + data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + def emailForwarding(request): try: msM = MailServerManager(request) diff --git a/managePHP/views.py b/managePHP/views.py index 4ef3a6ecc..62e9d0f26 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1085,7 +1085,7 @@ def installExtensions(request): phpPath = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php70.xml') else: phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp70.xml') @@ -1116,7 +1116,7 @@ def installExtensions(request): phpPath = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php71.xml') else: phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp71.xml') @@ -1144,7 +1144,7 @@ def installExtensions(request): php72Path = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php72.xml') else: php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp72.xml') @@ -1172,7 +1172,7 @@ def installExtensions(request): php73Path = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php73.xml') else: php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp73.xml') @@ -1200,7 +1200,7 @@ def installExtensions(request): php74Path = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php74.xml') else: php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp74.xml') @@ -1344,7 +1344,7 @@ def getRequestStatus(request): checkCommand = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: checkCommand = 'yum list installed' checkCommand = shlex.split(checkCommand) else: @@ -1469,7 +1469,7 @@ def getRequestStatusApache(request): checkCommand = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: checkCommand = 'yum list installed' checkCommand = shlex.split(checkCommand) else: @@ -1607,7 +1607,7 @@ def getCurrentPHPConfig(request): phpVers = "php" + PHPManager.getPHPString(phpVers) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini" else: initial = phpVers[3] @@ -1767,7 +1767,7 @@ def getCurrentAdvancedPHPConfig(request): phpVers = "php" + PHPManager.getPHPString(phpVers) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini" else: initial = phpVers[3] @@ -1809,7 +1809,7 @@ def savePHPConfigAdvance(request): phpVers = "php" + PHPManager.getPHPString(phpVers) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini" else: initial = phpVers[3] diff --git a/manageSSL/views.py b/manageSSL/views.py index 05ec7e988..0dfdb16c5 100755 --- a/manageSSL/views.py +++ b/manageSSL/views.py @@ -126,7 +126,7 @@ def sslForHostName(request): else: return ACLManager.loadError() - websitesName = ACLManager.findAllSites(currentACL, userID) + websitesName = ACLManager.findAllSites(currentACL, userID, 1) return render(request, 'manageSSL/sslForHostName.html', {'websiteList': websitesName}) except KeyError: @@ -151,11 +151,15 @@ def obtainHostNameSSL(request): data = json.loads(request.body) virtualHost = data['virtualHost'] - path = "/home/" + virtualHost + "/public_html" + try: + website = Websites.objects.get(domain=virtualHost) + path = "/home/" + virtualHost + "/public_html" + except: + website = ChildDomains.objects.get(domain=virtualHost) + path = website.path - data = json.loads(request.body) - virtualHost = data['virtualHost'] admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(virtualHost, admin, currentACL) == 1: pass else: diff --git a/manageServices/serviceManager.py b/manageServices/serviceManager.py index c37468a3b..05ef80e92 100755 --- a/manageServices/serviceManager.py +++ b/manageServices/serviceManager.py @@ -6,6 +6,8 @@ from manageServices.models import SlaveServers class ServiceManager: + slaveConfPath = '/home/cyberpanel/slaveConf' + def __init__(self, extraArgs): self.extraArgs = extraArgs @@ -24,14 +26,14 @@ class ServiceManager: ipStringNoSubnet = '' for items in SlaveServers.objects.all(): - ipsString = ipsString + '%s/32 ' % (items.slaveServerIP) - ipStringNoSubnet = ipStringNoSubnet + '%s ' % (items.slaveServerIP) - - ipsString = ipsString.rstrip(' ') - ipStringNoSubnet = ipStringNoSubnet.rstrip(' ') - + ipsString = ipsString + '%s/32, ' % (items.slaveServerIP) + ipStringNoSubnet = ipStringNoSubnet + '%s, ' % (items.slaveServerIP) + ipsString = ipsString.rstrip(', ') + ipStringNoSubnet = ipStringNoSubnet.rstrip(', ') + tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + writeToFile = open(tempPath, 'w') for items in data: if items.find('allow-axfr-ips') > -1: @@ -49,14 +51,14 @@ class ServiceManager: if items.find('slave') > -1: continue + if items.find('master') > -1: + continue + counter = counter + 1 - tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - writeToFile = open(tempPath, 'w') - - for items in data: writeToFile.writelines(items + '\n') + writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n') writeToFile.writelines('also-notify=' + ipStringNoSubnet + '\n') writeToFile.writelines('daemon=no\n') @@ -64,33 +66,42 @@ class ServiceManager: writeToFile.writelines('master=yes\n') writeToFile.close() else: - counter = 0 + import os - for items in data: - if items.find('allow-axfr-ips') > -1: - continue + if not os.path.exists(ServiceManager.slaveConfPath): - if items.find('also-notify') > -1: - continue + writeToFile = open(ServiceManager.slaveConfPath, 'w') + writeToFile.write('configured') + writeToFile.close() - if items.find('daemon=') > -1: - continue + counter = 0 - if items.find('disable-axfr') > -1: - continue + for items in data: + if items.find('allow-axfr-ips') > -1: + continue - if items.find('slave') > -1: - continue + if items.find('also-notify') > -1: + continue - counter = counter + 1 + if items.find('daemon=') > -1: + continue - tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - writeToFile = open(tempPath, 'w') + if items.find('disable-axfr') > -1: + continue - for items in data: - writeToFile.writelines(items + '\n') + if items.find('slave') > -1: + continue - slaveData = """slave=yes + counter = counter + 1 + + tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + writeToFile = open(tempPath, 'w') + + for items in data: + writeToFile.writelines(items + '\n') + + slaveData = """ +slave=yes daemon=yes disable-axfr=yes guardian=yes @@ -103,15 +114,14 @@ setuid=pdns superslave=yes """ - writeToFile.writelines(slaveData) - writeToFile.close() + writeToFile.writelines(slaveData) + writeToFile.close() + + command = 'sudo mv ' + tempPath + ' ' + path + ProcessUtilities.executioner(command) for items in Supermasters.objects.all(): items.delete() Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save() - command = 'sudo mv ' + tempPath + ' ' + path - #subprocess.call(shlex.split(command)) - ProcessUtilities.executioner(command) - diff --git a/manageServices/templates/manageServices/managePowerDNS.html b/manageServices/templates/manageServices/managePowerDNS.html index 685f53474..013dd0533 100755 --- a/manageServices/templates/manageServices/managePowerDNS.html +++ b/manageServices/templates/manageServices/managePowerDNS.html @@ -51,57 +51,57 @@
    -
    +
    -
    +
    -
    +
    -
    +
    -
    +
    -
    +
    -
    +
    -
    - +
    +
    diff --git a/manageServices/views.py b/manageServices/views.py index 1facec6a0..b95965ed6 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - from django.shortcuts import render from django.shortcuts import HttpResponse, redirect import plogical.CyberCPLogFileWriter as logging @@ -14,19 +13,41 @@ from .serviceManager import ServiceManager from plogical.processUtilities import ProcessUtilities # Create your views here. - def managePowerDNS(request): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) + if currentACL['admin'] == 1: pass else: return ACLManager.loadError() try: - return render(request, 'manageServices/managePowerDNS.html', {"status": 1}) + data = {} + data['status'] = 1 + + pdnsStatus = PDNSStatus.objects.get(pk=1) + + if pdnsStatus.type == 'MASTER': + counter = 1 + + for items in SlaveServers.objects.all(): + + if counter == 1: + data['slaveServer'] = items.slaveServer + data['slaveServerIP'] = items.slaveServerIP + else: + data['slaveServer%s' % (str(counter))] = items.slaveServer + data['slaveServerIP%s' % (str(counter))] = items.slaveServerIP + + counter = counter + 1 + else: + data['slaveServerNS'] = pdnsStatus.masterServer + data['masterServerIP'] = pdnsStatus.masterIP + + return render(request, 'manageServices/managePowerDNS.html', data) except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") diff --git a/plogical/acl.py b/plogical/acl.py index a79139059..e3ae1f63f 100755 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -405,13 +405,19 @@ class ACLManager: return admin.package_set.all() @staticmethod - def findAllSites(currentACL, userID): + def findAllSites(currentACL, userID, fetchChilds = 0): websiteNames = [] if currentACL['admin'] == 1: allWebsites = Websites.objects.all() + for items in allWebsites: websiteNames.append(items.domain) + + if fetchChilds: + for child in items.childdomains_set.all(): + websiteNames.append(child.domain) + else: admin = Administrator.objects.get(pk=userID) @@ -421,11 +427,19 @@ class ACLManager: for items in websites: websiteNames.append(items.domain) + if fetchChilds: + for child in items.childdomains_set.all(): + websiteNames.append(child.domain) + for items in admins: webs = items.websites_set.all() for web in webs: websiteNames.append(web.domain) + if fetchChilds: + for child in web.childdomains_set.all(): + websiteNames.append(child.domain) + return websiteNames diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 57b3909ed..6a438fd43 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -33,6 +33,7 @@ class ApplicationInstaller(multi.Thread): def run(self): try: + if self.installApp == 'wordpress': self.installWordPress() elif self.installApp == 'joomla': @@ -51,10 +52,55 @@ class ApplicationInstaller(multi.Thread): self.installMagento() elif self.installApp == 'convertDomainToSite': self.convertDomainToSite() + elif self.installApp == 'updatePackage': + self.updatePackage() except BaseException as msg: logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]') + def updatePackage(self): + try: + + package = self.extraArgs['package'] + + from serverStatus.serverStatusUtil import ServerStatusUtil + + f = open(ServerStatusUtil.lswsInstallStatusPath, 'a') + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: + + if package == 'all': + command = 'DEBIAN_FRONTEND=noninteractive apt-get update -y' + f.write(ProcessUtilities.outputExecutioner(command)) + + f.flush() + + command = 'apt-get upgrade -y' + f.write(ProcessUtilities.outputExecutioner(command)) + else: + command = 'apt-get install --only-upgrade %s -y' % (package) + f.write(ProcessUtilities.outputExecutioner(command)) + + f.close() + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + if package == 'all': + command = 'yum update -y' + f.write(ProcessUtilities.outputExecutioner(command)) + else: + command = 'yum update %s -y' % (package) + f.write(ProcessUtilities.outputExecutioner(command)) + + f.close() + + logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + 'Package(s) upgraded successfully. [200]', + 1) + + except BaseException as msg: + from serverStatus.serverStatusUtil import ServerStatusUtil + logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath, 'Failed. Error: %s. [404]' % (str(msg)), 1) + return 0 + def convertDomainToSite(self): try: @@ -368,7 +414,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -544,7 +590,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -704,7 +750,7 @@ class ApplicationInstaller(multi.Thread): shutil.rmtree(finalPath + "installation") - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -730,7 +776,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -918,7 +964,7 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 0a87c8e04..46f531eab 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -12,7 +12,7 @@ import os import time from plogical.backupUtilities import backupUtilities from re import match,I,M -from websiteFunctions.models import Backups +from websiteFunctions.models import Backups, BackupJob, BackupJobLogs from plogical.processUtilities import ProcessUtilities from random import randint import json, requests @@ -22,14 +22,23 @@ import signal class backupSchedule: now = datetime.now() + LOCAL = 0 + REMOTE = 1 + INFO = 0 + ERROR = 1 + backupLog = '' + runningPath = '/home/cyberpanel/remoteBackupPID' @staticmethod - def remoteBackupLogging(fileName, message): + def remoteBackupLogging(fileName, message, status = 0): try: file = open(fileName,'a') file.writelines("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n") print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")) file.close() + + BackupJobLogs(owner=backupSchedule.backupLog, status=status, message="[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message).save() + except IOError as msg: return "Can not write to error file." @@ -74,11 +83,45 @@ class backupSchedule: except: fileName = "Fetching.." + ifRunning = ProcessUtilities.outputExecutioner('ps aux') + + if (ifRunning.find('startBackup') > -1 or ifRunning.find('BackupRoot') > -1) and ifRunning.find('/%s/' % (backupDomain)): + pass + else: + if os.path.exists(status): + + status = open(status, 'r').read() + time.sleep(2) + + if status.find("Completed") > -1: + + ### Removing Files + + command = 'sudo rm -f ' + status + ProcessUtilities.normalExecutioner(command) + + command = 'sudo rm -f ' + backupFileNamePath + ProcessUtilities.normalExecutioner(command) + + command = 'sudo rm -f ' + pid + ProcessUtilities.normalExecutioner(command) + + backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost) + try: + os.remove(pathToFile) + except: + pass + return 1, tempStoragePath + else: + return 0, 'Backup process killed without reporting any error.' + else: + + return 0, 'Backup process killed without reporting any error.' + ## file name read ends if os.path.exists(status): status = open(status, 'r').read() - print(status) time.sleep(2) if status.find("Completed") > -1: @@ -120,18 +163,25 @@ class backupSchedule: except: pass - backupSchedule.remoteBackupLogging(backupLogPath, "An error occurred, Error message: " + status) + backupSchedule.remoteBackupLogging(backupLogPath, "Local backup creating failed for %s, Error message: %s" % (virtualHost, status), backupSchedule.ERROR) + try: os.remove(pathToFile) except: pass return 0, tempStoragePath + elif os.path.exists(schedulerPath): + backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed without reporting any error.', + backupSchedule.ERROR) os.remove(schedulerPath) return 0, 'Backup process killed without reporting any error.' except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]") + backupSchedule.remoteBackupLogging(backupLogPath, + "Local backup creating failed for %s, Error message: %s" % ( + virtualHost, str(msg)), backupSchedule.ERROR) return 0, str(msg) @staticmethod @@ -168,6 +218,8 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "") else: + backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) ) + backupSchedule.remoteBackupLogging(backupLogPath, "") backupSchedule.remoteBackupLogging(backupLogPath, "") @@ -196,6 +248,9 @@ class backupSchedule: command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " " + user + "@" + IPAddress+":~/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/" subprocess.call(shlex.split(command), stdout=writeToFile) + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(command) + ## Remove backups already sent to remote destinations os.remove(backupPath) @@ -206,16 +261,15 @@ class backupSchedule: @staticmethod def prepare(): try: - destinations = backupUtilities.destinationsPath - backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%m.%d.%Y_%H-%M-%S") + if os.path.exists(backupSchedule.runningPath): + pid = open(backupSchedule.runningPath, 'r').read() + print('\n\nRemote backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % (pid, pid)) + return 0 - backupSchedule.remoteBackupLogging(backupLogPath,"#################################################") - backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%m.%d.%Y_%H-%M-%S")) - backupSchedule.remoteBackupLogging(backupLogPath,"#################################################\n") - - backupSchedule.remoteBackupLogging(backupLogPath, "") - backupSchedule.remoteBackupLogging(backupLogPath, "") + writeToFile = open(backupSchedule.runningPath, 'w') + writeToFile.write(str(os.getpid())) + writeToFile.close() ## IP of Remote server. @@ -230,6 +284,27 @@ class backupSchedule: ipAddress = data['ipAddress'] + jobSuccessSites = 0 + jobFailedSites = 0 + + backupLogPath = "/usr/local/lscp/logs/backup_log." + time.strftime("%m.%d.%Y_%H-%M-%S") + + backupSchedule.backupLog = BackupJob(logFile=backupLogPath, location=backupSchedule.REMOTE, + jobSuccessSites=jobSuccessSites, jobFailedSites=jobFailedSites, + ipAddress=ipAddress, port=port) + backupSchedule.backupLog.save() + + + destinations = backupUtilities.destinationsPath + + + backupSchedule.remoteBackupLogging(backupLogPath,"#################################################") + backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%m.%d.%Y_%H-%M-%S")) + backupSchedule.remoteBackupLogging(backupLogPath,"#################################################\n") + + backupSchedule.remoteBackupLogging(backupLogPath, "") + backupSchedule.remoteBackupLogging(backupLogPath, "") + ## IPAddress of local server ipFile = "/etc/cyberpanel/machineIP" @@ -262,7 +337,8 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n") - + if os.path.exists(backupSchedule.runningPath): + os.remove(backupSchedule.runningPath) except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]") diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index a2c7f5f93..6065b9c92 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -17,18 +17,35 @@ from plogical.processUtilities import ProcessUtilities from re import match,I,M import signal from datetime import datetime +from websiteFunctions.models import BackupJob, BackupJobLogs class backupScheduleLocal: localBackupPath = '/home/cyberpanel/localBackupPath' + runningPath = '/home/cyberpanel/localBackupPID' now = datetime.now() - @staticmethod def prepare(): try: + + if os.path.exists(backupScheduleLocal.runningPath): + pid = open(backupScheduleLocal.runningPath, 'r').read() + print('\n\nLocal backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % (pid, pid)) + return 0 + + writeToFile = open(backupScheduleLocal.runningPath, 'w') + writeToFile.write(str(os.getpid())) + writeToFile.close() + backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S") backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime + jobSuccessSites = 0 + jobFailedSites = 0 + + backupSchedule.backupLog = BackupJob(logFile=backupLogPath, location=backupSchedule.LOCAL, jobSuccessSites=jobSuccessSites, jobFailedSites=jobFailedSites) + backupSchedule.backupLog.save() + writeToFile = open(backupLogPath, "a") backupSchedule.remoteBackupLogging(backupLogPath, "#################################################") @@ -43,6 +60,10 @@ class backupScheduleLocal: try: retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath) + if retValues[0] == 0: + backupSchedule.remoteBackupLogging(backupLogPath, '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, retValues[1]), backupSchedule.ERROR) + continue + if os.path.exists(backupScheduleLocal.localBackupPath): backupPath = retValues[1] + ".tar.gz" localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), backupRunTime) @@ -52,12 +73,14 @@ class backupScheduleLocal: command = 'mv %s %s' % (backupPath, localBackupPath) ProcessUtilities.normalExecutioner(command) + + jobSuccessSites = jobSuccessSites + 1 except BaseException as msg: + + jobFailedSites = jobFailedSites + 1 + backupSchedule.remoteBackupLogging(backupLogPath, - '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, str(msg))) - - - + '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, str(msg)), backupSchedule.ERROR) backupSchedule.remoteBackupLogging(backupLogPath, "") backupSchedule.remoteBackupLogging(backupLogPath, "") @@ -71,6 +94,14 @@ class backupScheduleLocal: writeToFile.close() + job = BackupJob.objects.get(logFile=backupLogPath) + job.jobFailedSites = jobFailedSites + job.jobSuccessSites = jobSuccessSites + job.save() + + if os.path.exists(backupScheduleLocal.runningPath): + os.remove(backupScheduleLocal.runningPath) + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]") diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index 59f62b16f..bf6b11b17 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -493,7 +493,6 @@ class backupUtilities: items.status = 1 items.size = totalSize items.save() - logging.CyberCPLogFileWriter.writeToFile(' again size: %s' % (totalSize)) except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg)) for items in backupObs: @@ -925,6 +924,11 @@ class backupUtilities: expectation.append("Permission denied") expectation.append("100%") + ## Temp changes + + command = 'chmod 600 %s' % ('/root/.ssh/cyberpanel.pub') + ProcessUtilities.executioner(command) + command = "scp -o StrictHostKeyChecking=no -P " + port + " /root/.ssh/cyberpanel.pub " + user + "@" + IPAddress + ":~/.ssh/authorized_keys" setupKeys = pexpect.spawn(command, timeout=3) @@ -950,15 +954,32 @@ class backupUtilities: else: raise BaseException + ## Temp changes + + command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub') + ProcessUtilities.executioner(command) + return [1, "None"] except pexpect.TIMEOUT as msg: + + command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub') + ProcessUtilities.executioner(command) + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, "TIMEOUT [sendKey]"] except pexpect.EOF as msg: + + command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub') + ProcessUtilities.executioner(command) + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, "EOF [sendKey]"] except BaseException as msg: + + command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub') + ProcessUtilities.executioner(command) + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, str(msg) + " [sendKey]"] @@ -981,7 +1002,7 @@ class backupUtilities: expectation.append("Permission denied") expectation.append("File exists") - command = "ssh -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress + ' "mkdir ~/.ssh || rm -f ~/.ssh/temp && rm -f ~/.ssh/authorized_temp && cp ~/.ssh/authorized_keys ~/.ssh/temp"' + command = "ssh -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress + ' "mkdir ~/.ssh || rm -f ~/.ssh/temp && rm -f ~/.ssh/authorized_temp && cp ~/.ssh/authorized_keys ~/.ssh/temp || chmod 700 ~/.ssh || chmod g-w ~"' setupKeys = pexpect.spawn(command, timeout=3) if os.path.exists(ProcessUtilities.debugPath): @@ -1183,6 +1204,7 @@ class backupUtilities: subprocess.call(shlex.split(command)) + command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + ' "cat ~/.ssh/authorized_temp > ~/.ssh/authorized_keys"' if os.path.exists(ProcessUtilities.debugPath): diff --git a/plogical/cronUtil.py b/plogical/cronUtil.py index a08803833..25f49e12c 100755 --- a/plogical/cronUtil.py +++ b/plogical/cronUtil.py @@ -9,7 +9,7 @@ class CronUtil: def getWebsiteCron(externalApp): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + externalApp else: cronPath = "/var/spool/cron/crontabs/" + externalApp @@ -29,7 +29,7 @@ class CronUtil: try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + externalApp else: cronPath = "/var/spool/cron/crontabs/" + externalApp @@ -51,7 +51,7 @@ class CronUtil: try: line -= 1 - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + externalApp else: cronPath = "/var/spool/cron/crontabs/" + externalApp @@ -81,7 +81,7 @@ class CronUtil: @staticmethod def addNewCron(externalApp, finalCron): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + externalApp else: cronPath = "/var/spool/cron/crontabs/" + externalApp @@ -100,7 +100,7 @@ class CronUtil: commandT = 'chmod 755 %s' % (cronParent) ProcessUtilities.executioner(commandT, 'root') - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'chmod 755 /var/spool/cron/crontabs' ProcessUtilities.outputExecutioner(command) @@ -109,7 +109,7 @@ class CronUtil: commandT = 'chmod 700 %s' % (cronParent) ProcessUtilities.executioner(commandT, 'root') - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'chmod 1730 /var/spool/cron/crontabs' ProcessUtilities.outputExecutioner(command) diff --git a/plogical/csf.py b/plogical/csf.py index ef1999224..cb4a1d9f7 100755 --- a/plogical/csf.py +++ b/plogical/csf.py @@ -70,10 +70,10 @@ class CSF(multi.Thread): ProcessUtilities.normalExecutioner(command) # install required packages for CSF perl and /usr/bin/host - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'yum install bind-utils net-tools perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph ipset -y' ProcessUtilities.normalExecutioner(command) - elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'apt-get install dnsutils libwww-perl liblwp-protocol-https-perl libgd-graph-perl net-tools ipset -y' ProcessUtilities.normalExecutioner(command) command = 'ln -s /bin/systemctl /usr/bin/systemctl' @@ -309,7 +309,7 @@ class CSF(multi.Thread): ## # Some Ubuntu initial configurations - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: data = open('/etc/csf/csf.conf', 'r').readlines() writeToConf = open('/etc/csf/csf.conf', 'w') diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index 51fb3f8b2..0ef13bd13 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -121,7 +121,6 @@ class DNS: subDomain = extractDomain.subdomain if len(subDomain) == 0: - if Domains.objects.filter(name=topLevelDomain).count() == 0: try: pdns = PDNSStatus.objects.get(pk=1) @@ -440,13 +439,67 @@ class DNS: DNS.createDNSRecord(zone, actualSubDomain, "A", ipAddress, 0, 3600) + ## Mail Record + + DNS.createDNSRecord(zone, 'mail.' + actualSubDomain, "A", ipAddress, 0, 3600) + # CNAME Records. cNameValue = "www." + actualSubDomain DNS.createDNSRecord(zone, cNameValue, "CNAME", actualSubDomain, 0, 3600) - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + ## MX Records + + mxValue = "mail." + actualSubDomain + + record = Records(domainOwner=zone, + domain_id=zone.id, + name=actualSubDomain, + type="MX", + content=mxValue, + ttl=3600, + prio="10", + disabled=0, + auth=1) + record.save() + + ## TXT Records + + record = Records(domainOwner=zone, + domain_id=zone.id, + name=actualSubDomain, + type="TXT", + content="v=spf1 a mx ip4:" + ipAddress + " ~all", + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() + + record = Records(domainOwner=zone, + domain_id=zone.id, + name="_dmarc." + actualSubDomain, + type="TXT", + content="v=DMARC1; p=none", + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() + + record = Records(domainOwner=zone, + domain_id=zone.id, + name="_domainkey." + actualSubDomain, + type="TXT", + content="t=y; o=~;", + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) @@ -465,6 +518,7 @@ class DNS: extractDomain = tldextract.extract(domain) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix + subDomain = extractDomain.subdomain zone = Domains.objects.get(name=topLevelDomain) @@ -474,18 +528,33 @@ class DNS: leftIndex = output.index('(') + 2 rightIndex = output.rindex(')') - 1 - record = Records(domainOwner=zone, - domain_id=zone.id, - name="default._domainkey." + topLevelDomain, - type="TXT", - content=output[leftIndex:rightIndex], - ttl=3600, - prio=0, - disabled=0, - auth=1) - record.save() + if Records.objects.filter(domainOwner=zone, name="default._domainkey." + topLevelDomain).count() == 0: - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + record = Records(domainOwner=zone, + domain_id=zone.id, + name="default._domainkey." + topLevelDomain, + type="TXT", + content=output[leftIndex:rightIndex], + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() + + if len(subDomain) > 0: + if Records.objects.filter(domainOwner=zone, name="default._domainkey." + domain).count() == 0: + record = Records(domainOwner=zone, + domain_id=zone.id, + name="default._domainkey." + domain, + type="TXT", + content=output[leftIndex:rightIndex], + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = ' systemctl restart pdns' ProcessUtilities.executioner(command) @@ -566,7 +635,7 @@ class DNS: auth=1) record.save() - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) @@ -585,7 +654,7 @@ class DNS: auth=1) record.save() - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) return @@ -602,7 +671,7 @@ class DNS: auth=1) record.save() - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) return @@ -618,7 +687,7 @@ class DNS: disabled=0, auth=1) record.save() - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) diff --git a/plogical/firewallUtilities.py b/plogical/firewallUtilities.py index d3f07fb63..db945d2f6 100755 --- a/plogical/firewallUtilities.py +++ b/plogical/firewallUtilities.py @@ -15,9 +15,9 @@ class FirewallUtilities: @staticmethod def resFailed(res): - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu and res != 0: + if (ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20) and res != 0: return True - elif ProcessUtilities.decideDistro() == ProcessUtilities.centos and res == 1: + elif (ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8) and res == 1: return True return False diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 485206df0..812b5317a 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -214,41 +214,39 @@ class mailUtilities: import tldextract - #extractDomain = tldextract.extract(virtualHostName) - #virtualHostName = extractDomain.domain + '.' + extractDomain.suffix + actualDomain = virtualHostName + extractDomain = tldextract.extract(virtualHostName) + virtualHostName = extractDomain.domain + '.' + extractDomain.suffix - if os.path.exists("/etc/opendkim/keys/" + virtualHostName + "/default.txt"): - return 1, "None" + if not os.path.exists("/etc/opendkim/keys/" + virtualHostName + "/default.txt"): + path = '/etc/opendkim/keys/%s' % (virtualHostName) + command = 'mkdir %s' % (path) + ProcessUtilities.normalExecutioner(command) + ## Generate keys - path = '/etc/opendkim/keys/%s' % (virtualHostName) - command = 'mkdir %s' % (path) - ProcessUtilities.normalExecutioner(command) + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + command = "/usr/sbin/opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName) + else: + command = "opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % ( + virtualHostName, virtualHostName) + ProcessUtilities.normalExecutioner(command) + ## Fix permissions - ## Generate keys + command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName + ProcessUtilities.normalExecutioner(command) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - command = "/usr/sbin/opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName) - else: - command = "opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % ( - virtualHostName, virtualHostName) - ProcessUtilities.normalExecutioner(command) - ## Fix permissions + command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private" + ProcessUtilities.normalExecutioner(command) - command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName - ProcessUtilities.normalExecutioner(command) - - command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private" - ProcessUtilities.normalExecutioner(command) - - command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt" - ProcessUtilities.normalExecutioner(command) + command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt" + ProcessUtilities.normalExecutioner(command) ## Edit key file keyTable = "/etc/opendkim/KeyTable" - configToWrite = "default._domainkey." + virtualHostName + " " + virtualHostName + ":default:/etc/opendkim/keys/" + virtualHostName + "/default.private\n" + configToWrite = "default._domainkey." + actualDomain + " " + actualDomain + ":default:/etc/opendkim/keys/" + virtualHostName + "/default.private\n" writeToFile = open(keyTable, 'a') writeToFile.write(configToWrite) @@ -257,7 +255,7 @@ class mailUtilities: ## Edit signing table signingTable = "/etc/opendkim/SigningTable" - configToWrite = "*@" + virtualHostName + " default._domainkey." + virtualHostName + "\n" + configToWrite = "*@" + actualDomain + " default._domainkey." + actualDomain + "\n" writeToFile = open(signingTable, 'a') writeToFile.write(configToWrite) @@ -266,7 +264,7 @@ class mailUtilities: ## Trusted hosts trustedHosts = "/etc/opendkim/TrustedHosts" - configToWrite = virtualHostName + "\n" + configToWrite = actualDomain + "\n" writeToFile = open(trustedHosts, 'a') writeToFile.write(configToWrite) @@ -451,7 +449,7 @@ milter_default_action = accept def installSpamAssassin(install, SpamAssassin): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo yum install spamassassin -y' else: command = 'sudo apt-get install spamassassin spamc -y' @@ -502,7 +500,7 @@ milter_default_action = accept def configureSpamAssassin(): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: confFile = "/etc/mail/spamassassin/local.cf" confData = open(confFile).readlines() diff --git a/plogical/modSec.py b/plogical/modSec.py index 6c4e86c6f..e242d4035 100755 --- a/plogical/modSec.py +++ b/plogical/modSec.py @@ -24,7 +24,7 @@ class modSec: mailUtilities.checkHome() - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo yum install ols-modsecurity -y' else: command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install ols-modsecurity -y' diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index fa06f8fac..bb17f36e7 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -413,7 +413,7 @@ password=%s def applyMySQLChanges(data): try: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo mv /etc/my.cnf /etc/my.cnf.bak' else: command = 'sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak' @@ -430,7 +430,7 @@ password=%s writeToFile.close() ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo mv ' + tempPath + ' /etc/my.cnf' else: command = 'sudo mv ' + tempPath + ' /etc/mysql/my.cnf' @@ -440,7 +440,7 @@ password=%s return 1, None except BaseException as msg: - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf' else: command = 'sudo mv /etc/mysql/my.cnf.bak /etc/mysql//my.cnf' diff --git a/plogical/phpUtilities.py b/plogical/phpUtilities.py index e1518a7d9..8e69569ef 100755 --- a/plogical/phpUtilities.py +++ b/plogical/phpUtilities.py @@ -20,7 +20,7 @@ class phpUtilities: mailUtilities.checkHome() - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo yum install ' + extension + ' -y' else: command = 'sudo apt-get install ' + extension + ' -y' @@ -54,7 +54,7 @@ class phpUtilities: mailUtilities.checkHome() - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'sudo rpm --nodeps -e ' + extension + ' -v' else: command = 'sudo apt-get remove -y ' + extension @@ -103,7 +103,7 @@ class phpUtilities: command = 'touch %s' % (serverLevelPHPRestart) ProcessUtilities.executioner(command) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini" else: initial = phpVers[3] diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index e3f276ada..fdd5e6990 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -16,6 +16,7 @@ class ProcessUtilities(multi.Thread): centos = 1 cent8 = 2 ubuntu = 0 + ubuntu20 = 3 server_address = '/usr/local/lscpd/admin/comm.sock' token = "unset" @@ -139,6 +140,8 @@ class ProcessUtilities(multi.Thread): distroPath = '/etc/lsb-release' if os.path.exists(distroPath): + if open(distroPath, 'r').read().find('20.04') > -1: + return ProcessUtilities.ubuntu20 return ProcessUtilities.ubuntu else: if open('/etc/redhat-release', 'r').read().find('CentOS Linux release 8') > -1: @@ -190,8 +193,7 @@ class ProcessUtilities(multi.Thread): sock = ret[0] if user == None: - - if command.find('export') > -1 and ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if command.find('export') > -1: pass elif command.find('sudo') == -1: command = 'sudo %s' % (command) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index f200bd53b..d88edd44f 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -1233,6 +1233,37 @@ class Upgrade: CONSTRAINT `websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_websites` (`id`) )""" + try: + cursor.execute(query) + except: + pass + + qeury = """CREATE TABLE `websiteFunctions_backupjob` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `logFile` varchar(1000) NOT NULL, + `ipAddress` varchar(50) NOT NULL, + `port` varchar(15) NOT NULL, + `jobFailedSites` int(11) NOT NULL, + `jobSuccessSites` int(11) NOT NULL, + `location` int(11) NOT NULL, + PRIMARY KEY (`id`) +)""" + try: + cursor.execute(query) + except: + pass + + + query = """CREATE TABLE `websiteFunctions_backupjoblogs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `message` longtext NOT NULL, + `owner_id` int(11) NOT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu` (`owner_id`), + CONSTRAINT `websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_backupjob` (`id`) +)""" + try: cursor.execute(query) except: diff --git a/plogical/vhost.py b/plogical/vhost.py index 8d8eef190..6e353096d 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -91,7 +91,7 @@ class vhost: try: os.makedirs(pathHTML) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -112,7 +112,7 @@ class vhost: try: os.makedirs(pathLogs) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' @@ -403,7 +403,7 @@ class vhost: ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'userdel -r -f %s' % (externalApp) else: command = 'deluser %s' % (externalApp) @@ -468,7 +468,7 @@ class vhost: ## - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'userdel -r -f %s' % (externalApp) else: command = 'deluser %s' % (externalApp) @@ -848,7 +848,7 @@ class vhost: try: os.makedirs(path) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: groupName = 'nobody' else: groupName = 'nogroup' diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index 7bbfcb306..d750f5e3c 100755 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -55,6 +55,65 @@ class virtualHostUtilities: cyberPanel = "/usr/local/CyberCP" redisConf = '/usr/local/lsws/conf/dvhost_redis.conf' + @staticmethod + def setupAutoDiscover(mailDomain, tempStatusPath, virtualHostName, admin): + + if mailDomain: + + logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating mail child domain..,80') + childDomain = 'mail.%s' % (virtualHostName) + childPath = '/home/%s/public_html/%s' % (virtualHostName, childDomain) + + virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0, + admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999))) + + ## update dovecot conf to enable auto-discover + + dovecotPath = '/etc/dovecot/dovecot.conf' + + if os.path.exists(dovecotPath): + dovecotContent = open(dovecotPath, 'r').read() + + if dovecotContent.find(childDomain) == -1: + content = """\nlocal_name %s { + ssl_cert = + + +
    + +
    +

    {% trans "Package Manager" %}

    +

    {% trans "On this page you can manage your system packages. On backend system available package manager is used (apt/yum)." %}

    +
    + +
    +
    +
    +
    + +
    + +
    +
    + Total Upgradeable Packages: {$ totalPackages $} + Fetched Packages: {$ fetchedPackages $} + + Update All + +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    {% trans "Package" %}{% trans "Version" %}{% trans "Upgrade" %}{% trans "Lock" %}{% trans "Actions" %}
    + + + + Details + + Update + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + Total Packages: {$ totalPackages $} + Fetched Packages: {$ fetchedPackages $} +
    + +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +
    {% trans "Package" %}{% trans "Version" %}{% trans "Upgrade" %}{% trans "Lock" %}{% trans "Actions" %}
    + + + + Details + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + Total Packages: {$ totalPackages $} + Fetched Packages: {$ fetchedPackages $} + + + +
    + +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + +
    {% trans "Package" %}{% trans "Version" %}{% trans "Lock" %}{% trans "Actions" %}
    + + + + Details + + Update + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + + + + + + + + +{% endblock %} diff --git a/serverStatus/urls.py b/serverStatus/urls.py index cdd1224e0..86fd8638d 100755 --- a/serverStatus/urls.py +++ b/serverStatus/urls.py @@ -18,5 +18,10 @@ urlpatterns = [ url(r'^topProcesses$', views.topProcesses, name='topProcesses'), url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'), url(r'^killProcess$', views.killProcess, name='killProcess'), + url(r'^packageManager$', views.packageManager, name='packageManager'), + url(r'^fetchPackages$', views.fetchPackages, name='fetchPackages'), + url(r'^fetchPackageDetails$', views.fetchPackageDetails, name='fetchPackageDetails'), + url(r'^updatePackage$', views.updatePackage, name='updatePackage'), + url(r'^lockStatus$', views.lockStatus, name='lockStatus'), ] \ No newline at end of file diff --git a/serverStatus/views.py b/serverStatus/views.py index dae87051e..1ec698044 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -6,7 +6,7 @@ from django.http import HttpResponse import plogical.CyberCPLogFileWriter as logging from loginSystem.views import loadLoginPage import json -import subprocess +import subprocess, shlex import psutil import socket from plogical.acl import ACLManager @@ -93,7 +93,6 @@ def litespeedStatus(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) - def stopOrRestartLitespeed(request): try: userID = request.session['userID'] @@ -127,7 +126,6 @@ def stopOrRestartLitespeed(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]") return HttpResponse("Not Logged in as admin") - def cyberCPMainLogFile(request): try: userID = request.session['userID'] @@ -145,7 +143,6 @@ def cyberCPMainLogFile(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]") return redirect(loadLoginPage) - def getFurtherDataFromLogFile(request): try: userID = request.session['userID'] @@ -196,7 +193,6 @@ def services(request): except KeyError: return redirect(loadLoginPage) - def servicesStatus(request): try: userID = request.session['userID'] @@ -291,7 +287,6 @@ def servicesStatus(request): except KeyError: return redirect(loadLoginPage) - def servicesAction(request): try: userID = request.session['userID'] @@ -344,7 +339,6 @@ def servicesAction(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - def switchTOLSWS(request): try: userID = request.session['userID'] @@ -378,7 +372,6 @@ def switchTOLSWS(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - def switchTOLSWSStatus(request): try: @@ -505,7 +498,6 @@ def topProcesses(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) - def topProcessesStatus(request): try: userID = request.session['userID'] @@ -580,17 +572,57 @@ def topProcessesStatus(request): data['Softirqs'] = loadNow[13] + '%' ## Memory - data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB' - data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB' - data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB' - data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB' + + logging.CyberCPLogFileWriter.writeToFile(str(memory)) + + if memory[3].find('+') > -1: + memoryFinal = memory[3].split('+')[0] + else: + memoryFinal = memory[3] + + data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB' + + + ## + + if memory[5].find('free') > -1: + data['freeMemory'] = str(int(float(memory[4]) / 1024)) + 'MB' + else: + data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB' + + + ## + + if memory[7].find('used') > -1: + data['usedMemory'] = str(int(float(memory[6]) / 1024)) + 'MB' + else: + data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB' + + + try: + if memory[9].find('buff') > -1: + data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB' + else: + data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB' + except: + logging.CyberCPLogFileWriter.writeToFile(memory[8]) + data['buffCache'] = str(int(float(memory[8].split('+')[0]) / 1024)) + 'MB' + ## Swap + logging.CyberCPLogFileWriter.writeToFile(str(swap)) + + data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB' data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB' data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB' - data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB' + + if swap[8].find('+') > -1: + finalBuffCache = swap[8].split('+')[0] + data['swapBuffCache'] = str(int(float(finalBuffCache) / 1024)) + 'MB' + else: + data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB' ## Processes @@ -628,7 +660,6 @@ def topProcessesStatus(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - def killProcess(request): try: userID = request.session['userID'] @@ -656,4 +687,416 @@ def killProcess(request): except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) - return HttpResponse(final_json) \ No newline at end of file + return HttpResponse(final_json) + +def packageManager(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + templateName = "serverStatus/packageManager.html" + proc = httpProc(request, templateName) + return proc.renderPre() + + except KeyError as msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[packageManager]") + return redirect(loadLoginPage) + +def fetchPackages(request): + try: + + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + data = json.loads(request.body) + page = int(str(data['page']).rstrip('\n')) + recordsToShow = int(data['recordsToShow']) + type = data['type'] + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: + + command = 'apt-mark showhold' + locked = ProcessUtilities.outputExecutioner(command).split('\n') + + if type == 'CyberPanel': + + command = 'cat /usr/local/CyberCP/AllCPUbuntu.json' + packages = json.loads(ProcessUtilities.outputExecutioner(command)) + + else: + command = 'apt list --installed' + packages = ProcessUtilities.outputExecutioner(command).split('\n') + packages = packages[4:] + + upgradePackages = [] + + if type == 'upgrade': + for pack in packages: + if pack.find('upgradable') > -1: + upgradePackages.append(pack) + + packages = upgradePackages + + + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + + ### Check Package Lock status + + if os.path.exists('/etc/yum.conf'): + yumConf = '/etc/yum.conf' + elif os.path.exists('/etc/yum/yum.conf'): + yumConf = '/etc/yum/yum.conf' + + yumConfData = open(yumConf, 'r').read() + locked = [] + + if yumConfData.find('exclude') > -1: + + data = open(yumConf, 'r').readlines() + + for items in data: + if items.find('exclude') > -1: + locked = items.split('=')[1].rstrip('\n').split(' ') + break + + if type == 'installed': + + #### Cater for packages that need updates. + + startForUpdate = 1 + + command = 'yum check-update' + updates = ProcessUtilities.outputExecutioner(command).split('\n') + + for items in updates: + if items == '': + updates = updates[startForUpdate:] + break + else: + startForUpdate = startForUpdate + 1 + + ## make list of packages that need update + + updateNeeded = [] + for items in updates: + updateNeeded.append(items.split(' ')[0]) + + ### + + command = 'yum list installed' + packages = ProcessUtilities.outputExecutioner(command).split('\n') + + startFrom = 1 + + for items in packages: + if items.find('Installed Packages') > -1: + packages = packages[startFrom:] + break + else: + startFrom = startFrom + 1 + elif type == 'upgrade': + #### Cater for packages that need updates. + + startForUpdate = 1 + + command = 'yum check-update' + packages = ProcessUtilities.outputExecutioner(command).split('\n') + + for items in packages: + if items == '': + packages = packages[startForUpdate:-1] + break + else: + startForUpdate = startForUpdate + 1 + elif type == 'CyberPanel': + command = 'cat /usr/local/CyberCP/CPCent7repo.json' + packages = json.loads(ProcessUtilities.outputExecutioner(command)) + + ## make list of packages that need update + + + #if os.path.exists(ProcessUtilities.debugPath): + # logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages))) + + from s3Backups.s3Backups import S3Backups + + pagination = S3Backups.getPagination(len(packages), recordsToShow) + endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow) + finalPackages = packages[finalPageNumber:endPageNumber] + + json_data = "[" + checker = 0 + counter = 0 + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages))) + + import re + for items in finalPackages: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: + try: + if type == 'CyberPanel': + + packageName = items['Package'].split('/')[0] + + if packageName in locked: + lock = 1 + else: + lock = 0 + + dic = {'package': packageName, + 'version': items['Version'], 'lock': lock} + + counter = counter + 1 + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + else: + nowSplitted = items.split('now') + + upgrade = 'Not Needed' + + if nowSplitted[1].split(' ')[3].find('upgradable') > -1: + current = nowSplitted[1].split(' ') + upgrade = '%s %s %s' % (current[3], current[4], current[5]) + + if nowSplitted[0].split('/')[0] in locked: + lock = 1 + else: + lock = 0 + + dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock} + + counter = counter + 1 + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg))) + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + try: + if type == 'installed' or type == 'upgrade': + + ### + + details = items.split(' ') + details = [a for a in details if a != ''] + + if type == 'installed': + if details[0] in updateNeeded: + upgrade = 'Upgrade available' + else: + upgrade = 'Not needed.' + else: + upgrade = 'Upgrade available' + + + if details[0].split('.')[0] in locked: + lock = 1 + else: + lock = 0 + + dic = {'package': details[0], + 'version': details[1], + 'upgrade': upgrade, 'lock': lock} + + counter = counter + 1 + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + elif type == 'CyberPanel': + + packageName = items['Package'] + + if packageName.split('.')[0] in locked: + lock = 1 + else: + lock = 0 + + dic = {'package': packageName, + 'version': items['Version'], 'lock': lock} + + counter = counter + 1 + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + + except BaseException as msg: + print(str(msg)) + logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:839]' % (str(msg))) + + json_data = json_data + ']' + + data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + +def fetchPackageDetails(request): + try: + + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + data = json.loads(request.body) + package = data['package'] + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: + command = 'apt-cache show %s' % (package) + packageDetails = ProcessUtilities.outputExecutioner(command) + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + command = 'yum info %s' % (package) + packageDetails = ProcessUtilities.outputExecutioner(command) + + data_ret = {'status': 1, 'packageDetails': packageDetails} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + +def updatePackage(request): + try: + + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + data = json.loads(request.body) + package = data['package'] + + from serverStatus.serverStatusUtil import ServerStatusUtil + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + 'Starting package(s) upgrade..', + 1) + + extraArgs = {} + extraArgs['package'] = package + + from plogical.applicationInstaller import ApplicationInstaller + + background = ApplicationInstaller('updatePackage', extraArgs) + background.start() + + time.sleep(2) + + data_ret = {'status': 1} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + +def lockStatus(request): + try: + + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadError() + + data = json.loads(request.body) + package = data['package'] + type = data['type'] + + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: + + if type == 0: + command = 'apt-mark unhold %s' % (package) + ProcessUtilities.executioner(command) + else: + command = 'apt-mark hold %s' % (package) + ProcessUtilities.executioner(command) + + elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + + package = package.split('.')[0] + + if os.path.exists('/etc/yum.conf'): + yumConf = '/etc/yum.conf' + elif os.path.exists('/etc/yum/yum.conf'): + yumConf = '/etc/yum/yum.conf' + + yumConfData = open(yumConf, 'r').read() + data = open(yumConf, 'r').readlines() + + + if type == 0: + writeToFile = open(yumConf, 'w') + + for items in data: + if items.find('exclude') > -1: + writeToFile.writelines(items.replace(package, '')) + else: + writeToFile.writelines(items) + + writeToFile.close() + else: + + if yumConfData.find('exclude') == -1: + + writeToFile = open(yumConf, 'a') + writeToFile.writelines('exclude=%s\n' % (package)) + writeToFile.close() + + else: + writeToFile = open(yumConf, 'w') + + for items in data: + if items.find('exclude') > -1: + excludeLine = items.strip('\n') + writeToFile.writelines('%s %s\n' % (excludeLine, package)) + else: + writeToFile.writelines(items) + + writeToFile.close() + + data_ret = {'status': 1} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) \ No newline at end of file diff --git a/static/backup/backup.js b/static/backup/backup.js index 9c158422b..59c654f87 100644 --- a/static/backup/backup.js +++ b/static/backup/backup.js @@ -416,7 +416,7 @@ app.controller('restoreWebsiteControl', function ($scope, $http, $timeout) { }); -//*** Resotre site ends here ***/// +//*** Restore site ends here ***/// ///** Backup Destination ***// @@ -448,6 +448,7 @@ app.controller('backupDestinations', function ($scope, $http, $timeout) { var data = { IPAddress: $scope.IPAddress, password: $scope.password, + user: $scope.user, backupSSHPort: $scope.backupSSHPort, }; @@ -1346,6 +1347,7 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) { $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); function ListInitialDatas(response) { + $scope.backupProcessStarted = true; if (response.data.remoteTransferStatus === 1) { @@ -1539,4 +1541,68 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) { }); -///** Backup site ends **/// \ No newline at end of file +///** Backup site ends **/// + + +//*** Remote Backup site ****// +app.controller('backupLogsScheduled', function ($scope, $http, $timeout) { + + $scope.cyberpanelLoading = true; + $scope.logDetails = true; + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.fetchLogs = function () { + + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + logFile: $scope.logFile, + recordsToShow: $scope.recordsToShow, + page: $scope.currentPage + }; + + dataurl = "/backup/fetchLogs"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.logDetails = false; + $scope.logs = JSON.parse(response.data.logs); + $scope.pagination = response.data.pagination; + $scope.jobSuccessSites = response.data.jobSuccessSites; + $scope.jobFailedSites = response.data.jobFailedSites; + $scope.location = response.data.location; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + +}); + +///** Backup site ends **/// diff --git a/static/databases/databases.js b/static/databases/databases.js old mode 100755 new mode 100644 index e13d25977..d1e91175b --- a/static/databases/databases.js +++ b/static/databases/databases.js @@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.dbPassword = randomPassword(12); + $scope.dbPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.dbPassword = randomPassword(12); + $scope.dbPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -493,4 +493,4 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) { } setupPHPMYAdminSession(); -}); \ No newline at end of file +}); diff --git a/static/filemanager/js/fileManager.js b/static/filemanager/js/fileManager.js index 725224dbb..19e175118 100644 --- a/static/filemanager/js/fileManager.js +++ b/static/filemanager/js/fileManager.js @@ -1479,7 +1479,6 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, // Download files $scope.downloadFile = function () { - url = "/filemanager/downloadFile"; var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0]; window.location.href = url + '?domainName=' + domainName + '&fileToDownload=' + downloadURL; diff --git a/static/firewall/firewall.js b/static/firewall/firewall.js index a0acd1f53..eaa372adb 100644 --- a/static/firewall/firewall.js +++ b/static/firewall/firewall.js @@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) { text: 'Could not connect to server, please refresh this page', type: 'error' }); - - } } diff --git a/static/ftp/ftp.js b/static/ftp/ftp.js index 679a8b5f7..a80377e6b 100644 --- a/static/ftp/ftp.js +++ b/static/ftp/ftp.js @@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.ftpPassword = randomPassword(12); + $scope.ftpPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -451,11 +451,11 @@ app.controller('listFTPAccounts', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.ftpPassword = randomPassword(12); + $scope.ftpPassword = randomPassword(16); }; $scope.usePassword = function () { $scope.generatedPasswordView = true; }; -}); \ No newline at end of file +}); diff --git a/static/mailServer/mailServer.js b/static/mailServer/mailServer.js index f50b36a45..f46bb4d4a 100644 --- a/static/mailServer/mailServer.js +++ b/static/mailServer/mailServer.js @@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.emailPassword = randomPassword(12); + $scope.emailPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.emailPassword = randomPassword(12); + $scope.emailPassword = randomPassword(16); }; $scope.usePassword = function () { @@ -1124,6 +1124,7 @@ app.controller('listEmails', function ($scope, $http) { $scope.cyberpanelLoading = true; $scope.emailsAccounts = true; + $scope.mailConfigured = 1; $scope.populateCurrentRecords = function () { $scope.cyberpanelLoading = false; @@ -1151,6 +1152,9 @@ app.controller('listEmails', function ($scope, $http) { if (response.data.status === 1) { $scope.emailsAccounts = false; $scope.records = JSON.parse(response.data.data); + $scope.mailConfigured = response.data.mailConfigured; + $scope.serverHostname = response.data.serverHostname; + new PNotify({ title: 'Success!', text: 'Emails Successfully Fetched.', @@ -1229,6 +1233,55 @@ app.controller('listEmails', function ($scope, $http) { } + }; + + $scope.fixMailSSL = function (email) { + + $scope.cyberpanelLoading = false; + + var url = "/email/fixMailSSL"; + + var data = { + selectedDomain: $scope.selectedDomain, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + if (response.data.status === 1) { + $scope.populateCurrentRecords(); + new PNotify({ + title: 'Success!', + text: 'Configurations applied successfully.', + type: 'success' + }); + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + new PNotify({ + title: 'Error!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + }; $scope.changePasswordInitial = function (email) { @@ -1291,4 +1344,4 @@ app.controller('listEmails', function ($scope, $http) { }); -/* Java script code for List Emails Ends here */ \ No newline at end of file +/* Java script code for List Emails Ends here */ diff --git a/static/serverStatus/serverStatus.js b/static/serverStatus/serverStatus.js index db70955a0..8a89159d6 100644 --- a/static/serverStatus/serverStatus.js +++ b/static/serverStatus/serverStatus.js @@ -3,7 +3,6 @@ */ - /* Java script code to start/stop litespeed */ app.controller('litespeedStatus', function ($scope, $http) { @@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) { $scope.actionResultBad = true; $scope.serverStatusCouldNotConnect = true; - } - else { + } else { $scope.restartorStopLoading = true; $scope.actionResult = true; @@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) { $scope.actionResultBad = true; $scope.serverStatusCouldNotConnect = true; - } - else { + } else { $scope.restartorStopLoading = true; $scope.actionResult = true; @@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) { }); $scope.lsSerial = response.data.lsSerial; $scope.lsexpiration = response.data.lsexpiration; - } - else { + } else { $scope.cpLoading = true; new PNotify({ title: 'Operation Failed!', @@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) { text: 'License successfully Updated', type: 'success' }); - } - else { + } else { $scope.cpLoading = true; new PNotify({ title: 'Operation Failed!', @@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) { $scope.logsData = response.data.logsdata; - } - else { + } else { $scope.logFileLoading = true; $scope.logsFeteched = true; @@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) { $scope.logsData = response.data.logsdata; - } - else { + } else { $scope.logFileLoading = true; $scope.logsFeteched = true; @@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.olsStart = false; $scope.olsStop = true; $scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB"; - } - else { + } else { $scope.olsStatus = "Stopped"; $scope.olsStats = false; $scope.olsStart = true; @@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.dockerStatus = "Running"; $scope.dockerStart = false; $scope.dockerStop = true; - } - else { + } else { $scope.dockerStatus = "Stopped"; $scope.dockerStart = true; $scope.dockerStop = false; @@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.sqlStart = false; $scope.sqlStop = true; $scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB"; - } - else { + } else { $scope.sqlStatus = "Stopped"; $scope.sqlStats = false; $scope.sqlStart = true; @@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.dnsStart = false; $scope.dnsStop = true; $scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB"; - } - else { + } else { $scope.dnsStatus = "Stopped"; $scope.dnsStats = false; $scope.dnsStart = true; @@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.ftpStart = false; $scope.ftpStop = true; $scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB"; - } - else { + } else { $scope.ftpStatus = "Stopped"; $scope.ftpStats = false; $scope.ftpStart = true; @@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) { } } + getServiceStatus(); $scope.serviceAction = function (serviceName, action) { @@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) { $scope.actionLoader = false; $scope.btnDisable = false; }, 3000); - } - else { + } else { setTimeout(function () { getServiceStatus(); $scope.ActionSuccessfull = false; @@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) { if (response.data.status === 1) { $scope.installBoxGen = false; getRequestStatus(); - } - else { + } else { new PNotify({ title: 'Operation Failed!', text: response.data.error_message, @@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) { if (response.data.abort === 0) { $scope.requestData = response.data.requestStatus; $timeout(getRequestStatus, 1000); - } - else { + } else { // Notifications $scope.cyberPanelLoading = true; $timeout.cancel(); @@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) { $scope.zombieProcesses = response.data.zombieProcesses; $timeout($scope.topProcessesStatus, 3000); - } - else { + } else { new PNotify({ title: 'Operation Failed!', text: response.data.error_message, @@ -771,8 +756,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) { text: 'Process successfully killed.', type: 'success' }); - } - else { + } else { new PNotify({ title: 'Operation Failed!', text: response.data.error_message, @@ -793,4 +777,236 @@ app.controller('topProcesses', function ($scope, $http, $timeout) { }; +}); + +/// + + +app.controller('listOSPackages', function ($scope, $http, $timeout) { + + $scope.cyberpanelLoading = true; + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + var globalType; + + $scope.fetchPackages = function (type = 'installed') { + $scope.cyberpanelLoading = false; + globalType = type; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + page: $scope.currentPage, + recordsToShow: $scope.recordsToShow, + type: type + }; + + dataurl = "/serverstatus/fetchPackages"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.allPackages = JSON.parse(response.data.packages); + $scope.pagination = response.data.pagination; + $scope.fetchedPackages = response.data.fetchedPackages; + $scope.totalPackages = response.data.totalPackages; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + $scope.fetchPackages('upgrade'); + + $scope.fetchPackageDetails = function (packageFetch) { + $scope.cyberpanelLoading = false; + $scope.package = packageFetch; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + package: packageFetch + }; + + dataurl = "/serverstatus/fetchPackageDetails"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.packageDetails = response.data.packageDetails; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.updatePackage = function (packageToUpgrade = 'all') { + $scope.cyberpanelLoading = false; + $scope.package = packageToUpgrade; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + package: packageToUpgrade + }; + + dataurl = "/serverstatus/updatePackage"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + getRequestStatus(); + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + function getRequestStatus() { + + $scope.cyberpanelLoading = false; + + url = "/serverstatus/switchTOLSWSStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.abort === 0) { + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $timeout.cancel(); + $scope.cyberpanelLoading = true; + $scope.requestData = response.data.requestStatus; + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + } + + $scope.lockStatus = function (lockPackage, type) { + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + package: lockPackage, + type: type, + }; + + dataurl = "/serverstatus/lockStatus"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Status updated.', + type: 'success' + }); + $scope.fetchPackages(globalType); + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + }); \ No newline at end of file diff --git a/static/userManagment/userManagment.js b/static/userManagment/userManagment.js index 39cbf5d6d..73eaed9a5 100644 --- a/static/userManagment/userManagment.js +++ b/static/userManagment/userManagment.js @@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.password = randomPassword(12); + $scope.password = randomPassword(16); }; $scope.usePassword = function () { @@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.password = randomPassword(12); + $scope.password = randomPassword(16); }; $scope.usePassword = function () { @@ -1744,4 +1744,4 @@ app.controller('listTableUsers', function ($scope, $http) { }); -/* Java script code to list table users */ \ No newline at end of file +/* Java script code to list table users */ diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index 58c302260..f39798297 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -5836,7 +5836,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { $scope.autoCommitCurrent = response.data.autoCommitCurrent; $scope.autoPushCurrent = response.data.autoPushCurrent; $scope.emailLogsCurrent = response.data.emailLogsCurrent; - $scope.currentCommands = response.data.commands; + document.getElementById("currentCommands").value = response.data.commands; $scope.webhookCommandCurrent = response.data.webhookCommandCurrent; } else { $scope.gitTracking = false; @@ -6677,17 +6677,40 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { url = "/websites/saveGitConfigurations"; - var data = { domain: $("#domain").text(), folder: $scope.folder, autoCommit: $scope.autoCommit, autoPush: $scope.autoPush, emailLogs: $scope.emailLogs, - commands: $scope.commands, + commands: document.getElementById("currentCommands").value, webhookCommand: $scope.webhookCommand }; + if ($scope.autoCommit === undefined){ + $scope.autoCommitCurrent = 'Never'; + }else{ + $scope.autoCommitCurrent = $scope.autoCommit; + } + + if ($scope.autoPush === undefined){ + $scope.autoPushCurrent = 'Never'; + }else{ + $scope.autoPushCurrent = $scope.autoPush; + } + + if ($scope.emailLogs === undefined){ + $scope.emailLogsCurrent = false; + }else{ + $scope.emailLogsCurrent = $scope.emailLogs; + } + + if ($scope.webhookCommand === undefined){ + $scope.webhookCommandCurrent = false; + }else{ + $scope.webhookCommandCurrent = $scope.webhookCommand; + } + var config = { headers: { 'X-CSRFToken': getCookie('csrftoken') @@ -6782,4 +6805,5 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { }; }); + /* Java script code to git tracking ends here */ diff --git a/userManagment/static/userManagment/userManagment.js b/userManagment/static/userManagment/userManagment.js index 39cbf5d6d..73eaed9a5 100755 --- a/userManagment/static/userManagment/userManagment.js +++ b/userManagment/static/userManagment/userManagment.js @@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.password = randomPassword(12); + $scope.password = randomPassword(16); }; $scope.usePassword = function () { @@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) { $scope.generatePassword = function () { $scope.generatedPasswordView = false; - $scope.password = randomPassword(12); + $scope.password = randomPassword(16); }; $scope.usePassword = function () { @@ -1744,4 +1744,4 @@ app.controller('listTableUsers', function ($scope, $http) { }); -/* Java script code to list table users */ \ No newline at end of file +/* Java script code to list table users */ diff --git a/version.txt b/version.txt index ca1e53142..c085faed0 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -{"version":"2.0","build":0} \ No newline at end of file +{"version":"2.0","build":1} \ No newline at end of file diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index dd0351fc0..df6979ca6 100644 --- a/websiteFunctions/StagingSetup.py +++ b/websiteFunctions/StagingSetup.py @@ -36,12 +36,17 @@ class StagingSetup(multi.Thread): website = Websites.objects.get(domain=masterDomain) + masterPath = '/home/%s/public_html' % (masterDomain) + + command = 'chmod 755 %s' % (masterPath) + ProcessUtilities.executioner(command) + ## Creating Child Domain path = "/home/" + masterDomain + "/public_html/" + domain logging.statusWriter(tempStatusPath, 'Creating domain for staging environment..,5') - phpSelection = 'PHP 7.1' + phpSelection = 'PHP 7.2' execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \ @@ -57,18 +62,37 @@ class StagingSetup(multi.Thread): if data.find('[200]') > -1: pass else: - logging.statusWriter(tempStatusPath, 'Failed to create child-domain for staging enviroment. [404]') + logging.statusWriter(tempStatusPath, 'Failed to create child-domain for staging environment. [404]') return 0 logging.statusWriter(tempStatusPath, 'Domain successfully created..,15') ## Copying Data - masterPath = '/home/%s/public_html' % (masterDomain) + ## Fetch child domain path + + childDomainPaths = [] + + for childs in website.childdomains_set.all(): + childDomainPaths.append(childs.path) + + filesAndFolder = os.listdir(masterPath) + + for items in filesAndFolder: + completePath = '%s/%s' % (masterPath, items) + + if completePath in childDomainPaths: + continue + else: + command = 'cp -r %s %s/' % (completePath, path) + ProcessUtilities.executioner(command, website.externalApp) + + foldersToBeRemoved = ['%s/.git' % (path), '%s/wp-content/backups' % (path), '%s/wp-content/updraft' % (path), '%s/wp-content/cache' % (path), '%s/wp-content/plugins/litespeed-cache' % (path)] + + for rmv in foldersToBeRemoved: + command = 'rm -rf %s' % (rmv) + ProcessUtilities.executioner(command, website.externalApp) - command = 'rsync -avzh --exclude "%s" --exclude ".git" --exclude "wp-content/backups" --exclude "wp-content/updraft" --exclude "wp-content/cache" --exclude "wp-content/plugins/litespeed-cache" %s/ %s' % ( - domain, masterPath, path) - ProcessUtilities.executioner(command, website.externalApp) logging.statusWriter(tempStatusPath, 'Data copied..,50') @@ -82,14 +106,18 @@ class StagingSetup(multi.Thread): configPath = '%s/wp-config.php' % (masterPath) - if not os.path.exists(configPath): + command = 'ls -la %s' % (configPath) + output = ProcessUtilities.outputExecutioner(command) + + if output.find('No such file or') > -1: logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]') return 0 - data = open(configPath, 'r').readlines() + command = 'cat %s' % (configPath) + data = ProcessUtilities.outputExecutioner(command).split('\n') for items in data: - if items.find('DB_NAME') > -1: + if items.find('DB_NAME') > -1 and items[0] != '/': try: dbName = items.split("'")[3] if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'): @@ -105,11 +133,6 @@ class StagingSetup(multi.Thread): databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName) - command = "sed -i 's/%s/%s/g' %s" % (masterDomain, domain, databasePath) - ProcessUtilities.executioner(command, 'cyberpanel') - command = "sed -i 's/%s/%s/g' %s" % ('https', 'http', databasePath) - ProcessUtilities.executioner(command, 'cyberpanel') - if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName): try: os.remove(databasePath) @@ -125,22 +148,31 @@ class StagingSetup(multi.Thread): ## Update final config file pathFinalConfig = '%s/wp-config.php' % (path) - data = open(pathFinalConfig, 'r').readlines() + + command = 'cat %s' % (configPath) + data = ProcessUtilities.outputExecutioner(command).split('\n') tmp = "/tmp/" + str(randint(1000, 9999)) writeToFile = open(tmp, 'w') for items in data: if items.find('DB_NAME') > -1: - writeToFile.write("define( 'DB_NAME', '%s' );\n" % (dbNameRestore)) + writeToFile.write("\ndefine( 'DB_NAME', '%s' );\n" % (dbNameRestore)) elif items.find('DB_USER') > -1: - writeToFile.write("define( 'DB_USER', '%s' );\n" % (dbUser)) + writeToFile.write("\ndefine( 'DB_USER', '%s' );\n" % (dbUser)) elif items.find('DB_PASSWORD') > -1: - writeToFile.write("define( 'DB_PASSWORD', '%s' );\n" % (dbPassword)) + writeToFile.write("\ndefine( 'DB_PASSWORD', '%s' );\n" % (dbPassword)) elif items.find('WP_SITEURL') > -1: continue + elif items.find("table_prefix") > -1: + writeToFile.writelines(items) + content = """ +define('WP_HOME','http://%s'); +define('WP_SITEURL','http://%s'); +""" % (domain, domain) + writeToFile.write(content) else: - writeToFile.write(items) + writeToFile.write(items + '\n') writeToFile.close() @@ -157,6 +189,14 @@ class StagingSetup(multi.Thread): except: pass + from filemanager.filemanager import FileManager + + fm = FileManager(None, None) + fm.fixPermissions(masterDomain) + + from plogical.installUtilities import installUtilities + installUtilities.reStartLiteSpeed() + logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 @@ -174,7 +214,11 @@ class StagingSetup(multi.Thread): child = ChildDomains.objects.get(domain=childDomain) + command = 'chmod 755 /home/%s/public_html' % (child.master.domain) + ProcessUtilities.executioner(command) + configPath = '%s/wp-config.php' % (child.path) + if not os.path.exists(configPath): logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]') return 0 @@ -189,7 +233,7 @@ class StagingSetup(multi.Thread): data = open(configPath, 'r').readlines() for items in data: - if items.find('DB_NAME') > -1: + if items.find('DB_NAME') > -1 and items[0] != '/': dbName = items.split("'")[3] if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'): break @@ -197,8 +241,6 @@ class StagingSetup(multi.Thread): raise BaseException('Failed to create database backup.') databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName) - command = "sed -i 's/%s/%s/g' %s" % (child.domain, child.master.domain, databasePath) - ProcessUtilities.executioner(command, 'cyberpanel') ## Restore to master domain @@ -209,7 +251,7 @@ class StagingSetup(multi.Thread): data = open(configPath, 'r').readlines() for items in data: - if items.find('DB_NAME') > -1: + if items.find('DB_NAME') > -1 and items[0] != '/': dbNameRestore = items.split("'")[3] if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName): try: @@ -222,7 +264,6 @@ class StagingSetup(multi.Thread): os.remove(databasePath) except: pass - if eraseCheck: sourcePath = child.path destinationPath = '/home/%s/public_html' % (child.master.domain) @@ -236,6 +277,14 @@ class StagingSetup(multi.Thread): command = 'rsync -avzh --exclude "wp-config.php" %s/ %s' % (sourcePath, destinationPath) ProcessUtilities.executioner(command, child.master.externalApp) + from filemanager.filemanager import FileManager + + fm = FileManager(None, None) + fm.fixPermissions(child.master.domain) + + from plogical.installUtilities import installUtilities + installUtilities.reStartLiteSpeed() + logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 diff --git a/websiteFunctions/models.py b/websiteFunctions/models.py index 93ebc01f1..ff4a5aea2 100755 --- a/websiteFunctions/models.py +++ b/websiteFunctions/models.py @@ -8,7 +8,6 @@ from datetime import datetime # Create your models here. - class Websites(models.Model): admin = models.ForeignKey(Administrator, on_delete=models.PROTECT) package = models.ForeignKey(Package, on_delete=models.PROTECT) @@ -26,7 +25,6 @@ class ChildDomains(models.Model): ssl = models.IntegerField() phpSelection = models.CharField(max_length=10,default=None) - class Backups(models.Model): website = models.ForeignKey(Websites,on_delete=models.CASCADE) fileName = models.CharField(max_length=200) @@ -34,16 +32,13 @@ class Backups(models.Model): size = models.CharField(max_length=50) status = models.IntegerField(default=0) - class dest(models.Model): destLoc = models.CharField(unique=True,max_length=18) - class backupSchedules(models.Model): dest = models.ForeignKey(dest, on_delete=models.CASCADE) frequency = models.CharField(max_length=15) - class aliasDomains(models.Model): master = models.ForeignKey(Websites, on_delete=models.CASCADE) aliasDomain = models.CharField(max_length=75) @@ -54,4 +49,15 @@ class GitLogs(models.Model): type = models.CharField(max_length=5) message = models.TextField(max_length=65532) +class BackupJob(models.Model): + logFile = models.CharField(max_length=1000) + ipAddress = models.CharField(max_length=50) + port = models.CharField(max_length=15) + jobSuccessSites = models.IntegerField() + jobFailedSites = models.IntegerField() + location = models.IntegerField() +class BackupJobLogs(models.Model): + owner = models.ForeignKey(BackupJob, on_delete=models.CASCADE) + status = models.IntegerField() + message = models.TextField() \ No newline at end of file diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 58c302260..f39798297 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -5836,7 +5836,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { $scope.autoCommitCurrent = response.data.autoCommitCurrent; $scope.autoPushCurrent = response.data.autoPushCurrent; $scope.emailLogsCurrent = response.data.emailLogsCurrent; - $scope.currentCommands = response.data.commands; + document.getElementById("currentCommands").value = response.data.commands; $scope.webhookCommandCurrent = response.data.webhookCommandCurrent; } else { $scope.gitTracking = false; @@ -6677,17 +6677,40 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { url = "/websites/saveGitConfigurations"; - var data = { domain: $("#domain").text(), folder: $scope.folder, autoCommit: $scope.autoCommit, autoPush: $scope.autoPush, emailLogs: $scope.emailLogs, - commands: $scope.commands, + commands: document.getElementById("currentCommands").value, webhookCommand: $scope.webhookCommand }; + if ($scope.autoCommit === undefined){ + $scope.autoCommitCurrent = 'Never'; + }else{ + $scope.autoCommitCurrent = $scope.autoCommit; + } + + if ($scope.autoPush === undefined){ + $scope.autoPushCurrent = 'Never'; + }else{ + $scope.autoPushCurrent = $scope.autoPush; + } + + if ($scope.emailLogs === undefined){ + $scope.emailLogsCurrent = false; + }else{ + $scope.emailLogsCurrent = $scope.emailLogs; + } + + if ($scope.webhookCommand === undefined){ + $scope.webhookCommandCurrent = false; + }else{ + $scope.webhookCommandCurrent = $scope.webhookCommand; + } + var config = { headers: { 'X-CSRFToken': getCookie('csrftoken') @@ -6782,4 +6805,5 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { }; }); + /* Java script code to git tracking ends here */ diff --git a/websiteFunctions/templates/websiteFunctions/installWordPress.html b/websiteFunctions/templates/websiteFunctions/installWordPress.html index 2800f2628..da2efa079 100755 --- a/websiteFunctions/templates/websiteFunctions/installWordPress.html +++ b/websiteFunctions/templates/websiteFunctions/installWordPress.html @@ -55,7 +55,7 @@
    - +
    diff --git a/websiteFunctions/templates/websiteFunctions/listChildDomains.html b/websiteFunctions/templates/websiteFunctions/listChildDomains.html index 668a9e0e6..518a976e6 100755 --- a/websiteFunctions/templates/websiteFunctions/listChildDomains.html +++ b/websiteFunctions/templates/websiteFunctions/listChildDomains.html @@ -41,7 +41,7 @@ style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888;">
    -
    -
    + class="col-lg-3 col-md-12">
    diff --git a/websiteFunctions/templates/websiteFunctions/manageGIT.html b/websiteFunctions/templates/websiteFunctions/manageGIT.html index 27ba5e006..d8558cc46 100755 --- a/websiteFunctions/templates/websiteFunctions/manageGIT.html +++ b/websiteFunctions/templates/websiteFunctions/manageGIT.html @@ -189,8 +189,7 @@
    -
    Currently: {$ autoCommitCurrent - $} +
    Currently: {$ autoCommitCurrent $}
    @@ -234,10 +233,9 @@
    - + class="form-control">
    diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 68763d5df..f4ee953e0 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -1367,7 +1367,7 @@ class WebsiteManager: CronUtil.CronPrem(0) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + website.externalApp else: cronPath = "/var/spool/cron/crontabs/" + website.externalApp @@ -1586,7 +1586,7 @@ class WebsiteManager: website = Websites.objects.get(domain=self.domain) - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: cronPath = "/var/spool/cron/" + website.externalApp else: cronPath = "/var/spool/cron/crontabs/" + website.externalApp @@ -1605,7 +1605,7 @@ class WebsiteManager: output = ProcessUtilities.outputExecutioner(execPath, website.externalApp) - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: command = 'chmod 600 %s' % (cronPath) ProcessUtilities.executioner(command) @@ -3222,7 +3222,23 @@ StrictHostKeyChecking no else: return ACLManager.loadErrorJson() - if validators.domain(self.gitHost) and ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame): + if self.gitHost.find(':') > -1: + gitHostDomain = self.gitHost.split(':')[0] + gitHostPort = self.gitHost.split(':')[1] + + if not validators.domain(gitHostDomain): + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + + try: + gitHostPort = int(gitHostPort) + except: + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + + else: + if not validators.domain(self.gitHost): + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + + if ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame): pass else: return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') @@ -3613,11 +3629,25 @@ StrictHostKeyChecking no else: return ACLManager.loadErrorJson() - logging.CyberCPLogFileWriter.writeToFile('hello world 2') + if self.gitHost.find(':') > -1: + gitHostDomain = self.gitHost.split(':')[0] + gitHostPort = self.gitHost.split(':')[1] + + if not validators.domain(gitHostDomain): + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + + try: + gitHostPort = int(gitHostPort) + except: + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + else: + if not validators.domain(self.gitHost): + return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') + ## Security check - if validators.domain(self.gitHost) and ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame): + if ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame): pass else: return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')