diff --git a/CyberCP/settings.py b/CyberCP/settings.py index 64905d503..12eb81229 100755 --- a/CyberCP/settings.py +++ b/CyberCP/settings.py @@ -114,7 +114,7 @@ DATABASES = { 'USER': 'cyberpanel', 'PASSWORD': 'Bz9gF7Hr7X4RtD', 'HOST': 'localhost', - 'PORT':'' + 'PORT': '' }, 'rootdb': { 'ENGINE': 'django.db.backends.mysql', diff --git a/install/cyberso.pub b/install/cyberso.pub index f87da8339..98ca178b3 100644 --- a/install/cyberso.pub +++ b/install/cyberso.pub @@ -1 +1 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3txFD2sk0fG9MX4l8vpvXYn8ymRN8107PCYywxvwIVN2KnWcPvsKreOajdJr6wj07jqXpviolQdkCM+qPRodHmTX5gpRz0GQobik1S1bihc2wTC4CA9WWAolXxBxnUO5FnMJMoB3tWmg+1tpJZnr+ZATFHjCbmTH+Ra5KO/bROt/gYoiiZvEAzLJNrLYOKBZ9Ik6/GBWFLALosjM8wFK6LQrrOzeNSOK7+aActliF0RjssHwi/65H0Hv172GsIecWvWTnOXrkhi134OtQmbSRtnVAMtjaPsWGO1PEJZya2iRa41fslolH2iQV9Bwe5m0pclceE14UV0cEvO7CqavF cyberso@ip-172-26-3-119.eu-west-2.compute.internal \ No newline at end of file +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCR0LGYoTUe8ZBhH1D9q/QxbmKzKLQS7TMEyPMCv3NidL+LHy60B5upmflIfIf7oRtyDXWGlH564CFQB8YDnXJBrUgCxpRWtT7MYLWMu9WA8OTtJnGi6r10maLp4RJi7yzuOZ36n+IW/ZdxxVgKgfVeUAtaYXZjrsOLepD4YfXjw4D0MYD7VPcYUdPjRf3m5vClaawvmMtNXh2d2a2BFDJCzX3YgAJdbNe9rJeVrigSWUahU6fPVKxbqEdb7E+l8YIUzNtnpjaxcaaBtLKbc4GiAzLmNOdG01F09/y3GTnHcZJSORLGowioZMpB+T8Q9pvW9lJDSw3k7GbUitpfMHT cloud \ No newline at end of file diff --git a/install/install.py b/install/install.py index 84899beb4..f666e2b09 100755 --- a/install/install.py +++ b/install/install.py @@ -446,7 +446,7 @@ class preFlightsChecks: command = "sed -i 's|root|%s|g' %s" % (self.mysqluser, path) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = "sed -i 's|'PORT':''|'PORT':'%s'|g' %s" % (self.mysqlport, path) + command = "sed -i \"s|'PORT': ''|'PORT':'%s'|g\" %s" % (self.mysqlport, path) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) logging.InstallLog.writeToFile("settings.py updated!") diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index baeed20d7..467f4045b 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -274,7 +274,6 @@ class InstallCyberPanel: def changeMYSQLRootPassword(self): if self.remotemysql == 'OFF': - if self.distro == ubuntu: passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';UPDATE user SET plugin='' WHERE User='root';flush privileges;" % (InstallCyberPanel.mysql_Root_password) else: diff --git a/install/mysqlUtilities.py b/install/mysqlUtilities.py index 7ca563331..d20fb7765 100755 --- a/install/mysqlUtilities.py +++ b/install/mysqlUtilities.py @@ -14,7 +14,6 @@ class mysqlUtilities: from json import loads mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read()) - initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword']) remote = 1 except: @@ -56,7 +55,26 @@ class mysqlUtilities: if res == 1: return 0 else: + if remote: + + ### DO Check + + if mysqlData['mysqlhost'].find('ondigitalocean') > -1: + + alterUserPassword = "ALTER USER 'cyberpanel'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % ( + publicip, dbpassword) + command = initCommand + alterUserPassword + '"' + + if install.preFlightsChecks.debug: + print(command) + time.sleep(10) + + cmd = shlex.split(command) + subprocess.call(cmd) + + ## RDS Check + if mysqlData['mysqlhost'].find('rds.amazon') == -1: dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip) else: diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 7450c22f0..ae8214490 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -22,6 +22,8 @@ import hashlib class ApplicationInstaller(multi.Thread): LOCALHOST = 'localhost' + REMOTE = 0 + PORT = '3306' def __init__(self, installApp, extraArgs): multi.Thread.__init__(self) @@ -421,9 +423,10 @@ $parameters = array( try: import json jsonData = json.loads(open(passFile, 'r').read()) - mysqlhost = jsonData['mysqlhost'] ApplicationInstaller.LOCALHOST = mysqlhost + ApplicationInstaller.REMOTE = 1 + ApplicationInstaller.PORT = jsonData['mysqlport'] except: pass @@ -582,7 +585,7 @@ $parameters = array( statusFile.writelines('Configuring the installation,40') statusFile.close() - command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST) + finalPath + command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s:%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST, ApplicationInstaller.PORT) + finalPath result = ProcessUtilities.outputExecutioner(command, externalApp) if result.find('Success:') == -1: @@ -1377,7 +1380,6 @@ $parameters = array( wm.submitWebsiteDeletion(1, self.extraArgs) logging.statusWriter(self.extraArgs['tempStatusPath'], '%s [404].' % (str(msg))) - def installWhmcs(self): try: diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index a785113b8..bebd28639 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -27,6 +27,7 @@ class mysqlUtilities: LOCALHOST = 'localhost' RDS = 0 + REMOTEHOST = '' @staticmethod def getPagination(records, toShow): @@ -67,6 +68,7 @@ class mysqlUtilities: mysqlpassword = jsonData['mysqlpassword'] mysqlport = jsonData['mysqlport'] mysqlhost = jsonData['mysqlhost'] + mysqlUtilities.REMOTEHOST = mysqlhost if mysqlhost.find('rds.amazon') > -1: mysqlUtilities.RDS = 1 @@ -114,7 +116,15 @@ class mysqlUtilities: return 0 cursor.execute("CREATE DATABASE " + dbname) - cursor.execute("CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword+ "'") + + if mysqlUtilities.REMOTEHOST.find('ondigitalocean') > -1: + query = "CREATE USER '%s'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % ( + dbuser, mysqlUtilities.LOCALHOST, dbpassword) + else: + query = "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % ( + mysqlUtilities.LOCALHOST) + dbpassword + "'" + + cursor.execute(query) if mysqlUtilities.RDS == 0: cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST)) diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index 7e68fe7f6..7e6346d40 100644 --- a/websiteFunctions/StagingSetup.py +++ b/websiteFunctions/StagingSetup.py @@ -98,7 +98,7 @@ class StagingSetup(multi.Thread): dbNameRestore, dbUser, dbPassword = ApplicationInstaller(None, None).dbCreation(tempStatusPath, website) - command = 'wp core config --dbname=%s --dbuser=%s --dbpass=%s --path=%s' % (dbNameRestore, dbUser, dbPassword, path) + command = 'wp core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s:%s --path=%s' % (dbNameRestore, dbUser, dbPassword, ApplicationInstaller.LOCALHOST, ApplicationInstaller.PORT, path) ProcessUtilities.executioner(command, website.externalApp) ## Exporting and importing database