From d8da9d1321cb9772b4bf640759cb8e00d4deb8d7 Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Sun, 5 Aug 2018 01:46:31 +0500 Subject: [PATCH] Prestashop Installer --- plogical/applicationInstaller.py | 238 ++++++++++++++++++ static/images/icons/prestashop.png | Bin 0 -> 4314 bytes static/websiteFunctions/websiteFunctions.js | 195 ++++++++++++++ .../static/images/icons/prestashop.png | Bin 0 -> 4314 bytes .../websiteFunctions/websiteFunctions.js | 195 ++++++++++++++ .../websiteFunctions/installPrestaShop.html | 141 +++++++++++ .../templates/websiteFunctions/website.html | 17 +- websiteFunctions/urls.py | 5 + websiteFunctions/views.py | 67 ++++- 9 files changed, 855 insertions(+), 3 deletions(-) create mode 100644 static/images/icons/prestashop.png create mode 100644 websiteFunctions/static/images/icons/prestashop.png create mode 100644 websiteFunctions/templates/websiteFunctions/installPrestaShop.html diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index d7ee38f6a..b42ef1356 100644 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -39,6 +39,8 @@ class ApplicationInstaller(multi.Thread): self.detachRepo() elif self.installApp == 'changeBranch': self.changeBranch() + elif self.installApp == 'prestashop': + self.installPrestaShop() except BaseException, msg: logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]') @@ -309,6 +311,242 @@ class ApplicationInstaller(multi.Thread): statusFile.close() return 0 + def installPrestaShop(self): + try: + + admin = self.extraArgs['admin'] + domainName = self.extraArgs['domainName'] + home = self.extraArgs['home'] + shopName = self.extraArgs['shopName'] + firstName = self.extraArgs['firstName'] + lastName = self.extraArgs['lastName'] + databasePrefix = self.extraArgs['databasePrefix'] + email = self.extraArgs['email'] + password = self.extraArgs['password'] + tempStatusPath = self.extraArgs['tempStatusPath'] + + + ### Check WP CLI + + + ## Open Status File + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up paths,0') + statusFile.close() + + try: + website = ChildDomains.objects.get(domain=domainName) + externalApp = website.master.externalApp + + if admin.type != 1: + if website.master.admin != admin: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("You do not own this website." + " [404]") + statusFile.close() + return 0 + + except: + website = Websites.objects.get(domain=domainName) + externalApp = website.externalApp + + if admin.type != 1: + if website.admin != admin: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("You do not own this website." + " [404]") + statusFile.close() + return 0 + + finalPath = "" + + + if home == '0': + path = self.extraArgs['path'] + finalPath = "/home/" + domainName + "/public_html/" + path + "/" + else: + finalPath = "/home/" + domainName + "/public_html/" + + + ## Security Check + + if finalPath.find("..") > -1: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Specified path must be inside virtual host home." + " [404]") + statusFile.close() + return 0 + + FNULL = open(os.devnull, 'w') + + if not os.path.exists(finalPath): + command = 'sudo mkdir -p ' + finalPath + subprocess.call(shlex.split(command)) + + ## checking for directories/files + + dirFiles = os.listdir(finalPath) + + if len(dirFiles) == 1: + if dirFiles[0] == ".well-known": + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Target directory should be empty before installation, otherwise data loss could occur." + " [404]") + statusFile.close() + return 0 + elif len(dirFiles) == 0: + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "Target directory should be empty before installation, otherwise data loss could occur." + " [404]") + statusFile.close() + return 0 + + + + + ## DB Creation + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up Database,20') + statusFile.close() + + dbName = randomPassword.generate_pass() + dbUser = dbName + dbPassword = randomPassword.generate_pass() + + ## DB Creation + + if website.package.dataBases > website.databases_set.all().count(): + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "Maximum database limit reached for this website." + " [404]") + statusFile.close() + return 0 + + if Databases.objects.filter(dbName=dbName).exists() or Databases.objects.filter( + dbUser=dbUser).exists(): + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "This database or user is already taken." + " [404]") + statusFile.close() + return 0 + + result = mysqlUtilities.createDatabase(dbName, dbUser, dbPassword) + + if result == 1: + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "Not able to create database." + " [404]") + statusFile.close() + return 0 + + db = Databases(website=website, dbName=dbName, dbUser=dbUser) + db.save() + + + #### + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Downloading and extracting PrestaShop Core..,30') + statusFile.close() + + command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip" + subprocess.call(shlex.split(command)) + + command = "sudo unzip -o prestashop_1.7.4.2.zip -d " + finalPath + subprocess.call(shlex.split(command)) + + command = "sudo unzip -o " + finalPath + "prestashop.zip -d " + finalPath + subprocess.call(shlex.split(command)) + + ## + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Configuring the installation,40') + statusFile.close() + + if home == '0': + path = self.extraArgs['path'] + finalURL = domainName + '/' + path + else: + finalURL = domainName + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Installing and configuring PrestaShop..,60') + statusFile.close() + + command = "sudo php " + finalPath + "install/index_cli.php --domain=" + finalURL + \ + " --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \ + + " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \ + " --email=" + email + " --password=" + password + subprocess.call(shlex.split(command)) + + ## + + command = "sudo rm -rf" + finalPath + "install" + subprocess.call(shlex.split(command)) + + ## + + command = "sudo chown -R " + externalApp + ":" + externalApp + " " + "/home/" + domainName + "/public_html/" + cmd = shlex.split(command) + res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) + + command = "sudo rm -f prestashop_1.7.4.2.zip" + cmd = shlex.split(command) + res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) + + vhost.addRewriteRules(domainName) + installUtilities.reStartLiteSpeed() + + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Successfully Installed. [200]") + statusFile.close() + return 0 + + + except BaseException, msg: + # remove the downloaded files + try: + + command = "sudo rm -rf " + finalPath + cmd = shlex.split(command) + res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) + + except BaseException, msg: + logging.writeToFile(str(msg) + " [installWordPress]") + + homeDir = "/home/" + domainName + "/public_html" + + if not os.path.exists(homeDir): + FNULL = open(os.devnull, 'w') + + command = 'sudo mkdir ' + homeDir + subprocess.call(shlex.split(command)) + + + command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir + cmd = shlex.split(command) + res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) + + try: + mysqlUtilities.deleteDatabase(dbName, dbUser) + db = Databases.objects.get(dbName=dbName) + db.delete() + except: + pass + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines(str(msg) + " [404]") + statusFile.close() + return 0 + def setupGit(self): try: admin = self.extraArgs['admin'] diff --git a/static/images/icons/prestashop.png b/static/images/icons/prestashop.png new file mode 100644 index 0000000000000000000000000000000000000000..0ab1d644cd4ae64048eec4e36b1326e597d997e0 GIT binary patch literal 4314 zcmV<05GC)4P)fOfqw30=@V5`ON2Y&faUSz1Nz3_FjAKwS|BeFU{#boBb1K!vN)n93~;;^+GUP!c0J)peVP1 z3MpAHrPy%WxUA!6vY&7U4Y0~$F&cYy_e;qSfvJEvBZ5yt0=tFa!(O9z?oINj= z5wx+S1poPjmG^txwAR&Pso6{Gp&DG>T`-8z4JoM@GjmAJ%qFLJ0;48hgrbev#ldic ztKR+s#o0@u5k(yV<@L5Z1!8p~tved(soVBfY<0ExecnVwpdX$>;k19DX!;Bcsc8wx zkjT4kE6#aqu=+s_5S;C|0C9~=r`61XPya+q?Y{VW8U>0*L*991jGZxyw7hfUW%r=S zD+gO01~fo$ov$K}+1~H@)HJJ z27^wHYUN#Bo&4?f6*N}_dT`>XMLJ@K&S1a*o)#0Utww;R+-?r3h} z@8v6Tb#=zmp&=u6WF8mab|1-E>Rl2kx&CywIm`gTC2t=peS1gKVRpRvGJbDjliX0D zGYsR>yB;Fr+(NZ1HHP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K75=dXg-k<|#+YhM(xs;k7ulI< z^mbVAOM%xLpwH_MxIF<+pO3CSKSy02-!s4d^()a+Q-_Fu02kZq2S6Y$r2qf`07*qo IM6N<$f + +
+
+

{% trans "Install PrestaShop" %}

+

{% trans "One-click PrestaShop Install!" %}

+
+ + +
+
+

+ {{ domainName }} - {% trans "Installation Details" %} +

+
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + + +
+ +
+ +
+

{$ currentStatus $}

+
+ +
+
+ 70% Complete +
+
+ + + + +
+

{% trans "Installation failed. Error message:" %} {$ errorMessage $}

+
+ +
+

{% trans "Installation successful. Visit:" %} {$ installationURL $}

+
+ + + +
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+ + +
+
+ +
+ +
+ +
+
+ + +
+ +
+
+
+ + + +
+ + +{% endblock %} \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index a9a1577c8..6b2be8bb6 100644 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -966,10 +966,10 @@
- + - + {% trans "Joomla" %} @@ -988,6 +988,19 @@
+ + + + diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index a6f46f6d0..da55fb78c 100644 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -88,6 +88,11 @@ urlpatterns = [ url(r'^installJoomla$', views.installJoomla, name='installJoomla'), url(r'^(?P([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'), + ## PrestaShop Install + + url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'), + url(r'^(?P([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'), + ## Git url(r'^(?P([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'), diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index e5ed1809c..c50d0fbdf 100644 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -2345,7 +2345,6 @@ def joomlaInstall(request, domain): except KeyError: return redirect(loadLoginPage) - def installJoomla(request): try: val = request.session['userID'] @@ -2672,4 +2671,70 @@ def changeBranch(request): except KeyError, msg: status = {"status":0,"error":str(msg)} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]") + return HttpResponse("Not Logged in as admin") + +def installPrestaShop(request, domain): + try: + val = request.session['userID'] + admin = Administrator.objects.get(pk=val) + try: + if admin.type != 1: + website = Websites.objects.get(domain=domain) + if website.admin != admin: + raise BaseException('You do not own this website.') + + + return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName' : domain}) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg)) + return HttpResponse(str(msg)) + except KeyError: + return redirect(loadLoginPage) + +def prestaShopInstall(request): + try: + val = request.session['userID'] + admin = Administrator.objects.get(id=val) + if request.method == 'POST': + try: + data = json.loads(request.body) + + mailUtilities.checkHome() + + extraArgs = {} + extraArgs['admin'] = admin + extraArgs['domainName'] = data['domain'] + extraArgs['home'] = data['home'] + extraArgs['shopName'] = data['shopName'] + extraArgs['firstName'] = data['firstName'] + extraArgs['lastName'] = data['lastName'] + extraArgs['databasePrefix'] = data['databasePrefix'] + extraArgs['email'] = data['email'] + extraArgs['password'] = data['password'] + extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) + + if data['home'] == '0': + extraArgs['path'] = data['path'] + + background = ApplicationInstaller('prestashop', extraArgs) + background.start() + + time.sleep(2) + + data_ret = {'installStatus': 1, 'error_message': 'None', 'tempStatusPath': extraArgs['tempStatusPath']} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + + + ## Installation ends + + except BaseException, msg: + data_ret = {'installStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except KeyError, msg: + status = {"installStatus":0,"error":str(msg)} + logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installJoomla]") return HttpResponse("Not Logged in as admin") \ No newline at end of file