Merge branch 'v2.3.3-dev' into v2.3.3-dev

This commit is contained in:
Usman Nasir
2022-07-06 08:34:42 +05:00
committed by GitHub
28 changed files with 4889 additions and 972 deletions

View File

@@ -40,18 +40,42 @@ DIR=/etc/mail/spamassassin
if [ -d "$DIR" ]; then
sa-update
else
echo "Please install spamassassin through the CyberPanel interface before proceeding"
echo "Please install SpamAssasin through the CyberPanel interface before proceeding"
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)
CLNVERSION=$(sed '3q;d' /etc/os-release)
### OS Detection
Server_OS=""
Server_OS_Version=""
if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q "AlmaLinux-8" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
Server_OS="CloudLinux"
elif grep -q -E "Rocky Linux" /etc/os-release ; then
Server_OS="RockyLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10|Ubuntu 22.04" /etc/os-release ; then
Server_OS="Ubuntu"
elif grep -q -E "openEuler 20.03|openEuler 22.03" /etc/os-release ; then
Server_OS="openEuler"
else
echo -e "Unable to detect your system..."
echo -e "\nCyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03...\n"
exit
fi
if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2 | tr -d . )
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] ; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8, 7.9, so cut it to show first number only
#treat CloudLinux, Rocky and Alma as CentOS
fi
if [[ $Server_OS = "CentOS" ]] && [[ "$Server_OS_Version" = "7" ]] ; then
setenforce 0
yum install -y perl yum-utils perl-CPAN
@@ -68,7 +92,7 @@ if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
freshclam -v
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ]; then
elif [[ $Server_OS = "CentOS" ]] && [[ "$Server_OS_Version" = "8" ]] ; then
setenforce 0
yum install -y perl yum-utils perl-CPAN
@@ -107,7 +131,7 @@ elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; then
freshclam -v
elif [ "$OS" = "NAME=\"Ubuntu\"" ]; then
elif [[ $Server_OS = "Ubuntu" ]]; then
apt-get install -y libmysqlclient-dev
@@ -133,8 +157,8 @@ echo "/^Received:/ HOLD" >>/etc/postfix/header_checks
systemctl restart postfix
if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.noarch.deb
if [[ $Server_OS = "Ubuntu" ]]; then
wget https://github.com/MailScanner/v5/releases/download/5.4.4-1/MailScanner-5.4.4-1.noarch.deb
dpkg -i *.noarch.deb
mkdir /var/run/MailScanner
@@ -144,10 +168,9 @@ if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
chown -R postfix:postfix /var/lock/subsys/MailScanner
chown -R postfix:postfix /var/spool/MailScanner
elif [ "$OS" = "NAME=\"CentOS Linux\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm
elif [[ $Server_OS = "CentOS" ]]; then
wget https://github.com/MailScanner/v5/releases/download/5.4.4-1/MailScanner-5.4.4-1.rhel.noarch.rpm
rpm -Uvh *.rhel.noarch.rpm
elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm
rpm -Uvh *.rhel.noarch.rpm

View File

@@ -1,26 +1,52 @@
#!/bin/bash
## Uninstall Mailscanner CyberPanel
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)
CLNVERSION=$(sed '3q;d' /etc/os-release)
### OS Detection
Server_OS=""
Server_OS_Version=""
if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q "AlmaLinux-8" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
Server_OS="CloudLinux"
elif grep -q -E "Rocky Linux" /etc/os-release ; then
Server_OS="RockyLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10|Ubuntu 22.04" /etc/os-release ; then
Server_OS="Ubuntu"
elif grep -q -E "openEuler 20.03|openEuler 22.03" /etc/os-release ; then
Server_OS="openEuler"
else
echo -e "Unable to detect your system..."
echo -e "\nCyberPanel is supported on x86_64 based Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, Ubuntu 22.04, CentOS 7, CentOS 8, AlmaLinux 8, RockyLinux 8, CloudLinux 7, CloudLinux 8, openEuler 20.03, openEuler 22.03...\n"
exit
fi
Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2 | tr -d . )
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] || [[ "$Server_OS" = "RockyLinux" ]] ; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8, 7.9, so cut it to show first number only
#treat CloudLinux, Rocky and Alma as CentOS
fi
systemctl stop mailscanner
if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
apt purge -y mailscanner
elif
[ "$OS" = "NAME=\"CentOS Linux\"" ]
then
if [[ $Server_OS = "CentOS" ]] && [[ "$Server_OS_Version" = "7" ]] ; then
yum remove -y MailScanner
elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
elif [[ $Server_OS = "CentOS" ]] && [[ "$Server_OS_Version" = "8" ]] ; then
yum remove -y MailScanner
elif [[ $Server_OS = "Ubuntu" ]]; then
apt purge -y mailscanner
fi
sed -i 's/\/^Received:\/ HOLD/\/^Received:\/ IGNORE/g' /etc/postfix/header_checks

View File

@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
ALLOWED_HOSTS = ['*']

View File

@@ -138,7 +138,7 @@ class IncJobs(multi.Thread):
backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain)
resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile)
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s --exclude /home/%s/backup --exclude /home/%s/incbackup' % (
command = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s --exclude /home/%s/backup --exclude /home/%s/incbackup' % (
key, secret, self.website.domain, backupPath, self.passwordFile, self.website.domain, self.website.domain)
# If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end.
@@ -184,7 +184,7 @@ class IncJobs(multi.Thread):
key, secret = self.getAWSData()
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s forget %s --password-file %s' % (
command = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s restic -r s3:s3.amazonaws.com/%s forget %s --password-file %s' % (
key, secret, self.website, snapshotID, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command, self.externalApp)
@@ -195,7 +195,7 @@ class IncJobs(multi.Thread):
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
return 0
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s prune --password-file %s' % (
command = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s restic -r s3:s3.amazonaws.com/%s prune --password-file %s' % (
key, secret, self.website, self.passwordFile)
ProcessUtilities.outputExecutioner(command, self.externalApp)
@@ -204,7 +204,7 @@ class IncJobs(multi.Thread):
key, secret = self.getAWSData()
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s restore %s --password-file %s --target %s' % (
command = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s restic -r s3:s3.amazonaws.com/%s restore %s --password-file %s --target %s' % (
key, secret, self.website, snapshotID, self.passwordFile, self.restoreTarget)
result = ProcessUtilities.outputExecutioner(command, self.externalApp)
@@ -764,7 +764,7 @@ class IncJobs(multi.Thread):
logging.statusWriter(self.statusPath, result, 1)
else:
key, secret = self.getAWSData()
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s init --password-file %s' % (
command = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s restic -r s3:s3.amazonaws.com/%s init --password-file %s' % (
key, secret, self.website.domain, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command, self.externalApp)

View File

@@ -145,7 +145,7 @@
<li>
<b class="pull-right">{$ ramUsage $}%</b>
<div class="progress-title">
{% trans "Ram Usage" %}
{% trans "RAM Usage" %}
</div>
<div class="progressbar-small progressbar" data-value="{$ ramUsage $}">
<div class="progressbar-value bg-red tooltip-button" title="{$ ramUsage $}%"></div>
@@ -304,7 +304,7 @@
<a id="sidebar-menu-item-server-ip-address" href="#" title="{% trans 'Server IP Address' %}">
<i class="glyph-icon tooltip-button icon-laptop" title="{% trans 'Server IP Address' %}"
data-original-title=".icon-laptop"></i>
<span style="color: #db6868;font-weight: bold;">{{ ipAddress }}</span>
<span style="color: #488a3f;font-weight: bold;">{{ ipAddress }}</span>
</a>
<a id="sidebar-menu-item-dashboard" href="{% url 'index' %}" title="{% trans 'Dashboard' %}">
<i class="glyph-icon icon-dashboard"></i>
@@ -399,7 +399,7 @@
<li>
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'WordPress' %}">
<div class="glyph-icon icon-wordpress" title="{% trans 'WordPress' %}"></div>
<span>{% trans "WordPresss" %}</span>
<span>{% trans "WordPress" %}</span>
</a>
<div class="sidebar-submenu">
@@ -418,6 +418,9 @@
<li><a href="{% url 'RestoreBackups' %}"
title="{% trans 'RestoreBackups' %}"><span>{% trans "Restore Backups" %}</span></a>
</li>
<li><a href="{% url 'RemoteBackupConfig' %}"
title="{% trans 'Remote Backup' %}"><span>{% trans "Remote Backup" %}</span></a>
</li>
</ul>
</div><!-- .sidebar-submenu -->

View File

@@ -1,97 +1,87 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Version Management - CyberPanel" %}{% endblock %}
{% block title %}{% trans "Version Management - CyberPanel" %}"{% endblock %}
{% block content %}
{% load static %}
{% load static %}
<div class="container">
<div id="page-title">
<h2>{% trans "Version Management" %}</h2>
<p>{% trans "On this page you can manage versions and or upgrade to latest version of CyberPanel" %}</p>
</div>
{% if Notecheck %}
<div class="container">
<div id="page-title">
<h2>{% trans "Version Management" %}</h2>
<p>{% trans "Here you can manage versions and check for updates to CyberPanel" %}</p>
</div>
{% if Notecheck %}
<div class="alert alert-info">
<p style="color:red; font-weight: bold ;">{% trans "Note: Latest commit does not match, please upgrade." %}</p>
<p style="color:red; font-weight: bold ;">{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %}</p>
</div>
{% endif %}
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
CyberPanel
</h3>
<div ng-controller="versionManagment" class="example-box-wrapper">
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
CyberPanel
</h3>
<div ng-controller="versionManagment" class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Current Version :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ currentVersion }} </div>
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Version:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ currentVersion }} </div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Build :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ build }} </div>
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Current Commit :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ Currentcomt }} </div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Build:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ build }} </div>
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Commit:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ Currentcomt }} </div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Version :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ latestVersion }} </div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Build :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ latestBuild }} </div>
<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Commit :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ latestcomit }} </div>
{% comment %}<label class="col-sm-3 control-label "
style="margin: 0px!important; padding: 0px!important;">{% trans "# commits since update :" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9"
style="margin: 0px!important; padding: 0px!important;">{{ numCommits }} </div>{% endcomment %}
</div>
<div ng-hide="upgradelogBox" class="form-group">
<div class="col-sm-12">
<textarea ng-model="upgradeLog" rows="30" class="form-control">{{ logs }}</textarea>
</div>
</div>
</form>
<div class="form-group">
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Version:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestVersion }} </div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Build:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestBuild }} </div>
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Commit:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestcomit }} </div>
</div>
<div ng-hide="upgradelogBox" class="form-group">
<div class="col-sm-12">
<textarea ng-model="upgradeLog" rows="30" class="form-control">{{ logs }}</textarea>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -20,7 +20,7 @@ export LC_CTYPE=en_US.UTF-8
echo -e "\nFetching latest data from CyberPanel server...\n"
echo -e "This may take few seconds..."
Server_Country="Unknow"
Server_Country="Unknown"
Server_OS=""
Server_OS_Version=""
Server_Provider='Undefined'
@@ -64,18 +64,18 @@ echo -e "\n${1}" >> /var/log/upgradeLogs.txt
Check_Root() {
echo -e "\nChecking root privileges..."
if echo "$Sudo_Test" | grep SUDO >/dev/null; then
echo -e "\nYou are using SUDO , please run as root user...\n"
echo -e "\nYou are using SUDO, please run as root user...\n"
echo -e "\nIf you don't have direct access to root user, please run \e[31msudo su -\e[39m command (do NOT miss the \e[31m-\e[39m at end or it will fail) and then run installation command again."
exit
fi
if [[ $(id -u) != 0 ]] >/dev/null; then
echo -e "\nYou must run on root user to install CyberPanel...\n"
echo -e "or run following command: (do NOT miss the quotes)"
echo -e "\nYou must run as root user to install CyberPanel...\n"
echo -e "or run the following command: (do NOT miss the quotes)"
echo -e "\e[31msudo su -c \"sh <(curl https://cyberpanel.sh || wget -O - https://cyberpanel.sh)\"\e[39m"
exit 1
else
echo -e "\nYou are runing as root...\n"
echo -e "\nYou are running as root...\n"
fi
}
@@ -84,7 +84,7 @@ echo -e "Checking server location...\n"
Server_Country=$(curl --silent --max-time 10 -4 https://cyberpanel.sh/?country)
if [[ ${#Server_Country} != "2" ]] ; then
Server_Country="Unknow"
Server_Country="Unknown"
fi
if [[ "$Debug" = "On" ]] ; then
@@ -93,7 +93,7 @@ fi
if [[ "$*" = *"--mirror"* ]] ; then
Server_Country="CN"
echo -e "Force to use mirror server due to --mirror argument...\n"
echo -e "Forced to use mirror server due to --mirror argument...\n"
fi
if [[ "$Server_Country" = *"CN"* ]] ; then
@@ -104,7 +104,7 @@ fi
Check_OS() {
if [[ ! -f /etc/os-release ]] ; then
echo -e "Unable to detect the operating system...\n"
echo -e "Unable to detect the Operating System...\n"
exit
fi
@@ -474,7 +474,7 @@ for i in {1..50};
sleep 30
fi
done
#special made function for Gitee.com , for whatever reason , sometimes it fails to download this file
#special made function for Gitee.com, for whatever reason sometimes it fails to download this file
}
@@ -490,12 +490,12 @@ else
fi
if [[ -f /usr/local/CyberPanel/bin/python2 ]]; then
echo -e "\nPython 2 dectected, doing resetup...\n"
echo -e "\nPython 2 dectected, doing re-setup...\n"
rm -rf /usr/local/CyberPanel/bin
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
Check_Return
elif [[ -d /usr/local/CyberPanel/bin/ ]]; then
echo -e "\nNo need to resetup virtualenv at /usr/local/CyberPanel...\n"
echo -e "\nNo need to re-setup virtualenv at /usr/local/CyberPanel...\n"
else
echo -e "\nNothing found, need fresh setup...\n"
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
@@ -562,9 +562,9 @@ fi
}
Pre_Upgrade_Branch_Input() {
echo -e "\nPress Enter key to continue with latest version or Enter specific version such as: \e[31m1.9.4\e[39m , \e[31m1.9.5\e[39m ...etc"
echo -e "\nIf nothing is input in 10 seconds , script will proceed with latest stable. "
echo -e "\nPlease press Enter key , or specify a version number ,or wait for 10 seconds timeout: "
echo -e "\nPress the Enter key to continue with latest version, or enter specific version such as: \e[31m1.9.4\e[39m , \e[31m1.9.5\e[39m ...etc"
echo -e "\nIf nothing is input in 10 seconds, script will proceed with the latest stable version. "
echo -e "\nPlease press the Enter key or specify a version number, or wait for 10 seconds: "
printf "%s" ""
read -r -t 10 Tmp_Input
if [[ $Tmp_Input = "" ]]; then
@@ -583,7 +583,7 @@ if [[ -f /usr/local/CyberCP/bin/python2 ]]; then
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
Check_Return
elif [[ -d /usr/local/CyberCP/bin/ ]]; then
echo -e "\nNo need to resetup virtualenv at /usr/local/CyberCP...\n"
echo -e "\nNo need to re-setup virtualenv at /usr/local/CyberCP...\n"
else
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP
Check_Return
@@ -751,7 +751,7 @@ if curl -I -XGET -k "https://127.0.0.1:${Panel_Port#*:}" | grep -q "200 OK" ; th
echo " CyberPanel Upgraded "
echo "###################################################################"
else
echo -e "\nSeems something wrong with upgarde, please check...\n"
echo -e "\nSeems something wrong with upgrade, please check...\n"
fi
rm -rf /root/cyberpanel_upgrade_tmp
}

View File

@@ -729,7 +729,7 @@ password="%s"
preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
command, 1, 0, os.EX_OSERR)
command = 'unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/'
command = 'unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/phpmyadmin'
preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
command, 1, 0, os.EX_OSERR)
@@ -1743,6 +1743,15 @@ autocreate_system_folders = On
7 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
0 0 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
0 0 * * 0 /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly
*/30 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '30 Minutes'
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Hour'
0 */6 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '6 Hours'
0 */12 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '12 Hours'
0 1 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Day'
0 0 */3 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '3 Days'
0 0 * * 0 /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Week'
*/3 * * * * if ! find /home/*/public_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi
"""

View File

@@ -259,7 +259,7 @@
<div class="card mb-3" style="max-width: 540px;">
<div class="row g-0">
<div class="col-md-3">
<img src="/static/images/new-design-list-websites-square.png" alt="..."
<img src="{% static 'baseTemplate/images/new-design-list-websites-square.png' %}" alt="..."
class="object-fit">
</div>
<div class="col-md-8 ml-5">

View File

@@ -108,8 +108,8 @@
</div>
<div ng-hide="successfullyCreated" class="alert alert-success">
<p>{% trans "Email with id :" %} {$ createdID
$}{% trans " is successfully created." %}</p>
<p>{% trans "Mailbox with username:" %} {$ createdID
$}{% trans " has been successfully created." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>

View File

@@ -92,7 +92,7 @@
</div>
<div ng-hide="successfullyDeleted" class="alert alert-success">
<p>{% trans "Email with id : {$ deletedID $} is successfully deleted." %}</p>
<p>{% trans "Mailbox with username: {$ deletedID $} has been successfully deleted." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>

View File

@@ -1,9 +1,11 @@
#!/usr/local/CyberCP/bin/python
import os.path
import sys
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
import django
django.setup()
from IncBackups.IncBackupsControl import IncJobs
from IncBackups.models import BackupJob
@@ -22,6 +24,7 @@ import requests
import socket
from websiteFunctions.models import NormalBackupJobs, NormalBackupJobLogs
from boto3.s3.transfer import TransferConfig
try:
from s3Backups.models import BackupPlan, BackupLogs
import boto3
@@ -63,7 +66,7 @@ class IncScheduler(multi.Thread):
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
for job in BackupJob.objects.all():
logging.statusWriter(IncScheduler.logPath, 'Job Description:\n\n Destination: %s, Frequency: %s.\n ' % (
job.destination, job.frequency), 1)
job.destination, job.frequency), 1)
if job.frequency == type:
for web in job.jobsites_set.all():
logging.statusWriter(IncScheduler.logPath, 'Backing up %s.' % (web.website), 1)
@@ -129,7 +132,7 @@ class IncScheduler(multi.Thread):
web = Websites.objects.get(domain=website)
message = '[%s Cron] Checking if %s has any pending commits on %s.' % (
type, website, time.strftime("%m.%d.%Y_%H-%M-%S"))
type, website, time.strftime("%m.%d.%Y_%H-%M-%S"))
finalText = '%s\n' % (message)
GitLogs(owner=web, type='INFO', message=message).save()
@@ -148,7 +151,7 @@ class IncScheduler(multi.Thread):
data['domain'] = gitConf['domain']
data['folder'] = gitConf['folder']
data['commitMessage'] = 'Auto commit by CyberPanel %s cron on %s' % (
type, time.strftime('%m-%d-%Y_%H-%M-%S'))
type, time.strftime('%m-%d-%Y_%H-%M-%S'))
if gitConf['autoCommit'] == type:
@@ -182,7 +185,7 @@ class IncScheduler(multi.Thread):
finalText = '%s\n%s' % (finalText, message)
message = '[%s Cron] Finished checking for %s on %s.' % (
type, website, time.strftime("%m.%d.%Y_%H-%M-%S"))
type, website, time.strftime("%m.%d.%Y_%H-%M-%S"))
finalText = '%s\n%s' % (finalText, message)
logging.SendEmail(web.adminEmail, web.adminEmail, finalText, 'Git report for %s.' % (web.domain))
GitLogs(owner=web, type='INFO', message=message).save()
@@ -333,7 +336,7 @@ class IncScheduler(multi.Thread):
if retValues[0] == 0:
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
message='[ERROR] Backup failed for %s, error: %s moving on..' % (
website.domain, retValues[1])).save()
website.domain, retValues[1])).save()
continue
completeFileToSend = retValues[1] + ".tar.gz"
@@ -378,12 +381,9 @@ class IncScheduler(multi.Thread):
GDriveJobLogs(owner=items, status=backupSchedule.INFO,
message='Job Completed').save()
print("job com[leted")
#logging.writeToFile('job completed')
# logging.writeToFile('job completed')
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
@@ -400,67 +400,67 @@ class IncScheduler(multi.Thread):
page_token = None
while True:
response = drive.files().list(q="name='%s-%s'" % (items.name,ipAddress),
spaces='drive',
response = drive.files().list(q="name='%s-%s'" % (items.name, ipAddress),
spaces='drive',
fields='nextPageToken, files(id, name)',
pageToken=page_token).execute()
for file in response.get('files', []):
# Process change
#print('Fetch Main folder ID: %s (%s)' % (file.get('name'), file.get('id')))
#logging.writeToFile('Fetch Main folder ID: %s (%s)' % (file.get('name'), file.get('id')))
mainfolder_id= file.get('id')
# print('Fetch Main folder ID: %s (%s)' % (file.get('name'), file.get('id')))
# logging.writeToFile('Fetch Main folder ID: %s (%s)' % (file.get('name'), file.get('id')))
mainfolder_id = file.get('id')
page_token = response.get('nextPageToken', None)
if page_token is None:
break
#print("new job started ")
# print("new job started ")
try:
page_token = None
while True:
response = drive.files().list(q="'%s' in parents"%(mainfolder_id),
spaces='drive',
fields='nextPageToken, files(id, name, createdTime)',
pageToken=page_token).execute()
response = drive.files().list(q="'%s' in parents" % (mainfolder_id),
spaces='drive',
fields='nextPageToken, files(id, name, createdTime)',
pageToken=page_token).execute()
for file in response.get('files', []):
# Process change
#print('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'), file.get('createdTime')))
#logging.writeToFile('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'),file.get('createdTime')))
# print('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'), file.get('createdTime')))
# logging.writeToFile('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'),file.get('createdTime')))
ab = file.get('createdTime')[:10]
filename = file.get('name')
fileDeleteID = file.get('id')
timestamp = time.mktime(datetime.datetime.strptime(ab,"%Y-%m-%d").timetuple())
timestamp = time.mktime(datetime.datetime.strptime(ab, "%Y-%m-%d").timetuple())
CUrrenttimestamp = time.time()
timerrtention = gDriveData['FileRetentiontime']
if(timerrtention == '1d'):
if (timerrtention == '1d'):
new = CUrrenttimestamp - float(86400)
if(new>=timestamp):
resp=drive.files().delete(fileId=fileDeleteID).execute()
logging.writeToFile('Delete file %s '%filename)
elif(timerrtention == '1w'):
if (new >= timestamp):
resp = drive.files().delete(fileId=fileDeleteID).execute()
logging.writeToFile('Delete file %s ' % filename)
elif (timerrtention == '1w'):
new = CUrrenttimestamp - float(604800)
if (new >= timestamp):
resp = drive.files().delete(fileId=fileDeleteID).execute()
logging.writeToFile('Delete file %s '%filename)
logging.writeToFile('Delete file %s ' % filename)
elif (timerrtention == '1m'):
new = CUrrenttimestamp - float(2592000)
if (new >= timestamp):
resp = drive.files().delete(fileId=fileDeleteID).execute()
logging.writeToFile('Delete file %s '%filename)
logging.writeToFile('Delete file %s ' % filename)
elif (timerrtention == '6m'):
new = CUrrenttimestamp - float(15552000)
if (new >= timestamp):
resp = drive.files().delete(fileId=fileDeleteID).execute()
logging.writeToFile('Delete file %s '%filename)
logging.writeToFile('Delete file %s ' % filename)
page_token = response.get('nextPageToken', None)
if page_token is None:
break
# logging.writeToFile('Createtime list - %s'%Createtime)
# logging.writeToFile('Createtime list - %s'%Createtime)
except BaseException as msg:
print('An error occurred fetch child: %s' % msg)
logging.writeToFile('An error occurred fetch child: %s' % msg)
print('An error occurred fetch child: %s' % msg)
logging.writeToFile('An error occurred fetch child: %s' % msg)
except BaseException as msg:
logging.writeToFile('job not completed [ERROR:]..%s'%msg)
logging.writeToFile('job not completed [ERROR:]..%s' % msg)
except BaseException as msg:
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
@@ -523,7 +523,7 @@ class IncScheduler(multi.Thread):
NormalBackupJobLogs.objects.filter(owner=backupjob).delete()
NormalBackupJobLogs(owner=backupjob, status=backupSchedule.INFO,
message='Starting %s backup on %s..' % (
type, time.strftime("%m.%d.%Y_%H-%M-%S"))).save()
type, time.strftime("%m.%d.%Y_%H-%M-%S"))).save()
if oldJobContinue:
NormalBackupJobLogs(owner=backupjob, status=backupSchedule.INFO,
@@ -886,8 +886,7 @@ Automatic backup failed for %s on %s.
emailPath = '/home/vmail/%s/%s' % (website.domain, email.email.split('@')[0])
email.DiskUsage = virtualHostUtilities.getDiskUsageofPath(emailPath)
email.save()
print('Disk Usage of %s is %s' % (email.email,email.DiskUsage))
print('Disk Usage of %s is %s' % (email.email, email.DiskUsage))
config['DiskUsage'], config['DiskUsagePercentage'] = virtualHostUtilities.getDiskUsage(
"/home/" + website.domain, website.package.diskSpace)
@@ -947,19 +946,420 @@ Automatic backup failed for %s on %s.
if config['pluginUpdates'] == 'Enabled':
command = 'wp plugin update --all --minor --allow-root --path=/home/%s/public_html' % (
config['domainName'])
config['domainName'])
ProcessUtilities.executioner(command)
### Themes, for plugins we will do minor updates only.
if config['themeUpdates'] == 'Enabled':
command = 'wp theme update --all --minor --allow-root --path=/home/%s/public_html' % (
config['domainName'])
config['domainName'])
ProcessUtilities.executioner(command)
except BaseException as msg:
logging.writeToFile('%s. [WPUpdates:767]' % (str(msg)))
@staticmethod
def RemoteBackup(function):
try:
from websiteFunctions.models import RemoteBackupSchedule, RemoteBackupsites, WPSites
from loginSystem.models import Administrator
import json
import time
from plogical.applicationInstaller import ApplicationInstaller
for config in RemoteBackupSchedule.objects.all():
try:
configbakup = json.loads(config.config)
backuptype = configbakup['BackupType']
if backuptype == 'Only DataBase':
Backuptype = "3"
elif backuptype == 'Only Website':
Backuptype = "2"
else:
Backuptype = "1"
except:
continue
try:
allRemoteBackupsiteobj = RemoteBackupsites.objects.filter(owner=config.pk)
for i in allRemoteBackupsiteobj:
backupsiteID = i.WPsites
wpsite = WPSites.objects.get(pk=backupsiteID)
AdminID = wpsite.owner.admin_id
Admin = Administrator.objects.get(pk=AdminID)
Lastrun = config.lastrun
Currenttime = float(time.time())
if config.timeintervel == function:
#al = float(Currenttime) - float(1800)
#if float(al) >= float(Lastrun):
#if 1 == 1:
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(3600)
#if float(al) >= float(Lastrun):
# if 1 == 1:
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(21600)
#if float(al) >= float(Lastrun):
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(43200)
#if float(al) >= float(Lastrun):
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(86400)
#if float(al) >= float(Lastrun):
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(259200)
#if float(al) >= float(Lastrun):
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.timeintervel == function:
#al = float(Currenttime) - float(604800)
#if float(al) >= float(Lastrun):
extraArgs = {}
extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup()
if status == 1:
filename = msg
if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id)
command = f"rm -r {filename}"
ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time()
obj.save()
except BaseException as msg:
print("Error in Sites:%s" % str(msg))
continue
except BaseException as msg:
print("Error: [RemoteBackup]: %s" % str(msg))
logging.writeToFile('%s. [RemoteBackup]' % (str(msg)))
@staticmethod
def SendTORemote(FileName, RemoteBackupID):
import pysftp
import json
import pysftp as sftp
from websiteFunctions.models import RemoteBackupConfig
try:
RemoteBackupOBJ = RemoteBackupConfig.objects.get(pk=RemoteBackupID)
config = json.loads(RemoteBackupOBJ.config)
HostName = config['Hostname']
Username = config['Username']
Password = config['Password']
Path = config['Path']
cnopts = sftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection(HostName, username=Username, password=Password, cnopts=cnopts) as sftp:
print("Connection succesfully stablished ... ")
try:
with sftp.cd(Path):
sftp.put(FileName)
except:
sftp.mkdir(Path)
with sftp.cd(Path):
sftp.put(FileName)
except BaseException as msg:
logging.writeToFile('%s. [SendTORemote]' % (str(msg)))
@staticmethod
def SendToS3Cloud(FileName, RemoteBackupCofigID, backupID, scheduleID):
import boto3
import json
import time
from websiteFunctions.models import RemoteBackupConfig, WPSitesBackup, RemoteBackupSchedule
import plogical.randomPassword as randomPassword
try:
print("UPloading to S3")
Backupobj = WPSitesBackup.objects.get(pk=backupID)
backupConfig = json.loads(Backupobj.config)
websitedomain = backupConfig['WebDomain']
RemoteBackupOBJ = RemoteBackupConfig.objects.get(pk=RemoteBackupCofigID)
config = json.loads(RemoteBackupOBJ.config)
provider = config['Provider']
if provider == "Backblaze":
EndURl = config['EndUrl']
elif provider == "Amazon":
EndURl = "https://s3.us-east-1.amazonaws.com"
elif provider == "Wasabi":
EndURl = "https://s3.wasabisys.com"
AccessKey = config['AccessKey']
SecertKey = config['SecertKey']
session = boto3.session.Session()
client = session.client(
's3',
endpoint_url=EndURl,
aws_access_key_id=AccessKey,
aws_secret_access_key=SecertKey,
verify=False
)
# ############Creating Bucket
# BucketName = randomPassword.generate_pass().lower()
# print("BucketName...%s"%BucketName)
#
# try:
# client.create_bucket(Bucket=BucketName)
# except BaseException as msg:
# print("Error in Creating bucket...: %s" % str(msg))
# logging.writeToFile("Create bucket error---%s:" % str(msg))
####getting Bucket from backup schedule
Scheduleobj = RemoteBackupSchedule.objects.get(pk=scheduleID)
Scheduleconfig = json.loads(Scheduleobj.config)
BucketName = Scheduleconfig['BucketName']
#####Uploading File
uploadfilename = 'backup-' + websitedomain + "-" + time.strftime("%m.%d.%Y_%H-%M-%S")
print("uploadfilename....%s"%uploadfilename)
try:
res = client.upload_file(Filename=FileName, Bucket=BucketName, Key=uploadfilename)
print("res of Uploading...: %s" % res)
except BaseException as msg:
print("Error in Uploading...: %s" % msg)
###################### version id, this only applied to blackbaze
try:
s3 = boto3.resource(
's3',
endpoint_url=EndURl,
aws_access_key_id=AccessKey,
aws_secret_access_key=SecertKey,
)
bucket = BucketName
key = uploadfilename
versions = s3.Bucket(bucket).object_versions.filter(Prefix=key)
data = {}
for version in versions:
obj = version.get()
print("VersionId---%s:" % obj.get('VersionId'))
data['backupVersionId'] = obj.get('VersionId')
ab = os.path.getsize(FileName)
filesize = float(ab) / 1024.0
backupConfig['uploadfilename'] = uploadfilename
backupConfig['backupVersionId'] = data['backupVersionId']
backupConfig['BucketName'] = BucketName
backupConfig['Uplaodingfilesize'] = filesize
Backupobj.config = json.dumps(backupConfig)
Backupobj.save()
except BaseException as msg:
print("Version ID Error: %s"%str(msg))
except BaseException as msg:
print('%s. [SendToS3Cloud]' % (str(msg)))
logging.writeToFile('%s. [SendToS3Cloud]' % (str(msg)))
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -967,6 +1367,10 @@ def main():
parser.add_argument('--planName', help='Plan name for AWS!')
args = parser.parse_args()
if args.function == '30 Minutes' or args.function == '30 Minutes' or args.function == '1 Hour' or args.function == '6 Hours' or args.function == '12 Hours' or args.function == '1 Day' or args.function == '3 Days' or args.function == '1 Week':
IncScheduler.RemoteBackup(args.function)
return 0
if args.function == 'forceRunAWSBackup':
IncScheduler.forceRunAWSBackup(args.planName)
return 0
@@ -979,10 +1383,10 @@ def main():
ib = IncScheduler('startBackup', {'freq': args.function})
ib.start()
###
IncScheduler.startBackup(args.function)
IncScheduler.runGoogleDriveBackups(args.function)
IncScheduler.git(args.function)
IncScheduler.checkDiskUsage()
@@ -993,4 +1397,4 @@ def main():
if __name__ == "__main__":
main()
main()

File diff suppressed because it is too large Load Diff

View File

@@ -360,8 +360,7 @@ class backupUtilities:
completPathToConf = f'{backupUtilities.Server_root}/conf/vhosts/{domainName}/vhost.conf'
if os.path.exists(backupUtilities.licenseKey):
copy(completPathToConf, tempStoragePath + '/vhost.conf')
copy(completPathToConf, tempStoragePath + '/vhost.conf')
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
## shutil.make_archive
@@ -441,9 +440,9 @@ class backupUtilities:
actualChildDomain = childDomain.find('domain').text
childPath = childDomain.find('path').text
if os.path.exists(backupUtilities.licenseKey):
completPathToConf = f'{backupUtilities.Server_root}/conf/vhosts/{actualChildDomain}/vhost.conf'
copy(completPathToConf, f'{tempStoragePath}/{actualChildDomain}.vhost.conf')
completPathToConf = f'{backupUtilities.Server_root}/conf/vhosts/{actualChildDomain}/vhost.conf'
copy(completPathToConf, f'{tempStoragePath}/{actualChildDomain}.vhost.conf')
### Storing SSL for child domainsa
@@ -813,10 +812,9 @@ class backupUtilities:
try:
if os.path.exists(backupUtilities.licenseKey):
if os.path.exists(completPath + '/' + domain + '.vhost.conf'):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + domain + '/vhost.conf'
copy(completPath + '/' + domain + '.vhost.conf', completPathToConf)
if os.path.exists(completPath + '/' + domain + '.vhost.conf'):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + domain + '/vhost.conf'
copy(completPath + '/' + domain + '.vhost.conf', completPathToConf)
sslStoragePath = completPath + "/" + domain + ".cert.pem"
@@ -1025,10 +1023,9 @@ class backupUtilities:
## emails extracted
if os.path.exists(backupUtilities.licenseKey):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + masterDomain + '/vhost.conf'
if os.path.exists(completPath + '/vhost.conf'):
copy(completPath + '/vhost.conf', completPathToConf)
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + masterDomain + '/vhost.conf'
if os.path.exists(completPath + '/vhost.conf'):
copy(completPath + '/vhost.conf', completPathToConf)
logging.CyberCPLogFileWriter.statusWriter(status, "Done")

View File

@@ -838,6 +838,7 @@ password=%s
if connection == 0:
return 0
cursor.execute("use mysql")
if host != None:
@@ -855,11 +856,11 @@ password=%s
else:
query = "SET PASSWORD FOR '" + userName + "'@'%s' = '" % (LOCALHOST) + dbPassword + "'"
cursor.execute(query)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(query)
cursor.execute(query)
connection.close()
return 1

View File

@@ -291,7 +291,6 @@ class ProcessUtilities(multi.Thread):
@staticmethod
def outputExecutioner(command, user=None, shell = None, dir = None, retRequired = None):
try:
if getpass.getuser() == 'root':
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command)
@@ -299,7 +298,11 @@ class ProcessUtilities(multi.Thread):
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
p = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return p.communicate()[0].decode("utf-8")
if retRequired:
return 1, p.communicate()[0].decode("utf-8")
else:
return p.communicate()[0].decode("utf-8")
if type(command) == list:
command = " ".join(command)

View File

@@ -0,0 +1,9 @@
config= {
"name": "habi",
"dev": "python"
}
print(config)
config['klm'] ="tls"
print(config)

View File

@@ -287,7 +287,7 @@ class Upgrade:
command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://github.com/usmannasir/cyberpanel/raw/stable/phpmyadmin.zip'
Upgrade.executioner(command, 0)
command = 'unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/'
command = 'unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/phpmyadmin'
Upgrade.executioner(command, 0)
command = 'mv /usr/local/CyberCP/public/phpMyAdmin-*-all-languages /usr/local/CyberCP/public/phpmyadmin'
@@ -2566,6 +2566,22 @@ vmail
writeToFile = open(cronPath, 'a')
writeToFile.write(content)
writeToFile.close()
if data.find("IncScheduler.py '30 Minutes'") == -1:
content = """
*/30 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '30 Minutes'
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Hour'
0 */6 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '6 Hours'
0 */12 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '12 Hours'
0 1 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Day'
0 0 */3 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '3 Days'
0 0 * * 0 /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py '1 Week'
"""
writeToFile = open(cronPath, 'a')
writeToFile.write(content)
writeToFile.close()
else:
content = """
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
@@ -2786,7 +2802,7 @@ vmail
command = execPath + " --function submitinstallImunifyAV"
Upgrade.executioner(command, command, 1)
command = 'chmod +x /usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py'
command = 'chmod +x /usr/local/CyberCP/public/imunifyav/bin/execute.py'
Upgrade.executioner(command, command, 1)

View File

@@ -128,3 +128,22 @@ class WPSitesBackup(models.Model):
WPSiteID = models.IntegerField(default=-1)
WebsiteID = models.IntegerField(default=-1)
config = models.TextField()
class RemoteBackupConfig(models.Model):
owner = models.ForeignKey(Administrator, on_delete=models.CASCADE)
configtype = models.CharField(max_length=255, default='')
config = models.TextField()
class RemoteBackupSchedule(models.Model):
RemoteBackupConfig = models.ForeignKey(RemoteBackupConfig, on_delete=models.CASCADE)
Name = models.CharField(max_length=255, default='')
timeintervel = models.CharField(max_length=200)
fileretention = models.CharField(max_length=200)
lastrun = models.CharField(max_length=200)
config = models.TextField()
class RemoteBackupsites(models.Model):
owner = models.ForeignKey(RemoteBackupSchedule, on_delete=models.CASCADE)
WPsites = models.IntegerField(null=True)
database = models.IntegerField(null=True)

View File

@@ -521,7 +521,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
if (response.data.ret_data.maintenanceMode === 1) {
$('#maintenanceMode').prop('checked', true);
}
if(response.data.ret_data.wpcron === 1) {
if (response.data.ret_data.wpcron === 1) {
$('#wpcron').prop('checked', true);
}
if (response.data.ret_data.passwordprotection == 1) {
@@ -589,8 +589,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
PPPassword: $scope.PPPassword,
}
}
else {
} else {
var data = {
WPid: $('#WPid').html(),
setting: setting,
@@ -633,7 +632,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
text: 'Successfully Updated!.',
type: 'success'
});
if (setting === "PasswordProtection"){
if (setting === "PasswordProtection") {
location.reload();
}
} else {
@@ -642,7 +641,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
text: response.data.error_message,
type: 'error'
});
if (setting === "PasswordProtection"){
if (setting === "PasswordProtection") {
location.reload();
}
@@ -1955,6 +1954,329 @@ app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) {
});
//.......................................Remote Backup
//........... delete DeleteBackupConfigNow
function DeleteBackupConfigNow(url) {
window.location.href = url;
}
function DeleteRemoteBackupsiteNow(url) {
window.location.href = url;
}
function DeleteBackupfileConfigNow(url) {
window.location.href = url;
}
app.controller('RemoteBackupConfig', function ($scope, $http, $timeout, $window) {
$scope.RemoteBackupLoading = true;
$scope.SFTPBackUpdiv = true;
$scope.EndpointURLdiv = true;
$scope.Selectprovider = true;
$scope.S3keyNamediv = true;
$scope.Accesskeydiv = true;
$scope.SecretKeydiv = true;
$scope.SelectRemoteBackuptype = function () {
var val = $scope.RemoteBackuptype;
if (val == "SFTP") {
$scope.SFTPBackUpdiv = false;
$scope.EndpointURLdiv = true;
$scope.Selectprovider = true;
$scope.S3keyNamediv = true;
$scope.Accesskeydiv = true;
$scope.SecretKeydiv = true;
} else if (val == "S3") {
$scope.EndpointURLdiv = true;
$scope.Selectprovider = false;
$scope.S3keyNamediv = false;
$scope.Accesskeydiv = false;
$scope.SecretKeydiv = false;
$scope.SFTPBackUpdiv = true;
} else {
$scope.RemoteBackupLoading = true;
$scope.SFTPBackUpdiv = true;
$scope.EndpointURLdiv = true;
$scope.Selectprovider = true;
$scope.S3keyNamediv = true;
$scope.Accesskeydiv = true;
$scope.SecretKeydiv = true;
}
}
$scope.SelectProvidertype = function () {
$scope.EndpointURLdiv = true;
var provider = $scope.Providervalue
if (provider == 'Backblaze') {
$scope.EndpointURLdiv = false;
} else {
$scope.EndpointURLdiv = true;
}
}
$scope.SaveBackupConfig = function () {
$scope.RemoteBackupLoading = false;
var Hname = $scope.Hostname;
var Uname = $scope.Username;
var Passwd = $scope.Password;
var path = $scope.path;
var type = $scope.RemoteBackuptype;
var Providervalue = $scope.Providervalue;
var data;
if (type == "SFTP") {
data = {
Hname: Hname,
Uname: Uname,
Passwd: Passwd,
path: path,
type: type
}
} else if (type == "S3") {
if (Providervalue == "Backblaze") {
data = {
S3keyname: $scope.S3keyName,
Provider: Providervalue,
AccessKey: $scope.Accesskey,
SecertKey: $scope.SecretKey,
EndUrl: $scope.EndpointURL,
type: type
}
} else {
data = {
S3keyname: $scope.S3keyName,
Provider: Providervalue,
AccessKey: $scope.Accesskey,
SecertKey: $scope.SecretKey,
type: type
}
}
}
var url = "/websites/SaveBackupConfig";
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.RemoteBackupLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Successfully Saved!.',
type: 'success'
});
location.reload();
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.RemoteBackupLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
});
var UpdatescheduleID;
app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) {
$scope.BackupScheduleLoading = true;
$scope.SaveBackupSchedule = function () {
$scope.RemoteBackupLoading = false;
var FileRetention = $scope.Fretention;
var Backfrequency = $scope.Bfrequency;
var data = {
FileRetention: FileRetention,
Backfrequency: Backfrequency,
ScheduleName: $scope.ScheduleName,
RemoteConfigID: $('#RemoteConfigID').html(),
BackupType: $scope.BackupType
}
var url = "/websites/SaveBackupSchedule";
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.RemoteBackupLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Successfully Saved!.',
type: 'success'
});
location.reload();
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.RemoteBackupLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
};
$scope.getupdateid = function (ID) {
UpdatescheduleID = ID;
}
$scope.UpdateRemoteschedules = function () {
$scope.RemoteBackupLoading = false;
var Frequency = $scope.RemoteFrequency;
var fretention = $scope.RemoteFileretention;
var data = {
ScheduleID: UpdatescheduleID,
Frequency: Frequency,
FileRetention: fretention
}
var url = "/websites/UpdateRemoteschedules";
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.RemoteBackupLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Successfully Updated!.',
type: 'success'
});
location.reload();
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.RemoteBackupLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
};
$scope.AddWPsiteforRemoteBackup = function () {
$scope.RemoteBackupLoading = false;
var data = {
WpsiteID: $('#Wpsite').val(),
RemoteScheduleID: $('#RemoteScheduleID').html()
}
var url = "/websites/AddWPsiteforRemoteBackup";
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.RemoteBackupLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Successfully Saved!.',
type: 'success'
});
location.reload();
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.RemoteBackupLoading = true;
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
};
});
/* Java script code to create account */
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {

View File

@@ -0,0 +1,87 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Backup Sites Configurations - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Backup Sites Configurations" %}</h2>
</div>
<div ng-controller="BackupSchedule" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans " Add WordPress Sites for Remote Backup" %} <img ng-hide="BackupScheduleLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<span style="display: none" id="RemoteScheduleID"> {{ RemoteScheduleID }}</span>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Selecte WordPress Site" %}</label>
<div class="col-sm-6">
<select ng-model="Wpsite" id="Wpsite"
class="form-control">
{% for i in WPsites %}
<option value="{{ i.id }}">{{ i.title }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="AddWPsiteforRemoteBackup()"
class="btn btn-primary btn-lg">{% trans "Save Backup Schedule" %}</button>
</div>
</div>
</form>
<h3 class="content-box-header">
{% trans "Saved Sites For Remote Backup" %} </h3>
<table class="table-spacing" style="width: 100%">
<thead style="color: white; background-color: #0a6ebd">
<tr>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">ID</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">WordPress Title</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
</tr>
</thead>
<tbody>
{% for sub in RemoteBackupsites %}
<tr>
<td style="padding: 13px;">{{ sub.id }}</td>
<td style="padding: 13px;">{{ sub.Title }}</td>
<td style="padding: 13px;">
<button
aria-label=""
onclick="DeleteRemoteBackupsiteNow('{% url 'AddRemoteBackupsite' %}?ID={{ RemoteScheduleID }}&DeleteID={{ sub.id }}')"
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
Delete
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,202 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "File Config - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Backup File Configurations" %}</h2>
</div>
<div ng-controller="BackupSchedule" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans " Schedule Backups" %} <img ng-hide="BackupScheduleLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Schedule Name" %}</label>
<div class="col-sm-6">
<input name="Hostname" type="text" class="form-control" ng-model="ScheduleName"
required>
</div>
</div>
<span style="display: none" id="RemoteConfigID"> {{ RemoteConfigID }}</span>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup Frequency" %}</label>
<div class="col-sm-6">
<select ng-model="Bfrequency"
class="form-control">
<option>30 Minutes</option>
<option>1 Hour</option>
<option>6 Hours</option>
<option>12 Hours</option>
<option>1 Day</option>
<option>3 Days</option>
<option>1 Week</option>
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label>
<div class="col-sm-6">
<select ng-model="Fretention"
class="form-control">
<option>3 Days</option>
<option>1 Week</option>
<option>3 Weeks</option>
<option>1 Month</option>
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup Type" %}</label>
<div class="col-sm-6">
<select ng-model="BackupType"
class="form-control">
<option>Only DataBase</option>
<option>Only Website</option>
<option>Website and Database Both</option>
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="SaveBackupSchedule()"
class="btn btn-primary btn-lg">{% trans "Save Backup Schedule" %}</button>
</div>
</div>
</form>
<h3 class="content-box-header">
{% trans "Configure Backup Schedules" %} </h3>
<table class="table-spacing" style="width: 100%">
<thead style="color: white; background-color: #0a6ebd">
<tr>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">ID</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Schedule Name</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup Frequency</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup File Retention
</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Last Run</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Remote Configuration
</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
</tr>
</thead>
<tbody>
{% for sub in Backupschedule %}
<tr>
<td style="padding: 13px;">{{ sub.id }}</td>
<td style="padding: 13px;">{{ sub.Name }}</td>
<td style="padding: 13px;">{{ sub.Frequency }}</td>
<td style="padding: 13px;">{{ sub.Retention }}</td>
<td style="padding: 13px;">{{ sub.LastRun }}</td>
<td style="padding: 13px;">{{ sub.RemoteConfiguration }}</td>
<td style="padding: 13px;">
<button
aria-label=""
onclick="DeleteBackupfileConfigNow('{% url 'BackupfileConfig' %}?ID={{ RemoteConfigID }}&DeleteID={{ sub.id }}')"
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
Delete
</button>
<button ng-click="getupdateid({{ sub.id }})" data-toggle="modal" data-target="#EidtRemoteShedule"
aria-label=""
type="button" class="btn btn-border btn-alt border-yellow btn-link font-yellow">
Eidt
</button>
<a href="{% url 'AddRemoteBackupsite' %}?ID={{ sub.id }}"
aria-label=""
style="margin-top: 5px;"
type="button" class="btn btn-border btn-alt border-green btn-link font-green">
Add WordPress Sites
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div id="EidtRemoteShedule" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Update Remote Backup Schedules
<img id="containerSettingLoading" src="/static/images/loading.gif"
style="display: none;">
</h4>
</div>
<div class="modal-body">
<form name="containerSettingsForm" action="/" class="form-horizontal">
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup Frequency" %}</label>
<div class="col-sm-6">
<select ng-model="RemoteFrequency"
class="form-control">
<option>30 Minutes</option>
<option>1 Hour</option>
<option>6 Hours</option>
<option>12 Hours</option>
<option>1 Day</option>
<option>3 Days</option>
<option>1 Week</option>
</select>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label>
<div class="col-sm-6">
<select ng-model="RemoteFileretention"
class="form-control">
<option>3 Days</option>
<option>1 Week</option>
<option>3 Weeks</option>
<option>1 Month</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" ng-disabled="savingSettings" class="btn btn-primary"
ng-click="UpdateRemoteschedules()">Save
</button>
<button type="button" ng-disabled="savingSettings" class="btn btn-default"
data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,169 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Remote Backup Configurations - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Remote Backup Configurations" %}</h2>
</div>
<div ng-controller="RemoteBackupConfig" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Configure Remote Backups" %} <img ng-hide="RemoteBackupLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Remote Backup Type" %}</label>
<div class="col-sm-6">
<select ng-model="RemoteBackuptype" ng-change="SelectRemoteBackuptype()"
class="form-control">
<option>SFTP</option>
<option>S3</option>
</select>
</div>
</div>
<div ng-hide="SFTPBackUpdiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Hostname" %}</label>
<div class="col-sm-6">
<input name="Hostname" type="text" class="form-control" ng-model="Hostname"
required>
</div>
</div>
<div ng-hide="SFTPBackUpdiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
<div class="col-sm-6">
<input name="Username" type="text" class="form-control" ng-model="Username"
required>
</div>
</div>
<div ng-hide="SFTPBackUpdiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input name="Password" type="password" class="form-control" ng-model="Password"
required>
</div>
</div>
<div ng-hide="SFTPBackUpdiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "path" %}</label>
<div class="col-sm-6">
<input name="path" type="path" class="form-control" ng-model="path"
required>
</div>
</div>
<div ng-hide="Selectprovider" class="form-group">
<label class="col-sm-3 control-label">{% trans "Choose Provider" %}</label>
<div class="col-sm-6">
<select ng-model="Providervalue" ng-change="SelectProvidertype()"
class="form-control">
<option selected="selected">Amazon</option>
<option>Wasabi</option>
<option>Backblaze</option>
</select>
</div>
</div>
<div ng-hide="S3keyNamediv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
<div class="col-sm-6">
<input name="S3keyName" type="text" class="form-control" ng-model="S3keyName"
required>
</div>
</div>
<div ng-hide="EndpointURLdiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Endpoint URL" %}</label>
<div class="col-sm-6">
<input name="EndpointURL" type="text" class="form-control" ng-model="EndpointURL"
required>
</div>
</div>
<div ng-hide="Accesskeydiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Access Key" %}</label>
<div class="col-sm-6">
<input name="Accesskey" type="text" class="form-control" ng-model="Accesskey"
required>
</div>
</div>
<div ng-hide="SecretKeydiv" class="form-group">
<label class="col-sm-3 control-label">{% trans "Secret Key" %}</label>
<div class="col-sm-6">
<input name="SecretKey" type="password" class="form-control" ng-model="SecretKey"
required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="SaveBackupConfig()"
class="btn btn-primary btn-lg">{% trans "Save Configurations" %}</button>
</div>
</div>
</form>
</div>
<h3 class="content-box-header">
{% trans "Saved Remote Configuration" %} </h3>
<table class="table-spacing" style="width: 100%">
<thead style="color: white; background-color: #0a6ebd">
<tr>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup Type</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">HostName</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Path / Key Name</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
</tr>
</thead>
<tbody>
{% for sub in backupconfigs %}
<tr>
<td style="padding: 13px;">{{ sub.Type }}</td>
<td style="padding: 13px;">{{ sub.HostName }}</td>
<td style="padding: 13px;">{{ sub.Path }}</td>
<td style="padding: 13px;">
<button
aria-label=""
onclick="DeleteBackupConfigNow('{% url 'RemoteBackupConfig' %}?DeleteID={{ sub.id }}')"
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
Delete
</button>
<a href="{% url 'BackupfileConfig' %}?ID={{ sub.id }}"
aria-label=""
type="button" class="btn btn-border btn-alt border-green btn-link font-green">
Schedule Backups
</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}

View File

@@ -102,6 +102,8 @@
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Website
</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Type
</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup Destination
</th>
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action
</th>
@@ -124,6 +126,9 @@
<td style="padding: 13px;">
{{ sub.Backuptype }}
</td>
<td style="padding: 13px;">
{{ sub.BackupDestination }}
</td>
<td style="padding: 13px;">
<a href="{% url 'RestoreHome' %}?BackupID={{ sub.id }}"

View File

@@ -1050,14 +1050,13 @@
<div class="col-md-3 panel-body">
<a href="{$ installMauticURL $}" target="_self"
title="{% trans 'Install Mautic' %}">
<img src="{% static 'images/icons/mautic.png' %}" width="65" class="mr-10">
<img src="{% static 'baseTemplate/images/icons/mautic.png' %}" width="65" class="mr-10">
</a>
<a href="{$ installMauticURL $}" target="_self"
title="{% trans 'Install Mautic' %}">
<span class="h4">{% trans "Mautic" %}</span>
</a>
</div>
</div>
</div>

View File

@@ -23,6 +23,9 @@ urlpatterns = [
url(r'^RestoreBackups$', views.RestoreBackups, name='RestoreBackups'),
url(r'^RestoreHome$', views.RestoreHome, name='RestoreHome'),
url(r'^AutoLogin$', views.AutoLogin, name='AutoLogin'),
url(r'^RemoteBackupConfig$', views.RemoteBackupConfig, name='RemoteBackupConfig'),
url(r'^BackupfileConfig$', views.BackupfileConfig, name='BackupfileConfig'),
url(r'^AddRemoteBackupsite$', views.AddRemoteBackupsite, name='AddRemoteBackupsite'),
###WordPress Ajax
@@ -44,9 +47,12 @@ urlpatterns = [
url(r'^DeploytoProduction', views.DeploytoProduction, name='DeploytoProduction'),
url(r'^WPCreateBackup', views.WPCreateBackup, name='WPCreateBackup'),
url(r'^RestoreWPbackupNow', views.RestoreWPbackupNow, name='RestoreWPbackupNow'),
url(r'^RestoreWPbackupNow', views.RestoreWPbackupNow, name='RestoreWPbackupNow'),
url(r'^dataintegrity', views.dataintegrity, name='dataintegrity'),
url(r'^installwpcore', views.installwpcore, name='installwpcore'),
url(r'^SaveBackupConfig', views.SaveBackupConfig, name='SaveBackupConfig'),
url(r'^SaveBackupSchedule', views.SaveBackupSchedule, name='SaveBackupSchedule'),
url(r'^AddWPsiteforRemoteBackup', views.AddWPsiteforRemoteBackup, name='AddWPsiteforRemoteBackup'),
url(r'^UpdateRemoteschedules', views.UpdateRemoteschedules, name='UpdateRemoteschedules'),

View File

@@ -65,6 +65,40 @@ def RestoreHome(request):
return wm.RestoreHome(request, userID, BackupID)
except KeyError:
return redirect(loadLoginPage)
def RemoteBackupConfig(request):
try:
userID = request.session['userID']
DeleteID = request.GET.get('DeleteID')
wm = WebsiteManager()
return wm.RemoteBackupConfig(request, userID, DeleteID)
except KeyError:
return redirect(loadLoginPage)
def BackupfileConfig(request):
try:
userID = request.session['userID']
ID = request.GET.get('ID')
DeleteID = request.GET.get('DeleteID')
wm = WebsiteManager()
return wm.BackupfileConfig(request, userID, ID, DeleteID)
except KeyError:
return redirect(loadLoginPage)
def AddRemoteBackupsite(request):
try:
userID = request.session['userID']
ID = request.GET.get('ID')
DeleteSiteID = request.GET.get('DeleteID')
wm = WebsiteManager()
return wm.AddRemoteBackupsite(request, userID, ID,DeleteSiteID )
except KeyError:
return redirect(loadLoginPage)
def RestoreBackups(request):
try:
userID = request.session['userID']
@@ -407,6 +441,88 @@ def RestoreWPbackupNow(request):
return redirect(loadLoginPage)
def SaveBackupConfig(request):
try:
userID = request.session['userID']
result = pluginManager.preWebsiteCreation(request)
if result != 200:
return result
wm = WebsiteManager()
coreResult = wm.SaveBackupConfig(userID, json.loads(request.body))
result = pluginManager.postWebsiteCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def SaveBackupSchedule(request):
try:
userID = request.session['userID']
result = pluginManager.preWebsiteCreation(request)
if result != 200:
return result
wm = WebsiteManager()
coreResult = wm.SaveBackupSchedule(userID, json.loads(request.body))
result = pluginManager.postWebsiteCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def AddWPsiteforRemoteBackup(request):
try:
userID = request.session['userID']
result = pluginManager.preWebsiteCreation(request)
if result != 200:
return result
wm = WebsiteManager()
coreResult = wm.AddWPsiteforRemoteBackup(userID, json.loads(request.body))
result = pluginManager.postWebsiteCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def UpdateRemoteschedules(request):
try:
userID = request.session['userID']
result = pluginManager.preWebsiteCreation(request)
if result != 200:
return result
wm = WebsiteManager()
coreResult = wm.UpdateRemoteschedules(userID, json.loads(request.body))
result = pluginManager.postWebsiteCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def installwpcore(request):
try:
userID = request.session['userID']

View File

@@ -4,6 +4,7 @@ import os.path
import sys
import django
from databases.models import Databases
from plogical.httpProc import httpProc
sys.path.append('/usr/local/CyberCP')
@@ -12,7 +13,7 @@ django.setup()
import json
from plogical.acl import ACLManager
import plogical.CyberCPLogFileWriter as logging
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup, RemoteBackupConfig,RemoteBackupSchedule, RemoteBackupsites
from plogical.virtualHostUtilities import virtualHostUtilities
import subprocess
import shlex
@@ -24,6 +25,7 @@ from plogical.mailUtilities import mailUtilities
from random import randint
import time
import re
import boto3
from plogical.childDomain import ChildDomainManager
from math import ceil
from plogical.alias import AliasManager
@@ -202,6 +204,123 @@ class WebsiteManager:
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None ):
Data = {}
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
try:
if DeleteID != None:
BackupconfigDelete = RemoteBackupConfig.objects.get(pk=DeleteID)
BackupconfigDelete.delete()
except:
pass
if ACLManager.CheckForPremFeature('wp-manager'):
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
allcon = RemoteBackupConfig.objects.all()
Data['backupconfigs'] =[]
for i in allcon:
configr = json.loads(i.config)
if i.configtype == "SFTP":
Data['backupconfigs'].append({
'id': i.pk,
'Type': i.configtype,
'HostName': configr['Hostname'],
'Path': configr['Path']
})
elif i.configtype == "S3":
Provider = configr['Provider']
if Provider == "Backblaze":
Data['backupconfigs'].append({
'id': i.pk,
'Type': i.configtype,
'HostName': Provider,
'Path': configr['S3keyname']
})
else:
Data['backupconfigs'].append({
'id': i.pk,
'Type': i.configtype,
'HostName': Provider,
'Path': configr['S3keyname']
})
proc = httpProc(request, 'websiteFunctions/RemoteBackupConfig.html',
Data, 'createWebsite')
return proc.render()
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None ):
Data = {}
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
Data['RemoteConfigID'] = RemoteConfigID
RemoteConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
try:
if DeleteID != None:
RemoteBackupConfigDelete = RemoteBackupSchedule.objects.get(pk=DeleteID)
RemoteBackupConfigDelete.delete()
except:
pass
if ACLManager.CheckForPremFeature('wp-manager'):
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj)
Data['Backupschedule'] = []
for i in allsechedule:
lastrun = i.lastrun
LastRun = time.strftime('%Y-%m-%d', time.localtime(float(lastrun)))
Data['Backupschedule'].append({
'id': i.pk,
'Name': i.Name,
'RemoteConfiguration': i.RemoteBackupConfig.configtype,
'Retention': i.fileretention,
'Frequency': i.timeintervel,
'LastRun': LastRun
})
proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html',
Data, 'createWebsite')
return proc.render()
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
def AddRemoteBackupsite(self, request=None, userID=None, RemoteScheduleID=None , DeleteSiteID=None):
Data = {}
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
Data['RemoteScheduleID'] = RemoteScheduleID
RemoteBackupScheduleobj= RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
try:
if DeleteSiteID != None:
RemoteBackupsitesDelete = RemoteBackupsites.objects.get(pk=DeleteSiteID)
RemoteBackupsitesDelete.delete()
except:
pass
if ACLManager.CheckForPremFeature('wp-manager'):
Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj)
Data['RemoteBackupsites'] = []
for i in allRemoteBackupsites:
wpsite = WPSites.objects.get(pk=i.WPsites)
Data['RemoteBackupsites'].append({
'id': i.pk,
'Title': wpsite.title,
})
proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html',
Data, 'createWebsite')
return proc.render()
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
def RestoreBackups(self, request=None, userID=None, DeleteID=None):
Data = {}
currentACL = ACLManager.loadedACL(userID)
@@ -254,6 +373,7 @@ class WebsiteManager:
config = sub.config
conf = json.loads(config)
Backuptype = conf['Backuptype']
BackupDestination = conf['BackupDestination']
except:
Backuptype = "Backup type not exists"
@@ -261,7 +381,8 @@ class WebsiteManager:
Data['job'].append({
'id': sub.id,
'title': web,
'Backuptype': Backuptype
'Backuptype': Backuptype,
'BackupDestination': BackupDestination
})
@@ -985,23 +1106,23 @@ class WebsiteManager:
DesSiteID = data['DesSite']
try:
bwp = WPSites.objects.get(pk=int(backupid))
if ACLManager.checkOwnership(bwp.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
except:
pass
dwp = WPSites.objects.get(pk=int(DesSiteID))
if ACLManager.checkOwnership(dwp.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
# try:
#
# bwp = WPSites.objects.get(pk=int(backupid))
#
# if ACLManager.checkOwnership(bwp.owner.domain, admin, currentACL) == 1:
# pass
# else:
# return ACLManager.loadError()
#
# except:
# pass
#
# dwp = WPSites.objects.get(pk=int(DesSiteID))
# if ACLManager.checkOwnership(dwp.owner.domain, admin, currentACL) == 1:
# pass
# else:
# return ACLManager.loadError()
Domain = data['Domain']
@@ -1033,6 +1154,206 @@ class WebsiteManager:
return HttpResponse(json_data)
def SaveBackupConfig(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
ConfigType = data['type']
if ConfigType == 'SFTP':
Hname = data['Hname']
Uname = data['Uname']
Passwd = data['Passwd']
path = data['path']
config = {
"Hostname": Hname,
"Username": Uname,
"Password": Passwd,
"Path": path
}
elif ConfigType == "S3":
Provider = data['Provider']
if Provider == "Backblaze":
S3keyname = data['S3keyname']
SecertKey = data['SecertKey']
AccessKey = data['AccessKey']
EndUrl = data['EndUrl']
config = {
"Provider": Provider,
"S3keyname": S3keyname,
"SecertKey": SecertKey,
"AccessKey": AccessKey,
"EndUrl": EndUrl
}
else:
S3keyname = data['S3keyname']
SecertKey = data['SecertKey']
AccessKey = data['AccessKey']
config = {
"Provider": Provider,
"S3keyname": S3keyname,
"SecertKey": SecertKey,
"AccessKey": AccessKey,
}
mkobj = RemoteBackupConfig(owner=admin, configtype=ConfigType, config=json.dumps(config))
mkobj.save()
time.sleep(1)
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 SaveBackupSchedule(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
FileRetention = data['FileRetention']
Backfrequency = data['Backfrequency']
ScheduleName = data['ScheduleName']
RemoteConfigID = data['RemoteConfigID']
BackupType = data['BackupType']
RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
Rconfig = json.loads(RemoteBackupConfigobj.config)
provider = Rconfig['Provider']
if provider == "Backblaze":
EndURl = Rconfig['EndUrl']
elif provider == "Amazon":
EndURl = "https://s3.us-east-1.amazonaws.com"
elif provider == "Wasabi":
EndURl = "https://s3.wasabisys.com"
AccessKey = Rconfig['AccessKey']
SecertKey = Rconfig['SecertKey']
session = boto3.session.Session()
client = session.client(
's3',
endpoint_url=EndURl,
aws_access_key_id=AccessKey,
aws_secret_access_key=SecertKey,
verify=False
)
############Creating Bucket
BucketName = randomPassword.generate_pass().lower()
try:
client.create_bucket(Bucket=BucketName)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile("Creating Bucket Error: %s"%str(msg))
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
config = {
'BackupType': BackupType,
'BucketName': BucketName
}
svobj = RemoteBackupSchedule( RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
timeintervel=Backfrequency, fileretention=FileRetention, config=json.dumps(config),
lastrun=str(time.time()))
svobj.save()
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 AddWPsiteforRemoteBackup(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
WPid = data['WpsiteID']
RemoteScheduleID = data['RemoteScheduleID']
wpsiteobj = WPSites.objects.get(pk=WPid)
WPpath = wpsiteobj.path
VHuser = wpsiteobj.owner.externalApp
PhpVersion = wpsiteobj.owner.phpSelection
php = PHPManager.getPHPString(PhpVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
####Get DB Name
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
VHuser, FinalPHPPath, WPpath)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if stdout.find('Error:') > -1:
raise BaseException(stdout)
else:
Finaldbname = stdout.rstrip("\n")
## Get DB obj
try:
DBobj = Databases.objects.get(dbName=Finaldbname)
except:
raise BaseException(str("DataBase Not Found"))
RemoteScheduleIDobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
svobj = RemoteBackupsites( owner=RemoteScheduleIDobj, WPsites = WPid, database = DBobj.pk)
svobj.save()
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 UpdateRemoteschedules(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
ScheduleID = data['ScheduleID']
Frequency = data['Frequency']
FileRetention = data['FileRetention']
scheduleobj = RemoteBackupSchedule.objects.get(pk=ScheduleID)
scheduleobj.timeintervel = Frequency
scheduleobj.fileretention = FileRetention
scheduleobj.save()
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 installwpcore(self, userID=None, data=None):
try: