Ubuntu support

This commit is contained in:
usmannasir
2018-11-06 00:19:58 +05:00
parent c66c71e348
commit 00d9e7f942
16 changed files with 313 additions and 394 deletions

View File

@@ -41,7 +41,7 @@ app.filter('getwebsitename', function() {
if(domain !== undefined) { if(domain !== undefined) {
domain = domain.replace("-", ""); domain = domain.replace(/-/g, '');
var domainName = domain.split("."); var domainName = domain.split(".");

View File

@@ -3,9 +3,6 @@
*/ */
/* Java script code to create database */ /* Java script code to create database */
app.controller('createDatabase', function($scope,$http) { app.controller('createDatabase', function($scope,$http) {
@@ -38,8 +35,7 @@ app.controller('createDatabase', function($scope,$http) {
// getting website username // getting website username
webUserName = databaseWebsite.replace("-", ""); webUserName = databaseWebsite.replace(/-/g, '');
webUserName = webUserName.split(".")[0]; webUserName = webUserName.split(".")[0];
if(webUserName.length > 5){ if(webUserName.length > 5){
@@ -54,7 +50,7 @@ app.controller('createDatabase', function($scope,$http) {
databaseWebsite:databaseWebsite, databaseWebsite:databaseWebsite,
dbName:dbName, dbName:dbName,
dbUsername:dbUsername, dbUsername:dbUsername,
dbPassword:dbPassword, dbPassword:dbPassword
}; };
var config = { var config = {
@@ -281,7 +277,6 @@ app.controller('deleteDatabase', function($scope,$http) {
/* Java script code to delete database ends here */ /* Java script code to delete database ends here */
/* Java script code to list databases */ /* Java script code to list databases */

View File

@@ -4,10 +4,10 @@ urlpatterns = [
url(r'^$', views.emailMarketing, name='emailMarketing'), url(r'^$', views.emailMarketing, name='emailMarketing'),
url(r'^fetchUsers$', views.fetchUsers, name='fetchUsers'), url(r'^fetchUsers$', views.fetchUsers, name='fetchUsers'),
url(r'^enableDisableMarketing$', views.enableDisableMarketing, name='enableDisableMarketing'), url(r'^enableDisableMarketing$', views.enableDisableMarketing, name='enableDisableMarketing'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/emailLists$', views.createEmailList, name='createEmailList'), url(r'^(?P<domain>(.*))/emailLists$', views.createEmailList, name='createEmailList'),
url(r'^submitEmailList$', views.submitEmailList, name='submitEmailList'), url(r'^submitEmailList$', views.submitEmailList, name='submitEmailList'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/manageLists$', views.manageLists, name='manageLists'), url(r'^(?P<domain>(.*))/manageLists$', views.manageLists, name='manageLists'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/manageSMTP$', views.manageSMTP, name='manageSMTP'), url(r'^(?P<domain>(.*))/manageSMTP$', views.manageSMTP, name='manageSMTP'),
url(r'^fetchEmails$', views.fetchEmails, name='fetchEmails'), url(r'^fetchEmails$', views.fetchEmails, name='fetchEmails'),
url(r'^deleteList$', views.deleteList, name='deleteList'), url(r'^deleteList$', views.deleteList, name='deleteList'),
url(r'^emailVerificationJob$', views.emailVerificationJob, name='emailVerificationJob'), url(r'^emailVerificationJob$', views.emailVerificationJob, name='emailVerificationJob'),

View File

@@ -8,7 +8,6 @@ urlpatterns = [
url(r'^getFurtherDomains$', views.getFurtherDomains, name='getFurtherDomains'), url(r'^getFurtherDomains$', views.getFurtherDomains, name='getFurtherDomains'),
url(r'^enableDisableEmailLimits$', views.enableDisableEmailLimits, name='enableDisableEmailLimits'), url(r'^enableDisableEmailLimits$', views.enableDisableEmailLimits, name='enableDisableEmailLimits'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.emailLimits, name='emailLimits'),
url(r'^changeDomainLimit$', views.changeDomainLimit, name='changeDomainLimit'), url(r'^changeDomainLimit$', views.changeDomainLimit, name='changeDomainLimit'),
url(r'^getFurtherEmail$', views.getFurtherEmail, name='getFurtherEmail'), url(r'^getFurtherEmail$', views.getFurtherEmail, name='getFurtherEmail'),
@@ -35,6 +34,8 @@ urlpatterns = [
url(r'^savePolicyServerStatus$', views.savePolicyServerStatus, name='savePolicyServerStatus'), url(r'^savePolicyServerStatus$', views.savePolicyServerStatus, name='savePolicyServerStatus'),
url(r'^(?P<domain>(.*))$', views.emailLimits, name='emailLimits'),
] ]

View File

@@ -14,7 +14,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader, $w
var editor = ace.edit("htmlEditorContent"); var editor = ace.edit("htmlEditorContent");
var aceEditorMode = ''; var aceEditorMode = '';
var domainName = window.location.pathname.split("/")[2]; var domainName = $("#domainNameInitial").text();
var domainRandomSeed = ""; var domainRandomSeed = "";
var homePathBack = "/home/"+domainName; var homePathBack = "/home/"+domainName;

View File

@@ -40,7 +40,7 @@
<!--- navigation bar ----> <!--- navigation bar ---->
<nav id="navBar" class="navbar navbar-expand-lg navbar-light bg-light"> <nav id="navBar" class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"><img id="logo" src="{% static 'filemanager/images/fileManager.png' %}">{% trans " File Manager" %} </a> <a class="navbar-brand" href="#"><img id="logo" src="{% static 'filemanager/images/fileManager.png' %}">{% trans " File Manager" %} <span style="display: none" id="domainNameInitial">{{ domainName }}</span></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>

View File

@@ -2,10 +2,10 @@ from django.conf.urls import url
import views import views
urlpatterns = [ urlpatterns = [
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.loadFileManagerHome, name='loadFileManagerHome'), url(r'^changePermissions$',views.changePermissions, name='changePermissions'),
url(r'^changePermissions',views.changePermissions, name='changePermissions'), url(r'^downloadFile$',views.downloadFile, name='downloadFile'),
url(r'^downloadFile',views.downloadFile, name='downloadFile'), url(r'^createTemporaryFile$',views.createTemporaryFile, name='createTemporaryFile'),
url(r'^createTemporaryFile',views.createTemporaryFile, name='createTemporaryFile'), url(r'^(?P<domain>(.*))$', views.loadFileManagerHome, name='loadFileManagerHome'),
] ]

View File

@@ -25,7 +25,7 @@ def loadFileManagerHome(request,domain):
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
if ACLManager.checkOwnership(domain, admin, currentACL) == 1: if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
return render(request, 'filemanager/index.html') return render(request, 'filemanager/index.html', {'domainName': domain})
else: else:
return ACLManager.loadError() return ACLManager.loadError()
else: else:

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

@@ -9,7 +9,6 @@ from firewallUtilities import FirewallUtilities
import time import time
import string import string
import random import random
import socket
import errno import errno
from os.path import * from os.path import *
from stat import * from stat import *
@@ -17,12 +16,12 @@ from stat import *
# There can not be peace without first a great suffering. # There can not be peace without first a great suffering.
#distros #distros
centos=0 centos=0
ubuntu=1 ubuntu=1
class preFlightsChecks: class preFlightsChecks:
cyberPanelMirror = "mirror.cyberpanel.net/pip" cyberPanelMirror = "mirror.cyberpanel.net/pip"
def __init__(self,rootPath,ip,path,cwd,cyberPanelPath, distro): def __init__(self,rootPath,ip,path,cwd,cyberPanelPath, distro):
@@ -41,11 +40,32 @@ class preFlightsChecks:
print("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] " + message + "\n") print("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] " + message + "\n")
print ("[" + time.strftime( print ("[" + time.strftime(
"%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n")
if log: if log:
logging.InstallLog.writeToFile(message) logging.InstallLog.writeToFile(message)
if do_exit: if do_exit:
sys.exit(code) sys.exit(code)
def checkIfSeLinuxDisabled(self):
try:
command = "sestatus"
output = subprocess.check_output(shlex.split(command))
if output.find("disabled") > -1 or output.find("permissive") > -1:
logging.InstallLog.writeToFile("SELinux Check OK. [checkIfSeLinuxDisabled]")
preFlightsChecks.stdOut("SELinux Check OK.")
return 1
else:
logging.InstallLog.writeToFile("SELinux is enabled, please disable SELinux and restart the installation!")
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0)
except BaseException,msg:
logging.InstallLog.writeToFile(str(msg) + "[checkIfSeLinuxDisabled]")
logging.InstallLog.writeToFile("SELinux Check OK. [checkIfSeLinuxDisabled]")
preFlightsChecks.stdOut("SELinux Check OK.")
return 1
def checkPythonVersion(self): def checkPythonVersion(self):
if sys.version_info[0] == 2 and sys.version_info[1] == 7: if sys.version_info[0] == 2 and sys.version_info[1] == 7:
return 1 return 1
@@ -54,11 +74,10 @@ class preFlightsChecks:
os._exit(0) os._exit(0)
def setup_account_cyberpanel(self): def setup_account_cyberpanel(self):
self.stdOut("Setup Cyberpanel account")
try: try:
count = 0
if self.distro == centos: if self.distro == centos:
count = 0
while (1): while (1):
command = "yum install sudo -y" command = "yum install sudo -y"
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -116,9 +135,11 @@ class preFlightsChecks:
if res == 1: if res == 1:
count = count + 1 count = count + 1
preFlightsChecks.stdOut("Not able to add user cyberpanel to system, trying again, try number: " + str(count) + "\n") preFlightsChecks.stdOut(
"Not able to add user cyberpanel to system, trying again, try number: " + str(count) + "\n")
if count == 3: if count == 3:
logging.InstallLog.writeToFile("We are not able add user cyberpanel to system, exiting the installer. [setup_account_cyberpanel]") logging.InstallLog.writeToFile(
"We are not able add user cyberpanel to system, exiting the installer. [setup_account_cyberpanel]")
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
@@ -168,15 +189,24 @@ class preFlightsChecks:
############################### ###############################
count = 0 count = 0
self.stdOut("Create /etc/letsencrypt directory")
try: while (1):
os.mkdir("/etc/letsencrypt")
except OSError as e: command = "mkdir /etc/letsencrypt"
if e.errno != errno.EEXIST:
self.stdOut("Error creating /etc/letsencrypt directory: " + str(e) + cmd = shlex.split(command)
" Installer can continue without this [setup_account_cyberpanel] ",1)
res = subprocess.call(cmd)
if res == 1:
count = count + 1
preFlightsChecks.stdOut("We are trying to create Let's Encrypt directory to store SSLs, trying again, try number: " + str(count))
if count == 3:
logging.InstallLog.writeToFile("Failed to create Let's Encrypt directory to store SSLs. Installer can continue without this.. [setup_account_cyberpanel]")
else: else:
pass logging.InstallLog.writeToFile("Successfully created Let's Encrypt directory!")
preFlightsChecks.stdOut("Successfully created Let's Encrypt directory!")
break
## ##
@@ -227,7 +257,8 @@ class preFlightsChecks:
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res != 0: if res != 0:
logging.InstallLog.writeToFile("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:" logging.InstallLog.writeToFile(
"Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"
" Error #" + str(res)) " Error #" + str(res))
preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:" preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"
" Error #" + str(res)) " Error #" + str(res))
@@ -274,8 +305,6 @@ class preFlightsChecks:
logging.InstallLog.writeToFile("CyberPanel Repo added!") logging.InstallLog.writeToFile("CyberPanel Repo added!")
preFlightsChecks.stdOut("CyberPanel Repo added!") preFlightsChecks.stdOut("CyberPanel Repo added!")
break break
return 0
def enableEPELRepo(self): def enableEPELRepo(self):
try: try:
@@ -314,7 +343,6 @@ class preFlightsChecks:
return 1 return 1
def install_pip(self): def install_pip(self):
self.stdOut("Install pip") self.stdOut("Install pip")
count = 0 count = 0
@@ -337,7 +365,6 @@ class preFlightsChecks:
preFlightsChecks.stdOut("PIP successfully installed!") preFlightsChecks.stdOut("PIP successfully installed!")
break break
def install_python_dev(self): def install_python_dev(self):
self.stdOut("Install python development environment") self.stdOut("Install python development environment")
count = 0 count = 0
@@ -360,7 +387,6 @@ class preFlightsChecks:
preFlightsChecks.stdOut("Python development tools successfully installed!") preFlightsChecks.stdOut("Python development tools successfully installed!")
break break
def install_gcc(self): def install_gcc(self):
self.stdOut("Install gcc") self.stdOut("Install gcc")
count = 0 count = 0
@@ -385,7 +411,6 @@ class preFlightsChecks:
break break
def install_python_setup_tools(self): def install_python_setup_tools(self):
self.stdOut("Install python setup tools")
count = 0 count = 0
while (1): while (1):
command = "yum -y install python-setuptools" command = "yum -y install python-setuptools"
@@ -407,7 +432,6 @@ class preFlightsChecks:
break break
def install_python_requests(self): def install_python_requests(self):
self.stdOut("Install python requests")
try: try:
import requests import requests
@@ -554,7 +578,6 @@ class preFlightsChecks:
break break
def install_django(self): def install_django(self):
self.stdOut("Install Django")
count = 0 count = 0
while (1): while (1):
command = "pip install django==1.11" command = "pip install django==1.11"
@@ -594,17 +617,6 @@ class preFlightsChecks:
preFlightsChecks.stdOut("MySQL-python successfully installed!") preFlightsChecks.stdOut("MySQL-python successfully installed!")
break break
if self.distro == ubuntu:
command = "pip install MySQL-python"
res = subprocess.call(shlex.split(command))
if res != 0:
logging.InstallLog.writeToFile(
"Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res))
preFlightsChecks.stdOut(
"Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res))
os._exit(os.EX_OSERR)
def install_gunicorn(self): def install_gunicorn(self):
self.stdOut("Install GUnicorn") self.stdOut("Install GUnicorn")
count = 0 count = 0
@@ -626,7 +638,6 @@ class preFlightsChecks:
preFlightsChecks.stdOut("GUNICORN successfully installed!") preFlightsChecks.stdOut("GUNICORN successfully installed!")
break break
def setup_gunicorn(self): def setup_gunicorn(self):
try: try:
@@ -672,7 +683,6 @@ class preFlightsChecks:
preFlightsChecks.stdOut("Not able to setup gunicorn, see install log.") preFlightsChecks.stdOut("Not able to setup gunicorn, see install log.")
def install_psutil(self): def install_psutil(self):
self.stdOut("Install psutil")
try: try:
import psutil import psutil
@@ -718,9 +728,6 @@ class preFlightsChecks:
break break
def fix_selinux_issue(self): def fix_selinux_issue(self):
if (self.distro == ubuntu):
return
try: try:
cmd = [] cmd = []
@@ -760,7 +767,6 @@ class preFlightsChecks:
break break
def download_install_CyberPanel(self,mysqlPassword, mysql): def download_install_CyberPanel(self,mysqlPassword, mysql):
self.stdOut("Download and install Cyberpanel")
try: try:
## On OpenVZ there is an issue with requests module, which needs to upgrade requests module ## On OpenVZ there is an issue with requests module, which needs to upgrade requests module
@@ -882,10 +888,7 @@ class preFlightsChecks:
### Applying migrations ### Applying migrations
try:
os.chdir("CyberCP") os.chdir("CyberCP")
except:
self.stdOut("Error changing to CyberCP directory - internal error!", 1, 1, os.EX_USAGE)
count = 0 count = 0
@@ -979,19 +982,18 @@ class preFlightsChecks:
def install_unzip(self): def install_unzip(self):
self.stdOut("Install unzip") self.stdOut("Install zip")
try: try:
count = 0 count = 0
while (1): while (1):
if self.distro == centos: if self.distro == centos:
command = 'yum -y install unzip' command = 'yum -y install zip'
else: else:
command = 'apt-get -y install unzip' command = 'apt-get -y install zip'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
count = count + 1 count = count + 1
preFlightsChecks.stdOut("Unable to install unzip, trying again, try number: " + str(count)) preFlightsChecks.stdOut("Unable to install unzip, trying again, try number: " + str(count))
@@ -1026,7 +1028,6 @@ class preFlightsChecks:
command = 'apt-get -y install zip' command = 'apt-get -y install zip'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
@@ -1052,15 +1053,8 @@ class preFlightsChecks:
return 1 return 1
def download_install_phpmyadmin(self): def download_install_phpmyadmin(self):
self.stdOut("Install PHP MyAdmin")
try: try:
directory = "/usr/local/lscp/cyberpanel/" os.chdir("/usr/local/lscp/cyberpanel/")
try:
os.chdir(directory)
except OSError as e:
msg = "Error changing to " + "/usr/local/lscp/cyberpanel/ :" + str(e) + " [download_install_phpmyadmin]"
self.stdOut(msg, 1, 1, os.EX_USAGE)
count = 0 count = 0
while(1): while(1):
@@ -1154,13 +1148,7 @@ class preFlightsChecks:
writeToFile.close() writeToFile.close()
try:
os.mkdir('/usr/local/lscp/cyberpanel/phpmyadmin/tmp') os.mkdir('/usr/local/lscp/cyberpanel/phpmyadmin/tmp')
except OSError as e:
if e.errno != errno.EEXIST:
self.stdOut("Error ceating: '/usr/local/lscp/cyberpanel/phpmyadmin/tmp' " + str(e), 1, 1, os.EX_CANTCREAT)
else:
pass
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/phpmyadmin' command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/phpmyadmin'
subprocess.call(shlex.split(command)) subprocess.call(shlex.split(command))
@@ -1207,14 +1195,14 @@ class preFlightsChecks:
# os.remove(file_name) # os.remove(file_name)
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
count = count + 1 count = count + 1
preFlightsChecks.stdOut("Unable to install Postfix, trying again, try number: " + str(count)) preFlightsChecks.stdOut("Unable to install Postfix, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Unable to install Postfix, you will not be able to send mails and rest should work fine! [install_postfix_davecot]") logging.InstallLog.writeToFile(
"Unable to install Postfix, you will not be able to send mails and rest should work fine! [install_postfix_davecot]")
break break
else: else:
logging.InstallLog.writeToFile("Postfix successfully installed!") logging.InstallLog.writeToFile("Postfix successfully installed!")
@@ -1260,17 +1248,17 @@ class preFlightsChecks:
if res == 1: if res == 1:
count = count + 1 count = count + 1
preFlightsChecks.stdOut("Unable to install Dovecot and Dovecot-MySQL, trying again, try number: " + str(count)) preFlightsChecks.stdOut(
"Unable to install Dovecot and Dovecot-MySQL, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Unable to install install Dovecot and Dovecot-MySQL, you will not be able to send mails and rest should work fine! [install_postfix_davecot]") logging.InstallLog.writeToFile(
"Unable to install install Dovecot and Dovecot-MySQL, you will not be able to send mails and rest should work fine! [install_postfix_davecot]")
break break
else: else:
logging.InstallLog.writeToFile("Dovecot and Dovecot-MySQL successfully installed!") logging.InstallLog.writeToFile("Dovecot and Dovecot-MySQL successfully installed!")
preFlightsChecks.stdOut("Dovecot and Dovecot-MySQL successfully installed!") preFlightsChecks.stdOut("Dovecot and Dovecot-MySQL successfully installed!")
break break
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [install_postfix_davecot]") logging.InstallLog.writeToFile(str(msg) + " [install_postfix_davecot]")
return 0 return 0
@@ -1282,7 +1270,6 @@ class preFlightsChecks:
def setup_email_Passwords(self,mysqlPassword, mysql): def setup_email_Passwords(self,mysqlPassword, mysql):
self.stdOut("Setup email passwords")
try: try:
logging.InstallLog.writeToFile("Setting up authentication for Postfix and Dovecot...") logging.InstallLog.writeToFile("Setting up authentication for Postfix and Dovecot...")
@@ -1398,12 +1385,12 @@ class preFlightsChecks:
def setup_postfix_davecot_config(self, mysql): def setup_postfix_davecot_config(self, mysql):
self.stdOut("Configuring postfix and dovecot")
try: try:
logging.InstallLog.writeToFile("Configuring postfix and dovecot...") logging.InstallLog.writeToFile("Configuring postfix and dovecot...")
os.chdir(self.cwd) os.chdir(self.cwd)
mysql_virtual_domains = "/etc/postfix/mysql-virtual_domains.cf" mysql_virtual_domains = "/etc/postfix/mysql-virtual_domains.cf"
mysql_virtual_forwardings = "/etc/postfix/mysql-virtual_forwardings.cf" mysql_virtual_forwardings = "/etc/postfix/mysql-virtual_forwardings.cf"
mysql_virtual_mailboxes = "/etc/postfix/mysql-virtual_mailboxes.cf" mysql_virtual_mailboxes = "/etc/postfix/mysql-virtual_mailboxes.cf"
@@ -1413,6 +1400,8 @@ class preFlightsChecks:
davecot = "/etc/dovecot/dovecot.conf" davecot = "/etc/dovecot/dovecot.conf"
davecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" davecotmysql = "/etc/dovecot/dovecot-sql.conf.ext"
if os.path.exists(mysql_virtual_domains): if os.path.exists(mysql_virtual_domains):
os.remove(mysql_virtual_domains) os.remove(mysql_virtual_domains)
@@ -2041,11 +2030,7 @@ class preFlightsChecks:
####### #######
try:
os.chdir("/usr/local/lscp/cyberpanel") os.chdir("/usr/local/lscp/cyberpanel")
except OSError as e:
self.stdOut("Can't change to cyberpanel directory, fatal error at this point")
count = 1 count = 1
@@ -2171,7 +2156,6 @@ class preFlightsChecks:
def reStartLiteSpeed(self): def reStartLiteSpeed(self):
self.stdOut("Restarting Litespeed")
try: try:
count = 0 count = 0
while(1): while(1):
@@ -2203,11 +2187,10 @@ class preFlightsChecks:
def installFirewalld(self): def installFirewalld(self):
try:
if self.distro == ubuntu: if self.distro == ubuntu:
return 0 # Uses AppArmor return 0 # Uses AppArmor
try:
preFlightsChecks.stdOut("Enabling Firewall!") preFlightsChecks.stdOut("Enabling Firewall!")
count = 0 count = 0
@@ -2364,16 +2347,6 @@ class preFlightsChecks:
count = 0 count = 0
# In Ubuntu, the library that lscpd looks for is libpcre.so.1, but the one it installs is libpcre.so.3...
if self.distro == ubuntu:
command = 'ln -s /lib/x86_64-linux-gnu/libpcre.so.3 /lib/x86_64-linux-gnu/libpcre.so.1'
res = subprocess.call(shlex.split(command))
if res == 0:
self.stdOut("Created ubuntu symbolic link to pcre")
else:
self.stdOut("Error creating symbolic link to pcre: " + str(res))
while(1): while(1):
command = 'systemctl start lscpd' command = 'systemctl start lscpd'
@@ -2406,14 +2379,12 @@ class preFlightsChecks:
return 1 return 1
def setup_cron(self): def setup_cron(self):
self.stdOut("Install and setup cron")
try: try:
## first install crontab ## first install crontab
fd = open("installLogs.txt", 'a') file = open("installLogs.txt", 'a')
count = 0 count = 0
while(1): while(1):
if self.distro == centos: if self.distro == centos:
command = 'yum install cronie -y' command = 'yum install cronie -y'
else: else:
@@ -2421,7 +2392,7 @@ class preFlightsChecks:
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
count = count + 1 count = count + 1
@@ -2438,12 +2409,14 @@ class preFlightsChecks:
count = 0 count = 0
while(1): while(1):
if self.distro == centos: if self.distro == centos:
command = 'systemctl enable crond' command = 'systemctl enable crond'
else: else:
command = 'systemctl enable cron' command = 'systemctl enable cron'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
count = count + 1 count = count + 1
@@ -2463,9 +2436,8 @@ class preFlightsChecks:
command = 'systemctl start crond' command = 'systemctl start crond'
else: else:
command = 'systemctl start cron' command = 'systemctl start cron'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
count = count + 1 count = count + 1
@@ -2488,7 +2460,7 @@ class preFlightsChecks:
command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py' command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
logging.InstallLog.writeToFile("1427 [setup_cron]") logging.InstallLog.writeToFile("1427 [setup_cron]")
@@ -2498,7 +2470,7 @@ class preFlightsChecks:
command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py' command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
logging.InstallLog.writeToFile("1428 [setup_cron]") logging.InstallLog.writeToFile("1428 [setup_cron]")
@@ -2512,9 +2484,8 @@ class preFlightsChecks:
command = 'systemctl restart crond.service' command = 'systemctl restart crond.service'
else: else:
command = 'systemctl restart cron.service' command = 'systemctl restart cron.service'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=fd) res = subprocess.call(cmd, stdout=file)
if res == 1: if res == 1:
count = count + 1 count = count + 1
@@ -2527,7 +2498,8 @@ class preFlightsChecks:
preFlightsChecks.stdOut("Crond successfully restarted!") preFlightsChecks.stdOut("Crond successfully restarted!")
break break
fd.close() file.close()
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [setup_cron]") logging.InstallLog.writeToFile(str(msg) + " [setup_cron]")
@@ -2539,7 +2511,6 @@ class preFlightsChecks:
return 1 return 1
def install_default_keys(self): def install_default_keys(self):
self.stdOut("Installing default certificates")
try: try:
count = 0 count = 0
@@ -2575,10 +2546,10 @@ class preFlightsChecks:
return 1 return 1
def install_rsync(self): def install_rsync(self):
self.stdOut("Installing rsync")
try: try:
count = 0 count = 0
while (1): while (1):
if self.distro == centos: if self.distro == centos:
command = 'yum -y install rsync' command = 'yum -y install rsync'
else: else:
@@ -2609,7 +2580,6 @@ class preFlightsChecks:
return 1 return 1
def test_Requests(self): def test_Requests(self):
self.stdOut("Testing Requests...")
try: try:
import requests import requests
getVersion = requests.get('https://cyberpanel.net/version.txt') getVersion = requests.get('https://cyberpanel.net/version.txt')
@@ -2675,8 +2645,7 @@ class preFlightsChecks:
print(" Visit: https://" + self.ipAddr + ":8090 ") print(" Visit: https://" + self.ipAddr + ":8090 ")
print(" Username: admin ") print(" Username: admin ")
print(" Password: 1234567 ") print(" Password: 1234567 ")
print(" Database password in /etc/cyberpanel/mysqlPassword ")
print(" ")
print("###################################################################") print("###################################################################")
def installCertBot(self): def installCertBot(self):
@@ -2797,6 +2766,7 @@ class preFlightsChecks:
try: try:
count = 0 count = 0
while (1): while (1):
if self.distro == centos: if self.distro == centos:
command = 'yum -y install opendkim' command = 'yum -y install opendkim'
else: else:
@@ -2937,6 +2907,7 @@ milter_default_action = accept
def setupPHPAndComposer(self): def setupPHPAndComposer(self):
try: try:
if self.distro == ubuntu: if self.distro == ubuntu:
if not os.access('/usr/local/lsws/lsphp70/bin/php', os.R_OK): if not os.access('/usr/local/lsws/lsphp70/bin/php', os.R_OK):
if os.access('/usr/local/lsws/lsphp70/bin/php7.0', os.R_OK): if os.access('/usr/local/lsws/lsphp70/bin/php7.0', os.R_OK):
@@ -2968,7 +2939,7 @@ milter_default_action = accept
res = subprocess.call(shlex.split(command)) res = subprocess.call(shlex.split(command))
except OSError, msg: except OSError, msg:
self.stdOut('Setup PHP error: ' + str(msg) + " [setupPHPAndComposer]", 1, 1, os.EX_OSERR) logging.InstallLog.writeToFile(str(msg) + " [setupPHPAndComposer]")
return 0 return 0
@staticmethod @staticmethod
@@ -2976,9 +2947,10 @@ milter_default_action = accept
res = subprocess.call(shlex.split('apt-get -y install ' + package)) res = subprocess.call(shlex.split('apt-get -y install ' + package))
if res != 0: if res != 0:
preFlightsChecks.stdOut("Error #" + str(res) + ' installing:' + package + '. This may not be an issue ' \ preFlightsChecks.stdOut("Error #" + str(res) + ' installing:' + package + '. This may not be an issue ' \
'but may affect installation of something later', 1) 'but may affect installation of something later',
return res #Though probably not used 1)
return res # Though probably not used
@staticmethod @staticmethod
def setupVirtualEnv(distro): def setupVirtualEnv(distro):
@@ -3155,7 +3127,7 @@ milter_default_action = accept
writeToFile.close() writeToFile.close()
except OSError, msg: except OSError, msg:
preFlightsChecks.stdOut('Error disabling DNS: ' + str(msg) + " [enableDisableDNS]", 1, 0) logging.InstallLog.writeToFile(str(msg) + " [enableDisableDNS]")
return 0 return 0
@staticmethod @staticmethod
@@ -3181,7 +3153,7 @@ milter_default_action = accept
writeToFile.close() writeToFile.close()
except OSError, msg: except OSError, msg:
preFlightsChecks.stdOut('Error disabling Email: ' + str(msg) + " [enableDisableEmail]", 1, 0) logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]")
return 0 return 0
@staticmethod @staticmethod
@@ -3207,10 +3179,9 @@ milter_default_action = accept
writeToFile.close() writeToFile.close()
except OSError, msg: except OSError, msg:
preFlightsChecks.stdOut('Error disabling FTP: ' + str(msg) + " [enableDisableFTP]", 1, 0) logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]")
return 0 return 0
def get_distro(): def get_distro():
distro = -1 distro = -1
distro_file = "" distro_file = ""
@@ -3274,13 +3245,7 @@ def main():
## Writing public IP ## Writing public IP
try:
os.mkdir("/etc/cyberpanel") os.mkdir("/etc/cyberpanel")
except OSError as e:
if e.errno != errno.EEXIST:
preFlightsChecks.stdOut("Error creating /etc/cyberpanel directory: " + str(e), 1, 1, os.EX_CANTCREAT)
else:
pass
machineIP = open("/etc/cyberpanel/machineIP", "w") machineIP = open("/etc/cyberpanel/machineIP", "w")
machineIP.writelines(args.publicip) machineIP.writelines(args.publicip)
@@ -3299,8 +3264,7 @@ def main():
preFlightsChecks.stdOut("Single MySQL instance version will be installed.") preFlightsChecks.stdOut("Single MySQL instance version will be installed.")
else: else:
mysql = args.mysql mysql = args.mysql
preFlightsChecks.stdOut("Double MySQL instance version will be installed.") preFlightsChecks.stdOut("Dobule MySQL instance version will be installed.")
checks.checkPythonVersion() checks.checkPythonVersion()
checks.setup_account_cyberpanel() checks.setup_account_cyberpanel()
@@ -3323,19 +3287,21 @@ def main():
import installCyberPanel import installCyberPanel
installCyberPanel.Main(cwd, mysql, distro) installCyberPanel.Main(cwd, mysql)
checks.fix_selinux_issue() checks.fix_selinux_issue()
checks.install_psmisc() checks.install_psmisc()
checks.install_postfix_davecot() checks.install_postfix_davecot()
checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
checks.setup_postfix_davecot_config(mysql) checks.setup_postfix_davecot_config(mysql)
checks.install_unzip() checks.install_unzip()
checks.install_zip() checks.install_zip()
checks.install_rsync() checks.install_rsync()
checks.downoad_and_install_raindloop() checks.downoad_and_install_raindloop()
checks.download_install_phpmyadmin() checks.download_install_phpmyadmin()
checks.installFirewalld() checks.installFirewalld()
@@ -3359,7 +3325,7 @@ def main():
checks.configureOpenDKIM() checks.configureOpenDKIM()
checks.modSecPreReqs() checks.modSecPreReqs()
checks.setupVirtualEnv(distro) checks.setupVirtualEnv()
checks.setupPHPAndComposer() checks.setupPHPAndComposer()
if args.postfix != None: if args.postfix != None:
@@ -3381,8 +3347,7 @@ def main():
checks.enableDisableFTP('On') checks.enableDisableFTP('On')
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")
checks.installation_successfull()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -9,15 +9,12 @@ import shlex
import randomPassword import randomPassword
import errno import errno
import MySQLdb as mariadb import MySQLdb as mariadb
import re import install
import time
import sys
#distros #distros
centos=0 centos=0
ubuntu=1 ubuntu=1
class InstallCyberPanel: class InstallCyberPanel:
mysql_Root_password = "" mysql_Root_password = ""
@@ -242,9 +239,11 @@ class InstallCyberPanel:
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to install LiteSpeed PHPs, trying again, try number: " + str(count)) InstallCyberPanel.stdOut(
"Trying to install LiteSpeed PHPs, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to install LiteSpeed PHPs, exiting installer! [installAllPHPVersions]") logging.InstallLog.writeToFile(
"Failed to install LiteSpeed PHPs, exiting installer! [installAllPHPVersions]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
@@ -260,9 +259,11 @@ class InstallCyberPanel:
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) InstallCyberPanel.stdOut(
"Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") logging.InstallLog.writeToFile(
"Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
@@ -290,7 +291,6 @@ class InstallCyberPanel:
InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!")
break break
## break for outer loop ## break for outer loop
break break
@@ -305,6 +305,8 @@ class InstallCyberPanel:
def setup_mariadb_repo(self): def setup_mariadb_repo(self):
try:
if self.distro == ubuntu: if self.distro == ubuntu:
# Only needed if the repo is broken or we need the latest version. # Only needed if the repo is broken or we need the latest version.
# command = "apt-get -y install software-properties-common" # command = "apt-get -y install software-properties-common"
@@ -312,7 +314,6 @@ class InstallCyberPanel:
# command = "add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'" # command = "add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'"
return return
try:
logging.InstallLog.writeToFile("Setting up MariaDB Repo..") logging.InstallLog.writeToFile("Setting up MariaDB Repo..")
InstallCyberPanel.stdOut("Setting up MariaDB Repo..") InstallCyberPanel.stdOut("Setting up MariaDB Repo..")
@@ -342,6 +343,7 @@ class InstallCyberPanel:
else: else:
command = 'yum -y install mariadb-server' command = 'yum -y install mariadb-server'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
@@ -475,11 +477,9 @@ class InstallCyberPanel:
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to enable MariaDB instance to start at system restart, " InstallCyberPanel.stdOut("Trying to enable MariaDB instance to start and system restart, trying again, try number: " + str(count))
"trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, " logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, you can do this later using systemctl enable mysql! [installMySQL]")
"you can do this later using systemctl enable mysql! [installMySQL]")
break break
else: else:
logging.InstallLog.writeToFile("MariaDB instance successfully enabled at system restart!") logging.InstallLog.writeToFile("MariaDB instance successfully enabled at system restart!")
@@ -646,7 +646,6 @@ class InstallCyberPanel:
self.stdOut("MariaDB is now setup so it can support Cyberpanel's needs") self.stdOut("MariaDB is now setup so it can support Cyberpanel's needs")
def installPureFTPD(self): def installPureFTPD(self):
try: try:
@@ -656,6 +655,7 @@ class InstallCyberPanel:
command = 'apt-get -y install pure-ftpd' command = 'apt-get -y install pure-ftpd'
else: else:
command = "yum install -y pure-ftpd" command = "yum install -y pure-ftpd"
res = subprocess.call(shlex.split(command)) res = subprocess.call(shlex.split(command))
if res == 1: if res == 1:
@@ -769,18 +769,9 @@ class InstallCyberPanel:
############## Start pureftpd ###################### ############## Start pureftpd ######################
try: try:
self.stdOut("Correct configuration with pure-ftpd")
count = 0 count = 0
try:
os.mkdir("/etc/pure-ftpd/conf")
os.mkdir("/etc/pure-ftpd/auth")
except OSError as e:
pass
command = 'cp /etc/pure-ftpd/pure-ftpd.conf /etc/pure-ftpd/conf/pure-ftpd.conf'
res = subprocess.call(shlex.split(command))
self.stdOut("Start the pure-ftp service")
while(1): while(1):
cmd = [] cmd = []
@@ -794,8 +785,7 @@ class InstallCyberPanel:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to start PureFTPD instance, trying again, try number: " + str(count)) InstallCyberPanel.stdOut("Trying to start PureFTPD instance, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to start PureFTPD instance, you can do this manually " logging.InstallLog.writeToFile("Failed to start PureFTPD instance, you can do this manually later using systemctl start pure-ftpd [startPureFTPD]")
"later using systemctl start pure-ftpd [startPureFTPD]")
break break
else: else:
logging.InstallLog.writeToFile("PureFTPD instance successfully started!") logging.InstallLog.writeToFile("PureFTPD instance successfully started!")
@@ -828,9 +818,7 @@ class InstallCyberPanel:
count = 0 count = 0
while(1): while(1):
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj ' \ command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem'
'"/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" ' \
'-keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem'
res = subprocess.call(shlex.split(command)) res = subprocess.call(shlex.split(command))
if res == 1: if res == 1:
@@ -885,9 +873,7 @@ class InstallCyberPanel:
return 1 return 1
def installPowerDNS(self): def installPowerDNS(self):
try: try:
count = 0 count = 0
if self.distro == ubuntu: if self.distro == ubuntu:
@@ -899,7 +885,8 @@ class InstallCyberPanel:
command = 'systemctl disable systemd-resolved.service' command = 'systemctl disable systemd-resolved.service'
res = subprocess.call(shlex.split(command)) res = subprocess.call(shlex.split(command))
if res != 0: if res != 0:
InstallCyberPanel.stdOut('Unable to disable systemd.resolved, prohits install of PowerDNS, error #' + InstallCyberPanel.stdOut(
'Unable to disable systemd.resolved, prohits install of PowerDNS, error #' +
str(res), 1, 1, os.EX_OSERR) str(res), 1, 1, os.EX_OSERR)
try: try:
os.rename('/etc/resolv.conf', 'etc/resolved.conf') os.rename('/etc/resolv.conf', 'etc/resolved.conf')
@@ -921,7 +908,6 @@ class InstallCyberPanel:
". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> " ". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> "
"/etc/resolv.conf'", 1, 1, os.EX_OSERR) "/etc/resolv.conf'", 1, 1, os.EX_OSERR)
if self.distro == centos: if self.distro == centos:
while (1): while (1):
command = 'yum -y install epel-release yum-plugin-priorities' command = 'yum -y install epel-release yum-plugin-priorities'
@@ -930,9 +916,11 @@ class InstallCyberPanel:
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to install PowerDNS Repositories, trying again, try number: " + str(count)) InstallCyberPanel.stdOut(
"Trying to install PowerDNS Repositories, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]") logging.InstallLog.writeToFile(
"Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
@@ -978,7 +966,8 @@ class InstallCyberPanel:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to install PowerDNS, trying again, try number: " + str(count)) InstallCyberPanel.stdOut("Trying to install PowerDNS, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to install PowerDNS, exiting installer! [installPowerDNS]") logging.InstallLog.writeToFile(
"Failed to install PowerDNS, exiting installer! [installPowerDNS]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
@@ -1036,11 +1025,9 @@ class InstallCyberPanel:
logging.InstallLog.writeToFile("PowerDNS configured!") logging.InstallLog.writeToFile("PowerDNS configured!")
InstallCyberPanel.stdOut("PowerDNS configured!") InstallCyberPanel.stdOut("PowerDNS configured!")
except IOError, msg: except IOError, msg:
logging.InstallLog.writeToFile(str(msg) + " [installPowerDNSConfigurations]") logging.InstallLog.writeToFile(str(msg) + " [installPowerDNSConfigurations]")
return 0 return 0
return 1 return 1
def startPowerDNS(self): def startPowerDNS(self):
@@ -1065,9 +1052,7 @@ class InstallCyberPanel:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to enable PowerDNS to start and system restart, trying again, try number: " + str(count)) InstallCyberPanel.stdOut("Trying to enable PowerDNS to start and system restart, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to enable PowerDNS to run at system restart, you can " logging.InstallLog.writeToFile("Failed to enable PowerDNS to run at system restart, you can manually do this later using systemctl enable pdns! [startPowerDNS]")
"manually do this later using systemctl enable pdns! "
"[startPowerDNS]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
break break
else: else:
@@ -1119,6 +1104,7 @@ class InstallCyberPanel:
command = "apt-get -y install gcc g++ make autoconf rcs" command = "apt-get -y install gcc g++ make autoconf rcs"
else: else:
command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs' command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
@@ -1168,22 +1154,20 @@ class InstallCyberPanel:
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to extract LSCPD, trying again, try number: " + str(count)) InstallCyberPanel.stdOut("Trying to configure LSCPD, trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to extract LSCPD, exiting installer! [installLSCPD]") logging.InstallLog.writeToFile("Failed to configure LSCPD, exiting installer! [installLSCPD]")
InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt")
os._exit(0) os._exit(0)
else: else:
logging.InstallLog.writeToFile("LSCPD successfully extracted!") logging.InstallLog.writeToFile("LSCPD successfully configured!")
InstallCyberPanel.stdOut("LSCPD successfully extracted!") InstallCyberPanel.stdOut("LSCPD successfully extracted!")
break break
count = 0 count = 0
while(1): while(1):
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj ' \ 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/key.pem -out /usr/local/lscp/cert.pem'
'"/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/key.pem ' \
'-out /usr/local/lscp/cert.pem'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
@@ -1244,6 +1228,7 @@ class InstallCyberPanel:
def Main(cwd, mysql, distro): def Main(cwd, mysql, distro):
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
file_name = '/etc/cyberpanel/mysqlPassword' file_name = '/etc/cyberpanel/mysqlPassword'
@@ -1253,6 +1238,7 @@ def Main(cwd, mysql, distro):
else: else:
password = open(file_name, "w") password = open(file_name, "w")
password.writelines(InstallCyberPanel.mysql_Root_password) password.writelines(InstallCyberPanel.mysql_Root_password)
password.close() password.close()
if distro == centos: if distro == centos:
@@ -1268,6 +1254,7 @@ def Main(cwd, mysql, distro):
installer.installAllPHPVersions() installer.installAllPHPVersions()
installer.fix_ols_configs() installer.fix_ols_configs()
installer.setup_mariadb_repo() installer.setup_mariadb_repo()
installer.installMySQL(mysql) installer.installMySQL(mysql)
installer.changeMYSQLRootPassword() installer.changeMYSQLRootPassword()
@@ -1278,6 +1265,7 @@ def Main(cwd, mysql, distro):
mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql) mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql)
installer.installPureFTPD() installer.installPureFTPD()
installer.installPureFTPDConfigurations(mysql) installer.installPureFTPDConfigurations(mysql)
installer.startPureFTPD() installer.startPureFTPD()

View File

@@ -6,35 +6,13 @@ import argparse
import os import os
import shlex import shlex
import socket import socket
import install
#distros
centos=0
ubuntu=1
distro = install.get_distro()
class unInstallCyberPanel: class unInstallCyberPanel:
def fixResolvConf(self):
if distro == centos:
return
if os.access('/etc/resolv.conf', os.F_OK):
return
try:
f = open('/etc/resolv.conf', 'w')
f.write('nameserver 8.8.8.8')
f.close()
except IOError as e:
print "Unable to create /etc/resolv.conf: " + str(e) + \
". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> " \
"/etc/resolv.conf'"
def unInstallCyberPanelRepo(self): def unInstallCyberPanelRepo(self):
if distro == centos:
try: try:
copyPath = "/etc/yum.repos.d/cyberpanel.repo" copyPath = "/etc/yum.repos.d/cyberpanel.repo"
os.remove(copyPath) os.remove(copyPath)
@@ -62,10 +40,7 @@ class unInstallCyberPanel:
def removePostfixDovecot(self): def removePostfixDovecot(self):
try: try:
if distro == centos:
command = 'yum -y remove postfix' command = 'yum -y remove postfix'
else:
command = 'apt-get -y remove postfix'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -87,10 +62,7 @@ class unInstallCyberPanel:
def removeMysql(self): def removeMysql(self):
try: try:
if distro == centos:
command = 'yum -y remove mariadb mariadb-server' command = 'yum -y remove mariadb mariadb-server'
else:
command = 'apt-get -y remove mariadb-server'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -112,10 +84,7 @@ class unInstallCyberPanel:
def removeLiteSpeed(self): def removeLiteSpeed(self):
try: try:
if distro == centos:
command = 'yum -y remove openlitespeed' command = 'yum -y remove openlitespeed'
else:
command = 'apt-get --purge -y remove openlitespeed'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -149,10 +118,7 @@ class unInstallCyberPanel:
def removePureFTPD(self): def removePureFTPD(self):
try: try:
if distro == centos:
command = 'yum -y remove pure-ftpd' command = 'yum -y remove pure-ftpd'
else:
command = 'apt-get -y remove pure-ftpd'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -170,10 +136,8 @@ class unInstallCyberPanel:
def removePowerDNS(self): def removePowerDNS(self):
try: try:
if distro == centos:
command = 'yum -y remove pdns' command = 'yum -y remove pdns'
else:
command = 'apt-get -y remove pdns-server'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -192,10 +156,7 @@ class unInstallCyberPanel:
def removePHP(self): def removePHP(self):
try: try:
if distro == centos:
command = 'yum -y remove lsphp*' command = 'yum -y remove lsphp*'
else:
command = 'apt-get -y remove lsphp*'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -217,7 +178,6 @@ def Main():
remove = unInstallCyberPanel() remove = unInstallCyberPanel()
remove.fixResolvConf()
remove.removeLiteSpeed() remove.removeLiteSpeed()
remove.removeMysql() remove.removeMysql()
remove.removePostfixDovecot() remove.removePostfixDovecot()

View File

@@ -348,6 +348,20 @@ class DNS:
record.save() record.save()
return return
if type == 'TXT':
if Records.objects.filter(name=name, type=type, content=value).count() == 0:
record = Records(domainOwner=zone,
domain_id=zone.id,
name=name,
type=type,
content=value,
ttl=ttl,
prio=priority,
disabled=0,
auth=1)
record.save()
return
if type == 'MX': if type == 'MX':
record = Records(domainOwner=zone, record = Records(domainOwner=zone,
domain_id=zone.id, domain_id=zone.id,
@@ -359,6 +373,7 @@ class DNS:
disabled=0, disabled=0,
auth=1) auth=1)
record.save() record.save()
return
if Records.objects.filter(name=name, type=type).count() == 0: if Records.objects.filter(name=name, type=type).count() == 0:

View File

@@ -41,7 +41,7 @@ app.filter('getwebsitename', function() {
if(domain !== undefined) { if(domain !== undefined) {
domain = domain.replace("-", ""); domain = domain.replace(/-/g, '');
var domainName = domain.split("."); var domainName = domain.split(".");

View File

@@ -3,9 +3,6 @@
*/ */
/* Java script code to create database */ /* Java script code to create database */
app.controller('createDatabase', function($scope,$http) { app.controller('createDatabase', function($scope,$http) {
@@ -38,8 +35,7 @@ app.controller('createDatabase', function($scope,$http) {
// getting website username // getting website username
webUserName = databaseWebsite.replace("-", ""); webUserName = databaseWebsite.replace(/-/g, '');
webUserName = webUserName.split(".")[0]; webUserName = webUserName.split(".")[0];
if(webUserName.length > 5){ if(webUserName.length > 5){
@@ -54,7 +50,7 @@ app.controller('createDatabase', function($scope,$http) {
databaseWebsite:databaseWebsite, databaseWebsite:databaseWebsite,
dbName:dbName, dbName:dbName,
dbUsername:dbUsername, dbUsername:dbUsername,
dbPassword:dbPassword, dbPassword:dbPassword
}; };
var config = { var config = {
@@ -281,7 +277,6 @@ app.controller('deleteDatabase', function($scope,$http) {
/* Java script code to delete database ends here */ /* Java script code to delete database ends here */
/* Java script code to list databases */ /* Java script code to list databases */

View File

@@ -14,7 +14,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader, $w
var editor = ace.edit("htmlEditorContent"); var editor = ace.edit("htmlEditorContent");
var aceEditorMode = ''; var aceEditorMode = '';
var domainName = window.location.pathname.split("/")[2]; var domainName = $("#domainNameInitial").text();
var domainRandomSeed = ""; var domainRandomSeed = "";
var homePathBack = "/home/"+domainName; var homePathBack = "/home/"+domainName;

View File

@@ -4,68 +4,66 @@ import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.loadWebsitesHome, name='loadWebsitesHome'), url(r'^$', views.loadWebsitesHome, name='loadWebsitesHome'),
url(r'^createWebsite', views.createWebsite, name='createWebsite'), url(r'^createWebsite$', views.createWebsite, name='createWebsite'),
url(r'^listWebsites', views.listWebsites, name='listWebsites'), url(r'^listWebsites$', views.listWebsites, name='listWebsites'),
url(r'^modifyWebsite', views.modifyWebsite, name='modifyWebsite'), url(r'^modifyWebsite$', views.modifyWebsite, name='modifyWebsite'),
url(r'^deleteWebsite', views.deleteWebsite, name='deleteWebsite'), url(r'^deleteWebsite$', views.deleteWebsite, name='deleteWebsite'),
url(r'^siteState', views.siteState, name='siteState'), url(r'^siteState$', views.siteState, name='siteState'),
# Website modification url # Website modification url
url(r'^submitWebsiteCreation', views.submitWebsiteCreation, name='submitWebsiteCreation'), url(r'^submitWebsiteCreation$', views.submitWebsiteCreation, name='submitWebsiteCreation'),
url(r'^submitWebsiteDeletion', views.submitWebsiteDeletion, name='submitWebsiteDeletion'), url(r'^submitWebsiteDeletion$', views.submitWebsiteDeletion, name='submitWebsiteDeletion'),
url(r'^submitWebsiteListing', views.getFurtherAccounts, name='submitWebsiteListing'), url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
url(r'^submitWebsiteModification', views.deleteWebsite, name='submitWebsiteModification'), url(r'^submitWebsiteModification$', views.deleteWebsite, name='submitWebsiteModification'),
url(r'^submitWebsiteStatus', views.submitWebsiteStatus, name='submitWebsiteStatus'), url(r'^submitWebsiteStatus$', views.submitWebsiteStatus, name='submitWebsiteStatus'),
url(r'^getWebsiteDetails', views.submitWebsiteModify, name='getWebsiteDetails'), url(r'^getWebsiteDetails$', views.submitWebsiteModify, name='getWebsiteDetails'),
url(r'^saveWebsiteChanges', views.saveWebsiteChanges, name='saveWebsiteChanges'), url(r'^saveWebsiteChanges', views.saveWebsiteChanges, name='saveWebsiteChanges'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/(?P<childDomain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.launchChild, name='launchChild'), url(r'^getDataFromLogFile$', views.getDataFromLogFile, name='getDataFromLogFile'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.domain, name='domain'), url(r'^fetchErrorLogs$', views.fetchErrorLogs, name='fetchErrorLogs'),
url(r'^getDataFromLogFile', views.getDataFromLogFile, name='getDataFromLogFile'),
url(r'^fetchErrorLogs', views.fetchErrorLogs, name='fetchErrorLogs'),
url(r'^getDataFromConfigFile', views.getDataFromConfigFile, name='getDataFromConfigFile'), url(r'^getDataFromConfigFile$', views.getDataFromConfigFile, name='getDataFromConfigFile'),
url(r'^saveConfigsToFile', views.saveConfigsToFile, name='saveConfigsToFile'), url(r'^saveConfigsToFile$', views.saveConfigsToFile, name='saveConfigsToFile'),
url(r'^getRewriteRules', views.getRewriteRules, name='getRewriteRules'), url(r'^getRewriteRules$', views.getRewriteRules, name='getRewriteRules'),
url(r'^saveRewriteRules', views.saveRewriteRules, name='saveRewriteRules'), url(r'^saveRewriteRules$', views.saveRewriteRules, name='saveRewriteRules'),
url(r'^saveSSL', views.saveSSL, name='saveSSL'), url(r'^saveSSL$', views.saveSSL, name='saveSSL'),
## sub/add/park domains ## sub/add/park domains
url(r'^submitDomainCreation', views.submitDomainCreation, name='submitDomainCreation'), url(r'^submitDomainCreation$', views.submitDomainCreation, name='submitDomainCreation'),
## fetch domains ## fetch domains
url(r'^fetchDomains', views.fetchDomains, name='submitDomainCreation'), url(r'^fetchDomains$', views.fetchDomains, name='submitDomainCreation'),
url(r'^changePHP', views.changePHP, name='changePHP'), url(r'^changePHP$', views.changePHP, name='changePHP'),
url(r'^submitDomainDeletion', views.submitDomainDeletion, name='submitDomainDeletion'), url(r'^submitDomainDeletion$', views.submitDomainDeletion, name='submitDomainDeletion'),
# crons # crons
url(r'^listCron',views.listCron,name="listCron"), url(r'^listCron$',views.listCron,name="listCron"),
url(r'^getWebsiteCron',views.getWebsiteCron,name="getWebsiteCron"), url(r'^getWebsiteCron$',views.getWebsiteCron,name="getWebsiteCron"),
url(r'^getCronbyLine',views.getCronbyLine,name="getCronbyLine"), url(r'^getCronbyLine$',views.getCronbyLine,name="getCronbyLine"),
url(r'^remCronbyLine',views.remCronbyLine,name="remCronbyLine"), url(r'^remCronbyLine$',views.remCronbyLine,name="remCronbyLine"),
url(r'^saveCronChanges',views.saveCronChanges,name="saveCronChanges"), url(r'^saveCronChanges$',views.saveCronChanges,name="saveCronChanges"),
url(r'^addNewCron',views.addNewCron,name="addNewCron"), url(r'^addNewCron$',views.addNewCron,name="addNewCron"),
## Domain Alias ## Domain Alias
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/domainAlias$', views.domainAlias, name='domainAlias'), url(r'^(?P<domain>(.*))/domainAlias$', views.domainAlias, name='domainAlias'),
url(r'^submitAliasCreation',views.submitAliasCreation,name="submitAliasCreation"), url(r'^submitAliasCreation$',views.submitAliasCreation,name="submitAliasCreation"),
url(r'^issueAliasSSL',views.issueAliasSSL,name="issueAliasSSL"), url(r'^issueAliasSSL$',views.issueAliasSSL,name="issueAliasSSL"),
url(r'^delateAlias',views.delateAlias,name="delateAlias"), url(r'^delateAlias$',views.delateAlias,name="delateAlias"),
## Openbasedir ## Openbasedir
@@ -73,7 +71,7 @@ urlpatterns = [
## WP Install ## WP Install
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/wordpressInstall$', views.wordpressInstall, name='wordpressInstall'), url(r'^(?P<domain>(.*))/wordpressInstall$', views.wordpressInstall, name='wordpressInstall'),
url(r'^installWordpressStatus$',views.installWordpressStatus,name="installWordpressStatus"), url(r'^installWordpressStatus$',views.installWordpressStatus,name="installWordpressStatus"),
url(r'^installWordpress$', views.installWordpress, name='installWordpress'), url(r'^installWordpress$', views.installWordpress, name='installWordpress'),
@@ -81,21 +79,23 @@ urlpatterns = [
## Joomla Install ## Joomla Install
url(r'^installJoomla$', views.installJoomla, name='installJoomla'), url(r'^installJoomla$', views.installJoomla, name='installJoomla'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'), url(r'^(?P<domain>(.*))/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'),
## PrestaShop Install ## PrestaShop Install
url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'), url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'), url(r'^(?P<domain>(.*))/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'),
## Git ## Git
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'), url(r'^(?P<domain>(.*))/setupGit$', views.setupGit, name='setupGit'),
url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'), url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/gitNotify$', views.gitNotify, name='gitNotify'), url(r'^(?P<domain>(.*))/gitNotify$', views.gitNotify, name='gitNotify'),
url(r'^detachRepo$', views.detachRepo, name='detachRepo'), url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
url(r'^changeBranch$', views.changeBranch, name='changeBranch'), url(r'^changeBranch$', views.changeBranch, name='changeBranch'),
## Catch all for domains
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
url(r'^(?P<domain>(.*))$', views.domain, name='domain'),
] ]