combine changes from @spyngamerman into final package

This commit is contained in:
Usman Nasir
2019-10-09 12:43:38 +05:00
parent 1eae822985
commit 8eae731cc1
45 changed files with 248 additions and 109 deletions

View File

@@ -12,7 +12,7 @@ except:
pass
import threading as multi
from plogical.processUtilities import ProcessUtilities
from models import IncJob, JobSnapshots
from IncBackups.models import IncJob, JobSnapshots
from websiteFunctions.models import Websites
import plogical.randomPassword as randomPassword
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
@@ -316,7 +316,7 @@ class IncJobs(multi.Thread):
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52/meta.xml -- metaPath
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018/meta.xml -- metaPath
metaPath = '/home/cyberpanel/%s' % (str(randint(1000, 9999)))

View File

@@ -0,0 +1,136 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Schedule Back up - 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 "Schedule Back up" %} - <a target="_blank" href="http://go.cyberpanel.net/remote-backup"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Remote Backups" %}</span></a></h2>
<p>{% trans "On this page you can schedule Back ups to localhost or remote server (If you have added one)." %}</p>
</div>
<div ng-controller="scheduleBackup" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Schedule Back up" %} <img ng-hide="scheduleBackupLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Destination" %}</label>
<div class="col-sm-6">
<select ng-change="scheduleFreqView()" ng-model="backupDest" class="form-control">
{% for items in destinations %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="scheduleFreq" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Frequency" %}</label>
<div class="col-sm-6">
<select ng-change="scheduleBtnView()" ng-model="backupFreq" class="form-control">
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
</div>
<div ng-hide="localPath" class="form-group">
<label class="col-sm-3 control-label">{% trans "Local Path" %}</label>
<div class="col-sm-6">
<input name="dom" type="text" class="form-control" ng-model="localPathValue"
placeholder="{% trans "Local directory where backups will be moved after creation." %}"
required>
</div>
</div>
<div ng-hide="scheduleBtn" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="addSchedule()"
class="btn btn-primary btn-lg btn-block">{% trans "Add Destination" %}</button>
</div>
</div>
<!------ List of Destinations --------------->
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="canNotAddSchedule" class="alert alert-danger">
<p>{% trans "Cannot add schedule. Error message:" %} {$ errorMessage $} </p>
</div>
<div ng-hide="scheduleAdded" class="alert alert-success">
<p>{% trans "Schedule Added" %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<table class="table">
<thead>
<tr>
<th>{% trans "ID" %}</th>
<th>{% trans "Destination" %}</th>
<th>{% trans "Frequency" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in records track by $index">
<td ng-bind="record.id"></td>
<td ng-bind="record.destLoc"></td>
<td ng-bind="record.frequency"></td>
<td ng-click="delSchedule(record.destLoc,record.frequency)"><img
src="{% static 'images/delete.png' %}"></td>
</tr>
</tbody>
</table>
</div>
</div>
<!------ List of records --------------->
</form>
</div>
</div>
</div>
</div>
{% endblock %}

0
IncBackups/templates/IncBackups/createBackup.html Normal file → Executable file
View File

View File

@@ -13,4 +13,5 @@ urlpatterns = [
url(r'^deleteBackup$', views.deleteBackup, name='deleteBackupInc'),
url(r'^fetchRestorePoints$', views.fetchRestorePoints, name='fetchRestorePointsInc'),
url(r'^restorePoint$', views.restorePoint, name='restorePointInc'),
url(r'^scheduleBackups$', views.scheduleBackups, name='scheduleBackupsInc'),
]

View File

@@ -541,3 +541,28 @@ def restorePoint(request):
final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def scheduleBackups(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0:
return ACLManager.loadError()
websitesName = ACLManager.findAllSites(currentACL, userID)
destinations = []
destinations.append('local')
path = '/home/cyberpanel/sftp'
for items in os.listdir(path):
destinations.append('sftp:%s' % (items))
for items in os.listdir(path):
destinations.append('s3:s3.amazonaws.com/%s' % (items))
return defRenderer(request, 'IncBackups/scheduleBackups.html', {'websiteList': websitesName, 'destinations': destinations})
except BaseException, msg:
return HttpResponse(str(msg))

View File

@@ -24,7 +24,6 @@ Webhosting control panel that uses OpenLiteSpeed as web server.
* PHP 7.0
* PHP 7.1
* PHP 7.2
* PHP 7.3
# Installation Instructions

0
backup/backupManager.py Normal file → Executable file
View File

3
baseTemplate/templates/baseTemplate/index.html Normal file → Executable file
View File

@@ -601,6 +601,9 @@
<li class="restoreBackup"><a href="{% url 'backupDestinationsInc' %}"
title="{% trans 'Restore Back up' %}"><span>{% trans "Add Destinations" %}</span></a>
</li>
<li class="restoreBackup"><a href="{% url 'scheduleBackupsInc' %}"
title="{% trans 'Schedule Back ups' %}"><span>{% trans "Schedule Back ups" %}</span></a>
</li>
</ul>
</div><!-- .sidebar-submenu -->

0
cli/cliLogger.py Normal file → Executable file
View File

0
emailPremium/templates/emailPremium/emailPage.html Normal file → Executable file
View File

0
emailPremium/templates/emailPremium/listDomains.html Normal file → Executable file
View File

0
emailPremium/templates/emailPremium/policyServer.html Normal file → Executable file
View File

0
firewall/templates/firewall/index.html Normal file → Executable file
View File

47
install/install.py Normal file → Executable file
View File

@@ -37,6 +37,7 @@ def generate_pass(length=14):
password.append(a_char)
return ''.join(password)
def check_prev_char(password, current_char_set):
"""Function to ensure that there are no consecutive
UPPERCASE/lowercase/numbers/special-characters."""
@@ -59,6 +60,7 @@ def check_prev_char(password, current_char_set):
centos = 0
ubuntu = 1
def get_distro():
distro = -1
distro_file = ""
@@ -175,7 +177,6 @@ class preFlightsChecks:
'mountTemp',
1, 0, os.EX_OSERR)
tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
varTmp = "/tmp /var/tmp none bind 0 0\n"
@@ -333,7 +334,6 @@ class preFlightsChecks:
else:
command = "adduser docker"
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel',
1, 0, os.EX_OSERR)
@@ -353,7 +353,6 @@ class preFlightsChecks:
'add user cyberpanel',
1, 0, os.EX_OSERR)
###
command = "mkdir -p /etc/letsencrypt/live/"
@@ -1016,8 +1015,6 @@ class preFlightsChecks:
else:
writeDataToFile.writelines(items)
if self.distro == ubuntu:
os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
@@ -1029,7 +1026,6 @@ class preFlightsChecks:
### Applying migrations
os.chdir("CyberCP")
command = "/usr/local/CyberCP/bin/python2 manage.py makemigrations"
@@ -1043,7 +1039,6 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Migrate', 1, 1, os.EX_OSERR)
if not os.path.exists("/usr/local/CyberCP/public"):
os.mkdir("/usr/local/CyberCP/public")
@@ -1144,23 +1139,26 @@ class preFlightsChecks:
'Change permissions for client.', 1, 0, os.EX_OSERR)
files = ['/etc/yum.repos.d/MariaDB.repo', '/etc/pdns/pdns.conf', '/etc/systemd/system/lscpd.service',
'/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf', '/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/usr/local/lsws/conf/httpd_config.xml', '/usr/local/lsws/conf/modsec.conf', '/usr/local/lsws/conf/httpd.conf']
'/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/usr/local/lsws/conf/httpd_config.xml',
'/usr/local/lsws/conf/modsec.conf', '/usr/local/lsws/conf/httpd.conf']
for items in files:
command = 'chmod 644 %s' % (items)
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for client.', 1, 0, os.EX_OSERR)
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf', '/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf', '/etc/powerdns/pdns.conf']
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf',
'/etc/powerdns/pdns.conf']
for items in impFile:
command = 'chmod 600 %s' % (items)
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for client.', 1, 0, os.EX_OSERR)
command = 'chmod 640 /etc/postfix/*.cf'
subprocess.call(command, shell=True)
@@ -1259,7 +1257,6 @@ class preFlightsChecks:
###################################################### Email setup
def install_postfix_davecot(self):
self.stdOut("Install dovecot - first remove postfix")
@@ -1275,14 +1272,12 @@ enabled=1"""
writeToFile.write(content)
writeToFile.close()
try:
if self.distro == centos:
command = 'yum -y install http://cyberpanel.sh/gf-release-latest.gf.el7.noarch.rpm'
subprocess.call(shlex.split(command))
command = 'yum remove postfix -y'
else:
command = 'apt-get -y remove postfix'
@@ -1372,7 +1367,6 @@ enabled=1"""
preFlightsChecks.stdOut("Dovecot and Dovecot-MySQL successfully installed!")
break
if self.distro != centos:
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
subprocess.call(command, shell=True)
@@ -1601,7 +1595,6 @@ enabled=1"""
if os.path.exists(davecotmysql):
os.remove(davecotmysql)
###############Getting SSL
count = 0
@@ -2104,7 +2097,6 @@ enabled=1"""
break
##
count = 0
while (1):
@@ -2155,7 +2147,6 @@ enabled=1"""
##
count = 0
while (1):
@@ -2354,8 +2345,6 @@ enabled=1"""
#############
count = 0
while (1):
@@ -2383,7 +2372,6 @@ enabled=1"""
'rainlooop data folder',
1, 0, os.EX_OSERR)
### Enable sub-folders
command = "mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/"
@@ -2429,7 +2417,6 @@ imap_folder_list_limit = 0
###################################################### Email setup ends!
def reStartLiteSpeed(self):
try:
count = 0
@@ -2491,7 +2478,6 @@ imap_folder_list_limit = 0
'Install FirewallD',
1, 0, os.EX_OSERR)
######
if self.distro == centos:
# Not available in ubuntu
@@ -2510,7 +2496,6 @@ imap_folder_list_limit = 0
'Restart FirewallD',
1, 0, os.EX_OSERR)
##########
command = 'systemctl enable firewalld'
@@ -2518,8 +2503,6 @@ imap_folder_list_limit = 0
'Install FirewallD',
1, 0, os.EX_OSERR)
FirewallUtilities.addRule("tcp", "8090")
FirewallUtilities.addRule("tcp", "80")
FirewallUtilities.addRule("tcp", "443")
@@ -2550,7 +2533,6 @@ imap_folder_list_limit = 0
## from here
def installLSCPD(self):
try:
@@ -2578,13 +2560,11 @@ imap_folder_list_limit = 0
'Install LSCPD',
1, 1, os.EX_OSERR)
command = 'tar zxf lscp.tar.gz -C /usr/local/'
preFlightsChecks.call(command, self.distro, '[installLSCPD]',
'Install LSCPD',
1, 1, os.EX_OSERR)
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 /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem'
preFlightsChecks.call(command, self.distro, '[installLSCPD]',
'Install LSCPD',
@@ -2834,7 +2814,6 @@ imap_folder_list_limit = 0
writeToFile.write("abc\n")
writeToFile.close()
command = "chmod 600 " + path
cmd = shlex.split(command)
res = subprocess.call(cmd)
@@ -3263,6 +3242,7 @@ imap_folder_list_limit = 0
preFlightsChecks.call(command, self.distro, '[installPYDNS]',
'Install PYDNS',
1, 0, os.EX_OSERR)
def installDockerPY(self):
command = "pip install docker"
preFlightsChecks.call(command, self.distro, '[installDockerPY]',
@@ -3530,7 +3510,6 @@ milter_default_action = accept
##
count = 0
while (1):
command = "pip install virtualenv"
@@ -3801,7 +3780,6 @@ def main():
else:
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns)
checks.setupPHPAndComposer()
checks.fix_selinux_issue()
checks.install_psmisc()
@@ -3822,7 +3800,6 @@ def main():
checks.installFirewalld()
checks.install_python_requests()
checks.install_default_keys()
@@ -3853,7 +3830,6 @@ def main():
checks.setupLSCPDDaemon()
checks.fixCyberPanelPermissions()
if args.postfix != None:
checks.enableDisableEmail(args.postfix)
else:
@@ -3872,7 +3848,6 @@ def main():
preFlightsChecks.stdOut("Pure-FTPD will be installed and enabled.")
checks.enableDisableFTP('On', distro)
checks.setUpFirstAccount()
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")
checks.installation_successfull()

0
install/installLog.py Normal file → Executable file
View File

View File

@@ -3692,7 +3692,7 @@ msgstr "SpamAssassin конфигурация е успешно променен
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Email лимити документация"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3835,7 +3835,7 @@ msgstr " uspješno je kreiran."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Email logovi"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3773,7 +3773,7 @@ msgstr " 已成功创建."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Email日志"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3780,7 +3780,7 @@ msgstr ""
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr ""
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3706,7 +3706,7 @@ msgstr "Les configurations de SpamAssassin ont été enregistrées avec succès.
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Limites de messagerie documentations"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3848,7 +3848,7 @@ msgstr "δημιουργήθηκε με επιτυχία."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Αρχεία καταγραφής Email "
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3437,7 +3437,7 @@ msgstr ""
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr ""
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3803,7 +3803,7 @@ msgstr "Le configurazioni di SpamAssassin sono state salvate correttamente."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Documentazione Limiti Email"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3682,7 +3682,7 @@ msgstr "SpamAssassin 設定が保存されました。"
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Eメールの制限ドキュメント"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3676,7 +3676,7 @@ msgstr "Pomyślnie zapisano konfigurację SpamAssassin."
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Limity poczty dokumentacja"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3845,7 +3845,7 @@ msgstr " foi criado com sucesso."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Logs de E-Mail"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3801,7 +3801,7 @@ msgstr "Успешно запущен процесс резервного коп
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Лог-журнал Эл.почты"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3775,7 +3775,7 @@ msgstr "Yedekleme işlemi başarıyla başlatıldı."
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Email Logs"
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Eposta günlükleri"
#: emailPremium/templates/emailPremium/emailLimits.html:14

View File

@@ -3674,7 +3674,7 @@ msgstr "Đã lưu thành công cấu hình SpamAssassin."
#: emailPremium/templates/emailPremium/emailPage.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
msgid "Email Limits Docs"
msgid "Emai Limits Docs"
msgstr "Tài liệu giới hạn Emai"
#: emailPremium/templates/emailPremium/emailLimits.html:14

0
loginSystem/templates/loginSystem/login.html Normal file → Executable file
View File

0
plogical/CyberCPLogFileWriter.py Normal file → Executable file
View File

0
plogical/backupSchedule.py Normal file → Executable file
View File

0
plogical/backupScheduleLocal.py Normal file → Executable file
View File

0
plogical/backupUtilities.py Normal file → Executable file
View File

6
plogical/csf.py Normal file → Executable file
View File

@@ -497,7 +497,7 @@ class CSF(multi.Thread):
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")
@staticmethod
def run_command(command):
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
@@ -507,8 +507,8 @@ class CSF(multi.Thread):
@staticmethod
def checkIP(ipAddress):
try:
command = "sudo csf -g ' + ipAddress.split()
for line in run_command(command):
command = "sudo csf -g ' + ipAddress.split()"
for line in CSF.run_command(command):
print(line)
except BaseException, msg:

0
plogical/mailUtilities.py Normal file → Executable file
View File

0
plogical/mysqlUtilities.py Normal file → Executable file
View File

0
plogical/processUtilities.py Normal file → Executable file
View File

0
plogical/remoteBackup.py Normal file → Executable file
View File

0
plogical/remoteTransferUtilities.py Normal file → Executable file
View File

0
plogical/upgrade.py Normal file → Executable file
View File

0
pluginInstaller/pluginInstaller.py Normal file → Executable file
View File

0
postfixSenderPolicy/accept_traffic.py Normal file → Executable file
View File

0
s3Backups/s3Backups.py Normal file → Executable file
View File