Browse Source

removed hardcoded value from import_slow_log.py ,stack.py and debug.py file and added doc string in clean.py,secure.py

bugfixes
shital.rtcamp 10 years ago
parent
commit
6970efd391
  1. 2
      docs/ee.8
  2. 3
      ee/cli/plugins/clean.py
  3. 35
      ee/cli/plugins/debug.py
  4. 20
      ee/cli/plugins/import_slow_log.py
  5. 3
      ee/cli/plugins/secure.py
  6. 369
      ee/cli/plugins/stack.py

2
docs/ee.8

@ -1,4 +1,4 @@
.TH ee 8 "EasyEngine (ee) version: 3.0" "Feb 2,2015" "EasyEngine" .TH ee 8 "EasyEngine (ee) version: 3.0" "Feb 2,2014" "EasyEngine"
.SH NAME .SH NAME
.B EasyEngine (ee) .B EasyEngine (ee)
\- Manage Nginx Based Websites. \- Manage Nginx Based Websites.

3
ee/cli/plugins/clean.py

@ -50,6 +50,7 @@ class EECleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_memcache(self): def clean_memcache(self):
"""This function Clears memcache"""
try: try:
if(EEAptGet.is_installed(self, "memcached")): if(EEAptGet.is_installed(self, "memcached")):
EEService.restart_service(self, "memcached") EEService.restart_service(self, "memcached")
@ -62,6 +63,7 @@ class EECleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_fastcgi(self): def clean_fastcgi(self):
"""This function clears Fastcgi cache"""
if(os.path.isdir("/var/run/nginx-cache")): if(os.path.isdir("/var/run/nginx-cache")):
Log.info(self, "Cleaning NGINX FastCGI cache") Log.info(self, "Cleaning NGINX FastCGI cache")
EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
@ -70,6 +72,7 @@ class EECleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_opcache(self): def clean_opcache(self):
"""This function clears opcache"""
try: try:
Log.info(self, "Cleaning opcache") Log.info(self, "Cleaning opcache")
wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache"

35
ee/cli/plugins/debug.py

@ -7,6 +7,7 @@ from ee.core.mysql import EEMysql
from ee.core.services import EEService from ee.core.services import EEService
from ee.core.logging import Log from ee.core.logging import Log
from ee.cli.plugins.site_functions import logwatch from ee.cli.plugins.site_functions import logwatch
from ee.core.variables import EEVariables
import os import os
import configparser import configparser
import glob import glob
@ -102,8 +103,9 @@ class EEDebugController(CementBaseController):
else: else:
Log.info(self, "Debug for site allready enabled") Log.info(self, "Debug for site allready enabled")
self.msg = self.msg + ['/var/www/{0}/logs/error.log' self.msg = self.msg + ['{0}{1}/logs/error.log'
.format(self.app.pargs.site_name)] .format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
else: else:
Log.info(self, "{0} domain not valid" Log.info(self, "{0} domain not valid"
@ -261,9 +263,11 @@ class EEDebugController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def debug_wp(self): def debug_wp(self):
if self.start and self.app.pargs.site_name: if self.start and self.app.pargs.site_name:
wp_config = ("/var/www/{0}/wp-config.php" wp_config = ("{0}{1}/wp-config.php"
.format(self.app.pargs.site_name)) .format(EEVariables.ee_webroot,
webroot = "/var/www/{0}".format(self.app.pargs.site_name) self.app.pargs.site_name))
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if os.path.isfile(wp_config): if os.path.isfile(wp_config):
if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |"
" grep true".format(wp_config)): " grep true".format(wp_config)):
@ -287,18 +291,21 @@ class EEDebugController(CementBaseController):
else: else:
Log.info(self, "WordPress debug log already enabled") Log.info(self, "WordPress debug log already enabled")
self.msg = self.msg + ['/var/www/{0}/htdocs/wp-content' self.msg = self.msg + ['{0}{1}/htdocs/wp-content'
'/debug.log' '/debug.log'
.format(self.app.pargs.site_name)] .format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
else: else:
Log.info(self, "{0} domain not valid" Log.info(self, "{0} domain not valid"
.format(self.app.pargs.site_name)) .format(self.app.pargs.site_name))
elif not self.start and self.app.pargs.site_name: elif not self.start and self.app.pargs.site_name:
wp_config = ("/var/www/{0}/wp-config.php" wp_config = ("{0}{1}/wp-config.php"
.format(self.app.pargs.site_name)) .format(EEVariables.ee_webroot,
webroot = "/var/www/{0}".format(self.app.pargs.site_name) self.app.pargs.site_name))
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if os.path.isfile(wp_config): if os.path.isfile(wp_config):
if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | "
"grep true".format(wp_config)): "grep true".format(wp_config)):
@ -365,10 +372,12 @@ class EEDebugController(CementBaseController):
Log.info(self, "Nginx rewrite logs for {0} allready setup" Log.info(self, "Nginx rewrite logs for {0} allready setup"
.format(self.app.pargs.site_name)) .format(self.app.pargs.site_name))
if ('/var/www/{0}/logs/error.log'.format(self.app.pargs.site_name) if ('{0}{1}/logs/error.log'.format(EEVariables.ee_webroot,
self.app.pargs.site_name)
not in self.msg): not in self.msg):
self.msg = self.msg + ['/var/www/{0}/logs/error.log' self.msg = self.msg + ['{0}{1}/logs/error.log'
.format(self.app.pargs.site_name)] .format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
# Stop Nginx rewrite for site # Stop Nginx rewrite for site
elif not self.start and self.app.pargs.site_name: elif not self.start and self.app.pargs.site_name:

20
ee/cli/plugins/import_slow_log.py

@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.logging import Log from ee.core.logging import Log
from ee.core.variables import EEVariables
import os import os
@ -18,20 +19,25 @@ class EEImportslowlogController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
if os.path.isdir("/var/www/22222/htdocs/db/anemometer"): if os.path.isdir("{0}22222/htdocs/db/anemometer"
.format(EEVariables.ee_webroot)):
if os.path.isfile("/var/log/mysql/mysql-slow.log"): if os.path.isfile("/var/log/mysql/mysql-slow.log"):
# Get Anemometer user name and password # Get Anemometer user name and password
Log.error(self, "Importing MySQL slow log to Anemometer") Log.error(self, "Importing MySQL slow log to Anemometer")
host = os.popen("grep -e \"\'host\'\" /var/www/22222/htdocs/" host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
"db/anemometer/conf/config.inc.php " .format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | " "| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read() "tr -d '\n'").read()
user = os.popen("grep -e \"\'user\'\" /var/www/22222/htdocs/" user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
"db/anemometer/conf/config.inc.php " .format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | " "| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read() "tr -d '\n'").read()
password = os.popen("grep -e \"\'password\'\" /var/www/22222/" password = os.popen("grep -e \"\'password\'\" {0}22222/"
"htdocs/db/anemometer/conf/config.inc.php " .format(EEVariables.ee_webroot)
+ "htdocs/db/anemometer/conf"
"/config.inc.php "
"| head -1 | cut -d\\\' -f4 | " "| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read() "tr -d '\n'").read()

3
ee/cli/plugins/secure.py

@ -44,6 +44,7 @@ class EESecureController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def secure_auth(self): def secure_auth(self):
"""This function Secures authentication"""
passwd = ''.join([random.choice passwd = ''.join([random.choice
(string.ascii_letters + string.digits) (string.ascii_letters + string.digits)
for n in range(6)]) for n in range(6)])
@ -74,6 +75,7 @@ class EESecureController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def secure_port(self): def secure_port(self):
"""This function Secures port"""
while not self.app.pargs.user_input.isdigit(): while not self.app.pargs.user_input.isdigit():
Log.info(self, "Please Enter valid port number ") Log.info(self, "Please Enter valid port number ")
self.app.pargs.user_input = input("EasyEngine admin port [22222]:") self.app.pargs.user_input = input("EasyEngine admin port [22222]:")
@ -100,6 +102,7 @@ class EESecureController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def secure_ip(self): def secure_ip(self):
"""This function Secures IP"""
# TODO:remaining with ee.conf updation in file # TODO:remaining with ee.conf updation in file
newlist = [] newlist = []
if not self.app.pargs.user_input: if not self.app.pargs.user_input:

369
ee/cli/plugins/stack.py

@ -15,6 +15,7 @@ from ee.core.git import EEGit
from ee.core.checkfqdn import check_fqdn from ee.core.checkfqdn import check_fqdn
from pynginxconfig import NginxConfig from pynginxconfig import NginxConfig
from ee.core.services import EEService from ee.core.services import EEService
from ee.core.variables import EEVariables
import random import random
import string import string
import configparser import configparser
@ -284,48 +285,64 @@ class EEStackController(CementBaseController):
'sites-enabled/' 'sites-enabled/'
'22222.conf']) '22222.conf'])
# Create log and cert folder and softlinks # Create log and cert folder and softlinks
if not os.path.exists('/var/www/22222/logs'): if not os.path.exists('{0}22222/logs'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating directory " Log.debug(self, "Creating directory "
"/var/www/22222/logs ") "{0}22222/logs "
os.makedirs('/var/www/22222/logs') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/logs'
.format(EEVariables.ee_webroot))
if not os.path.exists('/var/www/22222/cert'): if not os.path.exists('{0}22222/cert'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating directory " Log.debug(self, "Creating directory "
"/var/www/22222/cert") "{0}22222/cert"
os.makedirs('/var/www/22222/cert') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/cert'
.format(EEVariables.ee_webroot))
EEFileUtils.create_symlink(self, ['/var/log/nginx/' EEFileUtils.create_symlink(self, ['/var/log/nginx/'
'22222.access.log', '22222.access.log',
'/var/www/22222/' '{0}22222/'
'logs/access.log']) 'logs/access.log'
.format(EEVariables.ee_webroot)]
)
EEFileUtils.create_symlink(self, ['/var/log/nginx/' EEFileUtils.create_symlink(self, ['/var/log/nginx/'
'22222.error.log', '22222.error.log',
'/var/www/22222/' '{0}22222/'
'logs/error.log']) 'logs/error.log'
.format(EEVariables.ee_webroot)]
)
EEShellExec.cmd_exec(self, "openssl genrsa -out " EEShellExec.cmd_exec(self, "openssl genrsa -out "
"/var/www/22222/cert/22222.key 2048") "{0}22222/cert/22222.key 2048"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "openssl req -new -batch -subj " EEShellExec.cmd_exec(self, "openssl req -new -batch -subj "
"/commonName=127.0.0.1/ -key " "/commonName=127.0.0.1/ -key "
"/var/www/22222/cert/22222.key " "{0}22222/cert/22222.key "
"-out /var/www/22222/cert/" "-out {0}22222/cert/"
"22222.csr") "22222.csr"
.format(EEVariables.ee_webroot))
EEFileUtils.mvfile(self, "/var/www/22222/cert/22222.key", EEFileUtils.mvfile(self, "{0}22222/cert/22222.key"
"/var/www/22222/cert/" .format(EEVariables.ee_webroot),
"22222.key.org") "{0}22222/cert/"
"22222.key.org"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "openssl rsa -in " EEShellExec.cmd_exec(self, "openssl rsa -in "
"/var/www/22222/cert/" "{0}22222/cert/"
"22222.key.org -out " "22222.key.org -out "
"/var/www/22222/cert/22222.key") "{0}22222/cert/22222.key"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "openssl x509 -req -days 3652 " EEShellExec.cmd_exec(self, "openssl x509 -req -days 3652 "
"-in /var/www/22222/cert/" "-in {0}22222/cert/"
"22222.csr -signkey /var/www/" "22222.csr -signkey {0}"
"22222/cert/22222.key -out " "22222/cert/22222.key -out "
"/var/www/22222/cert/22222.crt") "{0}22222/cert/22222.crt"
.format(EEVariables.ee_webroot))
# Nginx Configation into GIT # Nginx Configation into GIT
EEGit.add(self, EEGit.add(self,
["/etc/nginx"], msg="Adding Nginx into Git") ["/etc/nginx"], msg="Adding Nginx into Git")
@ -405,23 +422,33 @@ class EEStackController(CementBaseController):
"profiler_enable] = off\n") "profiler_enable] = off\n")
# PHP and Debug pull configuration # PHP and Debug pull configuration
if not os.path.exists('/var/www/22222/htdocs/fpm/status/'): if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(EEVariables.ee_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'/var/www/22222/htdocs/fpm/status/ ') '{0}22222/htdocs/fpm/status/ '
os.makedirs('/var/www/22222/htdocs/fpm/status/') .format(EEVariables.ee_webroot))
open('/var/www/22222/htdocs/fpm/status/debug', 'a').close() os.makedirs('{0}22222/htdocs/fpm/status/'
open('/var/www/22222/htdocs/fpm/status/php', 'a').close() .format(EEVariables.ee_webroot))
open('{0}22222/htdocs/fpm/status/debug'
.format(EEVariables.ee_webroot), 'a').close()
open('{0}22222/htdocs/fpm/status/php'
.format(EEVariables.ee_webroot), 'a').close()
# Write info.php # Write info.php
if not os.path.exists('/var/www/22222/htdocs/php/'): if not os.path.exists('{0}22222/htdocs/php/'
.format(EEVariables.ee_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'/var/www/22222/htdocs/php/ ') '{0}22222/htdocs/php/ '
os.makedirs('/var/www/22222/htdocs/php') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/php'
.format(EEVariables.ee_webroot))
with open("/var/www/22222/htdocs/php/info.php", "w") as myfile: with open("{0}22222/htdocs/php/info.php"
.format(EEVariables.ee_webroot), "w") as myfile:
myfile.write("<?php\nphpinfo();\n?>") myfile.write("<?php\nphpinfo();\n?>")
EEFileUtils.chown(self, "/var/www/22222", 'www-data', EEFileUtils.chown(self, "{0}22222"
.format(EEVariables.ee_webroot), 'www-data',
'www-data', recursive=True) 'www-data', recursive=True)
EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git")
@ -642,31 +669,41 @@ class EEStackController(CementBaseController):
EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/')
Log.debug(self, 'Extracting file /tmp/pma.tar.gz to ' Log.debug(self, 'Extracting file /tmp/pma.tar.gz to '
'loaction /tmp/') 'loaction /tmp/')
if not os.path.exists('/var/www/22222/htdocs/db'): if not os.path.exists('{0}22222/htdocs/db'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating new directory " Log.debug(self, "Creating new directory "
"/var/www/22222/htdocs/db") "{0}22222/htdocs/db"
os.makedirs('/var/www/22222/htdocs/db') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/db'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/phpmyadmin-STABLE/', shutil.move('/tmp/phpmyadmin-STABLE/',
'/var/www/22222/htdocs/db/pma/') '{0}22222/htdocs/db/pma/'
.format(EEVariables.ee_webroot))
Log.debug(self, 'Setting Privileges of www-data:www-data to ' Log.debug(self, 'Setting Privileges of www-data:www-data to '
'/var/www/22222/htdocs/db/pma file ') '{0}22222/htdocs/db/pma file '
.format(EEVariables.ee_webroot))
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/db/pma') # '/var/www/22222/htdocs/db/pma')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
if any('/tmp/memcache.tar.gz' == x[1] if any('/tmp/memcache.tar.gz' == x[1]
for x in packages): for x in packages):
Log.debug(self, "Extracting memcache.tar.gz to location" Log.debug(self, "Extracting memcache.tar.gz to location"
" /var/www/22222/htdocs/cache/memcache ") " {0}22222/htdocs/cache/memcache "
.format(EEVariables.ee_webroot))
EEExtract.extract(self, '/tmp/memcache.tar.gz', EEExtract.extract(self, '/tmp/memcache.tar.gz',
'/var/www/22222/htdocs/cache/memcache') '{0}22222/htdocs/cache/memcache'
.format(EEVariables.ee_webroot))
Log.debug(self, "Setting Privileges to " Log.debug(self, "Setting Privileges to "
"/var/www/22222/htdocs/cache/memcache file") "{0}22222/htdocs/cache/memcache file"
.format(EEVariables.ee_webroot))
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/cache/memcache') # '/var/www/22222/htdocs/cache/memcache')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
@ -676,20 +713,27 @@ class EEStackController(CementBaseController):
Log.debug(self, "Extracting file webgrind.tar.gz to " Log.debug(self, "Extracting file webgrind.tar.gz to "
"location /tmp/ ") "location /tmp/ ")
EEExtract.extract(self, '/tmp/webgrind.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/webgrind.tar.gz', '/tmp/')
if not os.path.exists('/var/www/22222/htdocs/php'): if not os.path.exists('{0}22222/htdocs/php'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating directroy " Log.debug(self, "Creating directroy "
"/var/www/22222/htdocs/php") "{0}22222/htdocs/php"
os.makedirs('/var/www/22222/htdocs/php') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/php'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/webgrind-master/', shutil.move('/tmp/webgrind-master/',
'/var/www/22222/htdocs/php/webgrind') '{0}22222/htdocs/php/webgrind'
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'" EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'"
"/usr/bin/dot\'\" /var/www/22222/htdocs/" "/usr/bin/dot\'\" {0}22222/htdocs/"
"php/webgrind/config.php") "php/webgrind/config.php"
.format(EEVariables.ee_webroot))
Log.debug(self, "Setting Privileges of www-data:www-data to " Log.debug(self, "Setting Privileges of www-data:www-data to "
"/var/www/22222/htdocs/php/webgrind/ file ") "{0}22222/htdocs/php/webgrind/ file "
.format(EEVariables.ee_webroot))
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/php/webgrind/') # '/var/www/22222/htdocs/php/webgrind/')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
@ -699,14 +743,18 @@ class EEStackController(CementBaseController):
Log.debug(self, "Extracting file anemometer.tar.gz to " Log.debug(self, "Extracting file anemometer.tar.gz to "
"location /tmp/ ") "location /tmp/ ")
EEExtract.extract(self, '/tmp/anemometer.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/anemometer.tar.gz', '/tmp/')
if not os.path.exists('/var/www/22222/htdocs/db/'): if not os.path.exists('{0}22222/htdocs/db/'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating directory") Log.debug(self, "Creating directory")
os.makedirs('/var/www/22222/htdocs/db/') os.makedirs('{0}22222/htdocs/db/'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/Anemometer-master', shutil.move('/tmp/Anemometer-master',
'/var/www/22222/htdocs/db/anemometer') '{0}22222/htdocs/db/anemometer'
.format(EEVariables.ee_webroot))
chars = ''.join(random.sample(string.ascii_letters, 8)) chars = ''.join(random.sample(string.ascii_letters, 8))
EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db' EEShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db'
'/anemometer/install.sql') '/anemometer/install.sql'
.format(EEVariables.ee_webroot))
EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' EEMysql.execute(self, 'grant select on *.* to \'anemometer\''
'@\'{0}\''.format(self.app.config.get('mysql', '@\'{0}\''.format(self.app.config.get('mysql',
'grant-host'))) 'grant-host')))
@ -720,8 +768,9 @@ class EEStackController(CementBaseController):
Log.debug(self, "configration Anemometer") Log.debug(self, "configration Anemometer")
data = dict(host=EEVariables.ee_mysql_host, port='3306', data = dict(host=EEVariables.ee_mysql_host, port='3306',
user='anemometer', password=chars) user='anemometer', password=chars)
ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' ee_anemometer = open('{0}22222/htdocs/db/anemometer'
'/conf/config.inc.php', 'w') '/conf/config.inc.php'
.format(EEVariables.ee_webroot), 'w')
self.app.render((data), 'anemometer.mustache', self.app.render((data), 'anemometer.mustache',
out=ee_anemometer) out=ee_anemometer)
ee_anemometer.close() ee_anemometer.close()
@ -736,27 +785,33 @@ class EEStackController(CementBaseController):
Log.debug(self, "Extracting ViMbAdmin.tar.gz to " Log.debug(self, "Extracting ViMbAdmin.tar.gz to "
"location /tmp/") "location /tmp/")
EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/')
if not os.path.exists('/var/www/22222/htdocs/'): if not os.path.exists('{0}22222/htdocs/'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating directory " Log.debug(self, "Creating directory "
"/var/www/22222/htdocs/") "{0}22222/htdocs/"
os.makedirs('/var/www/22222/htdocs/') .format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/ViMbAdmin-{0}/' shutil.move('/tmp/ViMbAdmin-{0}/'
.format(EEVariables.ee_vimbadmin), .format(EEVariables.ee_vimbadmin),
'/var/www/22222/htdocs/vimbadmin/') '{0}22222/htdocs/vimbadmin/'
.format(EEVariables.ee_webroot))
# Donwload composer and install ViMbAdmin # Donwload composer and install ViMbAdmin
Log.debug(self, "Downloading composer " Log.debug(self, "Downloading composer "
"https://getcomposer.org/installer | php ") "https://getcomposer.org/installer | php ")
EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" EEShellExec.cmd_exec(self, "cd {0}22222/htdocs"
"/vimbadmin; curl" "/vimbadmin; curl"
" -sS https://getcomposer.org/installer |" " -sS https://getcomposer.org/installer |"
" php") " php".format(EEVariables.ee_webroot))
Log.debug(self, "installation of composer") Log.debug(self, "installation of composer")
EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" EEShellExec.cmd_exec(self, "cd {0}22222/htdocs"
"/vimbadmin && " "/vimbadmin && "
"php composer.phar install --prefer-dist" "php composer.phar install --prefer-dist"
" --no-dev && rm -f /var/www/22222/htdocs" " --no-dev && rm -f {1}22222/htdocs"
"/vimbadmin/composer.phar") "/vimbadmin/composer.phar"
.format(EEVariables.ee_webroot,
EEVariables.ee_webroot))
# Configure vimbadmin database # Configure vimbadmin database
vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) vm_passwd = ''.join(random.sample(string.ascii_letters, 8))
@ -775,27 +830,31 @@ class EEStackController(CementBaseController):
data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host, data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host,
password=vm_passwd) password=vm_passwd)
Log.debug(self, 'Writting the ViMbAdmin configuration to ' Log.debug(self, 'Writting the ViMbAdmin configuration to '
'file /var/www/22222/htdocs/vimbadmin/application/' 'file {0}22222/htdocs/vimbadmin/application/'
'configs/application.ini') 'configs/application.ini'
ee_vmb = open('/var/www/22222/htdocs/vimbadmin/application/' .format(EEVariables.ee_webroot))
'configs/application.ini', 'w') ee_vmb = open('{0}22222/htdocs/vimbadmin/application/'
'configs/application.ini'
.format(EEVariables.ee_webroot), 'w')
self.app.render((data), 'vimbadmin.mustache', self.app.render((data), 'vimbadmin.mustache',
out=ee_vmb) out=ee_vmb)
ee_vmb.close() ee_vmb.close()
shutil.copyfile("/var/www/22222/htdocs/vimbadmin/public/" shutil.copyfile("{0}22222/htdocs/vimbadmin/public/"
".htaccess.dist", ".htaccess.dist"
"/var/www/22222/htdocs/vimbadmin/public/" .format(EEVariables.ee_webroot),
".htaccess") "{0}22222/htdocs/vimbadmin/public/"
".htaccess".format(EEVariables.ee_webroot))
Log.debug(self, "Executing command " Log.debug(self, "Executing command "
"/var/www/22222/htdocs/vimbadmin/bin" "{0}22222/htdocs/vimbadmin/bin"
"/doctrine2-cli.php orm:schema-tool:" "/doctrine2-cli.php orm:schema-tool:"
"create") "create".format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "/var/www/22222/htdocs/vimbadmin" EEShellExec.cmd_exec(self, "{0}22222/htdocs/vimbadmin"
"/bin/doctrine2-cli.php orm:schema-tool:" "/bin/doctrine2-cli.php orm:schema-tool:"
"create") "create".format(EEVariables.ee_webroot))
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
@ -866,13 +925,17 @@ class EEStackController(CementBaseController):
Log.debug(self, "Extracting file /tmp/roundcube.tar.gz " Log.debug(self, "Extracting file /tmp/roundcube.tar.gz "
"to location /tmp/ ") "to location /tmp/ ")
EEExtract.extract(self, '/tmp/roundcube.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/roundcube.tar.gz', '/tmp/')
if not os.path.exists('/var/www/roundcubemail'): if not os.path.exists('{0}roundcubemail'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating new directory " Log.debug(self, "Creating new directory "
" /var/www/roundcubemail/") " {0}roundcubemail/"
os.makedirs('/var/www/roundcubemail/') .format(EEVariables.ee_webroot))
os.makedirs('{0}roundcubemail/'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/roundcubemail-{0}/' shutil.move('/tmp/roundcubemail-{0}/'
.format(EEVariables.ee_roundcube), .format(EEVariables.ee_roundcube),
'/var/www/roundcubemail/htdocs') '{0}roundcubemail/htdocs'
.format(EEVariables.ee_webroot))
# Configure roundcube database # Configure roundcube database
rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) rc_passwd = ''.join(random.sample(string.ascii_letters, 8))
@ -886,33 +949,39 @@ class EEStackController(CementBaseController):
"'{1}'".format(self.app.config.get( "'{1}'".format(self.app.config.get(
'mysql', 'grant-host'), 'mysql', 'grant-host'),
rc_passwd)) rc_passwd))
EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/" EEShellExec.cmd_exec(self, "mysql roundcubemail < {0}"
"roundcubemail/htdocs/SQL/mysql" "roundcubemail/htdocs/SQL/mysql"
".initial.sql") ".initial.sql"
.format(EEVariables.ee_webroot))
shutil.copyfile("/var/www/roundcubemail/htdocs/config/"
"config.inc.php.sample", shutil.copyfile("{0}roundcubemail/htdocs/config/"
"/var/www/roundcubemail/htdocs/config/" "config.inc.php.sample"
"config.inc.php") .format(EEVariables.ee_webroot),
"{0}roundcubemail/htdocs/config/"
"config.inc.php"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:" EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:"
"pass@localhost/roundcubemail\'mysql://" "pass@localhost/roundcubemail\'mysql://"
"roundcube:{0}@{1}/" "roundcube:{0}@{1}/"
"roundcubemail\'\" /var/www/roundcubemail" "roundcubemail\'\" {2}roundcubemail"
"/htdocs/config/config." "/htdocs/config/config."
"inc.php" "inc.php"
.format(rc_passwd, .format(rc_passwd,
EEVariables.ee_mysql_host)) EEVariables.ee_mysql_host,
EEVariables.ee_webroot))
# Sieve plugin configuration in roundcube # Sieve plugin configuration in roundcube
EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\["
"\'plugins\'\] " "\'plugins\'\] "
"= array(:\$config\['plugins'\] = " "= array(:\$config\['plugins'\] = "
"array(\\n \'sieverules\',:\\\" " "array(\\n \'sieverules\',:\\\" "
"/var/www/roundcubemail/htdocs/config" "{0}roundcubemail/htdocs/config"
"/config.inc.php\"") .format(EEVariables.ee_webroot)
+ "/config.inc.php\"")
EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']" EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']"
"=4190;\" >> /var/www/roundcubemail" "=4190;\" >> {0}roundcubemail"
"/htdocs/config/config.inc.php") .format(EEVariables.ee_webroot)
+ "/htdocs/config/config.inc.php")
data = dict(site_name='webmail', www_domain='webmail', data = dict(site_name='webmail', www_domain='webmail',
static=False, static=False,
@ -935,23 +1004,29 @@ class EEStackController(CementBaseController):
'/etc/nginx/sites-enabled/' '/etc/nginx/sites-enabled/'
'webmail.conf']) 'webmail.conf'])
# Create log folder and softlinks # Create log folder and softlinks
if not os.path.exists('/var/www/roundcubemail/logs'): if not os.path.exists('{0}roundcubemail/logs'
os.makedirs('/var/www/roundcubemail/logs') .format(EEVariables.ee_webroot)):
os.makedirs('{0}roundcubemail/logs'
.format(EEVariables.ee_webroot))
EEFileUtils.create_symlink(self, ['/var/log/nginx/' EEFileUtils.create_symlink(self, ['/var/log/nginx/'
'webmail.access.log', 'webmail.access.log',
'/var/www/roundcubemail/' '{0}roundcubemail/'
'logs/access.log']) 'logs/access.log'
.format(EEVariables.ee_webroot)])
EEFileUtils.create_symlink(self, ['/var/log/nginx/' EEFileUtils.create_symlink(self, ['/var/log/nginx/'
'webmail.error.log', 'webmail.error.log',
'/var/www/roundcubemail/' '{0}roundcubemail/'
'logs/error.log']) 'logs/error.log'
.format(EEVariables.ee_webroot)])
# Remove roundcube installer # Remove roundcube installer
EEService.reload_service(self, 'nginx') EEService.reload_service(self, 'nginx')
EEFileUtils.remove(self, ["/var/www/roundcubemail" EEFileUtils.remove(self, ["{0}roundcubemail"
"/htdocs/installer"]) "/htdocs/installer"
EEFileUtils.chown(self, '/var/www/roundcubemail', .format(EEVariables.ee_webroot)])
EEFileUtils.chown(self, '{0}roundcubemail'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
@ -1070,8 +1145,9 @@ class EEStackController(CementBaseController):
packages = packages + [["http://downloads.sourceforge.net/" packages = packages + [["http://downloads.sourceforge.net/"
"adminer/adminer-{0}.php" "adminer/adminer-{0}.php"
"".format(EEVariables.ee_adminer), "".format(EEVariables.ee_adminer),
"/var/www/22222/" "{0}22222/"
"htdocs/db/adminer/index.php", "htdocs/db/adminer/index.php"
.format(EEVariables.ee_webroot),
"Adminer"]] "Adminer"]]
if self.app.pargs.mailscanner: if self.app.pargs.mailscanner:
@ -1086,22 +1162,29 @@ class EEStackController(CementBaseController):
["https://raw.githubusercontent.com" ["https://raw.githubusercontent.com"
"/rtCamp/eeadmin/master/cache/nginx/" "/rtCamp/eeadmin/master/cache/nginx/"
"clean.php", "clean.php",
"/var/www/22222/htdocs/cache/" "{0}22222/htdocs/cache/"
"nginx/clean.php", "clean.php"], "nginx/clean.php"
.format(EEVariables.ee_webroot),
"clean.php"],
["https://raw.github.com/rlerdorf/" ["https://raw.github.com/rlerdorf/"
"opcache-status/master/opcache.php", "opcache-status/master/opcache.php",
"/var/www/22222/htdocs/cache/" "{0}22222/htdocs/cache/"
"opcache/opcache.php", "opcache.php"], "opcache/opcache.php"
.format(EEVariables.ee_webroot),
"opcache.php"],
["https://raw.github.com/amnuts/" ["https://raw.github.com/amnuts/"
"opcache-gui/master/index.php", "opcache-gui/master/index.php",
"/var/www/22222/htdocs/" "{0}22222/htdocs/"
"cache/opcache/opgui.php", "cache/opcache/opgui.php"
.format(EEVariables.ee_webroot),
"Opgui"], "Opgui"],
["https://gist.github.com/ck-on/4959032" ["https://gist.github.com/ck-on/4959032"
"/raw/0b871b345fd6cfcd6d2be030c1f33d1" "/raw/0b871b345fd6cfcd6d2be030c1f33d1"
"ad6a475cb/ocp.php", "ad6a475cb/ocp.php",
"/var/www/22222/htdocs/cache/" "{0}22222/htdocs/cache/"
"opcache/ocp.php", "OCP.php"], "opcache/ocp.php"
.format(EEVariables.ee_webroot),
"OCP.php"],
["https://github.com/jokkedk/webgrind/" ["https://github.com/jokkedk/webgrind/"
"archive/master.tar.gz", "archive/master.tar.gz",
'/tmp/webgrind.tar.gz', 'Webgrind'], '/tmp/webgrind.tar.gz', 'Webgrind'],
@ -1170,8 +1253,10 @@ class EEStackController(CementBaseController):
Log.debug(self, "Removing mail server packages") Log.debug(self, "Removing mail server packages")
apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mail
apt_packages = apt_packages + EEVariables.ee_mailscanner apt_packages = apt_packages + EEVariables.ee_mailscanner
packages = packages + ["/var/www/22222/htdocs/vimbadmin", packages = packages + ["{0}22222/htdocs/vimbadmin"
"/var/www/roundcubemail"] .format(EEVariables.ee_webroot),
"{0}roundcubemail"
.format(EEVariables.ee_webroot)]
if EEShellExec.cmd_exec(self, "mysqladmin ping"): if EEShellExec.cmd_exec(self, "mysqladmin ping"):
EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS vimbadmin")
EEMysql.execute(self, "drop database IF EXISTS roundcubemail") EEMysql.execute(self, "drop database IF EXISTS roundcubemail")
@ -1196,19 +1281,25 @@ class EEStackController(CementBaseController):
packages = packages + ['/usr/bin/wp'] packages = packages + ['/usr/bin/wp']
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
Log.debug(self, "Removing package variable of phpMyAdmin ") Log.debug(self, "Removing package variable of phpMyAdmin ")
packages = packages + ['/var/www/22222/htdocs/db/pma'] packages = packages + ['{0}22222/htdocs/db/pma'
.format(EEVariables.ee_webroot)]
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Removing package variable of Adminer ") Log.debug(self, "Removing package variable of Adminer ")
packages = packages + ['/var/www/22222/htdocs/db/Adminer'] packages = packages + ['{0}22222/htdocs/db/Adminer'
.format(EEVariables.ee_webroot)]
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Removing package variable of utils ") Log.debug(self, "Removing package variable of utils ")
packages = packages + ['/var/www/22222/htdocs/php/webgrind/', packages = packages + ['{0}22222/htdocs/php/webgrind/'
'/var/www/22222/htdocs/cache/opcache', .format(EEVariables.ee_webroot),
'/var/www/22222/htdocs/cache/Nginx/' '{0}22222/htdocs/cache/opcache'
'clean.php', .format(EEVariables.ee_webroot),
'/var/www/22222/htdocs/cache/Memcache', '{0}22222/htdocs/cache/Nginx/'
'clean.php'.format(EEVariables.ee_webroot),
'{0}22222/htdocs/cache/Memcache'
.format(EEVariables.ee_webroot),
'/usr/bin/pt-query-advisor', '/usr/bin/pt-query-advisor',
'/var/www/22222/htdocs/db/Anemometer'] '{0}22222/htdocs/db/Anemometer'
.format(EEVariables.ee_webroot)]
if len(apt_packages): if len(apt_packages):
Log.debug(self, "Removing apt_packages") Log.debug(self, "Removing apt_packages")
@ -1249,8 +1340,10 @@ class EEStackController(CementBaseController):
Log.debug(self, "Removing mail server packages") Log.debug(self, "Removing mail server packages")
apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mail
apt_packages = apt_packages + EEVariables.ee_mailscanner apt_packages = apt_packages + EEVariables.ee_mailscanner
packages = packages + ["/var/www/22222/htdocs/vimbadmin", packages = packages + ["{0}22222/htdocs/vimbadmin"
"/var/www/roundcubemail"] .format(EEVariables.ee_webroot),
"{0}roundcubemail"
.format(EEVariables.ee_webroot)]
if EEShellExec.cmd_exec(self, "mysqladmin ping"): if EEShellExec.cmd_exec(self, "mysqladmin ping"):
EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS vimbadmin")
EEMysql.execute(self, "drop database IF EXISTS roundcubemail") EEMysql.execute(self, "drop database IF EXISTS roundcubemail")
@ -1274,20 +1367,26 @@ class EEStackController(CementBaseController):
Log.debug(self, "Purge package variable WPCLI") Log.debug(self, "Purge package variable WPCLI")
packages = packages + ['/usr/bin/wp'] packages = packages + ['/usr/bin/wp']
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
packages = packages + ['/var/www/22222/htdocs/db/pma'] packages = packages + ['{0}22222/htdocs/db/pma'.
format(EEVariables.ee_webroot)]
Log.debug(self, "Purge package variable phpMyAdmin") Log.debug(self, "Purge package variable phpMyAdmin")
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Purge package variable Adminer") Log.debug(self, "Purge package variable Adminer")
packages = packages + ['/var/www/22222/htdocs/db/adminer'] packages = packages + ['{0}22222/htdocs/db/adminer'
.format(EEVariables.ee_webroot)]
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Purge package variable utils") Log.debug(self, "Purge package variable utils")
packages = packages + ['/var/www/22222/htdocs/php/webgrind/', packages = packages + ['{0}22222/htdocs/php/webgrind/'
'/var/www/22222/htdocs/cache/opcache', .format(EEVariables.ee_webroot),
'/var/www/22222/htdocs/cache/nginx/' '{0}22222/htdocs/cache/opcache'
'clean.php', .format(EEVariables.ee_webroot),
'/var/www/22222/htdocs/cache/memcache', '{0}22222/htdocs/cache/nginx/'
'clean.php'.format(EEVariables.ee_webroot),
'{0}22222/htdocs/cache/memcache'
.format(EEVariables.ee_webroot),
'/usr/bin/pt-query-advisor', '/usr/bin/pt-query-advisor',
'/var/www/22222/htdocs/db/anemometer' '{0}22222/htdocs/db/anemometer'
.format(EEVariables.ee_webroot)
] ]
if len(apt_packages): if len(apt_packages):

Loading…
Cancel
Save