From 690104c2762e000da071a02dc1c83bd92c227e13 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Tue, 2 Mar 2021 23:57:35 +0500 Subject: [PATCH 1/7] update cloud key --- install/cyberso.pub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 85082311f8f3f9de71ac0bf76479888970ecf7d7 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Wed, 3 Mar 2021 13:35:09 +0500 Subject: [PATCH 2/7] bug fix: cater remote db during staging deployment --- plogical/applicationInstaller.py | 1 - websiteFunctions/StagingSetup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 7450c22f0..f4d4e7748 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -1377,7 +1377,6 @@ $parameters = array( wm.submitWebsiteDeletion(1, self.extraArgs) logging.statusWriter(self.extraArgs['tempStatusPath'], '%s [404].' % (str(msg))) - def installWhmcs(self): try: diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index 7e68fe7f6..d97bd8179 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 --path=%s' % (dbNameRestore, dbUser, dbPassword, ApplicationInstaller.LOCALHOST, path) ProcessUtilities.executioner(command, website.externalApp) ## Exporting and importing database From c92ee539bc1e65438c11b01aabd0cadb1b8c962c Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 4 Mar 2021 09:22:06 +0500 Subject: [PATCH 3/7] do check for remote db --- install/installCyberPanel.py | 1 - install/mysqlUtilities.py | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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..158c8ca37 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,6 +55,19 @@ class mysqlUtilities: if res == 1: return 0 else: + ### 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) + if remote: if mysqlData['mysqlhost'].find('rds.amazon') == -1: dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip) From 0871e4d39bc3e817c281e3e89a6d34a22a4f2689 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 4 Mar 2021 10:17:47 +0500 Subject: [PATCH 4/7] do check for remote db --- CyberCP/settings.py | 2 +- install/install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/install.py b/install/install.py index f973a5dd8..a22228b30 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!") From faf8a140e16bd22625f31d2de341e9f3b63f730a Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 4 Mar 2021 21:04:32 +0500 Subject: [PATCH 5/7] bug fix in do check --- install/mysqlUtilities.py | 30 ++++++++++++++++++------------ plogical/applicationInstaller.py | 5 ++++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/install/mysqlUtilities.py b/install/mysqlUtilities.py index 158c8ca37..d20fb7765 100755 --- a/install/mysqlUtilities.py +++ b/install/mysqlUtilities.py @@ -55,20 +55,26 @@ class mysqlUtilities: if res == 1: return 0 else: - ### 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) 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 f4d4e7748..d8d1dcd6d 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 From ca2c55dbcfb675e633f0bdaa9c580afdb13faf22 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 4 Mar 2021 21:14:11 +0500 Subject: [PATCH 6/7] bug fix in do check --- plogical/applicationInstaller.py | 2 +- plogical/mysqlUtilities.py | 11 +++++++++++ websiteFunctions/StagingSetup.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index d8d1dcd6d..ae8214490 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -585,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: diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index 71e75a7b0..d76fdd4b2 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 @@ -117,8 +119,17 @@ class mysqlUtilities: cursor.execute("CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword+ "'") if mysqlUtilities.RDS == 0: + cursor.execute( + "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword + "'") cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST)) else: + 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) + cursor.execute( "GRANT INDEX, DROP, UPDATE, ALTER, CREATE, SELECT, INSERT, DELETE ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST)) connection.close() diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index d97bd8179..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 --dbhost=%s --path=%s' % (dbNameRestore, dbUser, dbPassword, ApplicationInstaller.LOCALHOST, 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 From 6fc9ef54b195fd55af7166ca615e23d9b58571e3 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 5 Mar 2021 00:00:01 +0500 Subject: [PATCH 7/7] bug fix in do check --- plogical/mysqlUtilities.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index d76fdd4b2..ef70a9ebb 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -116,20 +116,19 @@ 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( - "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword + "'") cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST)) else: - 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) - cursor.execute( "GRANT INDEX, DROP, UPDATE, ALTER, CREATE, SELECT, INSERT, DELETE ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST)) connection.close()