Browse Source

Merge branch 'python' of github.com:rtCamp/easyengine into python

bugfixes
shital.rtcamp 10 years ago
parent
commit
a8e821d459
  1. 169
      config/bash_completion.d/ee_auto.rc
  2. 7
      config/plugins.d/import_slow_log.conf
  3. 2
      ee/cli/bootstrap.py
  4. 6
      ee/cli/controllers/base.py
  5. 26
      ee/cli/controllers/isl.py
  6. 2
      ee/cli/main.py
  7. 52
      ee/cli/plugins/clean.py
  8. 41
      ee/cli/plugins/debug.py
  9. 50
      ee/cli/plugins/example.py
  10. 63
      ee/cli/plugins/import_slow_log.py
  11. 16
      ee/cli/plugins/info.py
  12. 20
      ee/cli/plugins/secure.py
  13. 203
      ee/cli/plugins/site.py
  14. 133
      ee/cli/plugins/site_functions.py
  15. 14
      ee/cli/plugins/sitedb.py
  16. 2
      ee/cli/plugins/stack.py
  17. 16
      ee/cli/plugins/stack_services.py
  18. 1
      ee/cli/templates/default.mustache
  19. 1
      ee/core/addswap.py
  20. 12
      ee/core/apt_repo.py
  21. 11
      ee/core/aptget.py
  22. 9
      ee/core/checkpackage.py
  23. 3
      ee/core/database.py
  24. 19
      ee/core/domaincheck.py
  25. 1
      ee/core/domainvalidate.py
  26. 10
      ee/core/dummy.py
  27. 3
      ee/core/git.py
  28. 23
      ee/core/info.py
  29. 1
      ee/core/logging.py
  30. 8
      ee/core/mysql.py
  31. 11
      ee/core/permissions.py
  32. 4
      ee/core/shellexec.py
  33. 8
      ee/core/swapcreation.py
  34. 8
      ee/core/symboliclink.py
  35. 12
      ee/core/variables.py
  36. 16
      ee/utils/test.py
  37. 25
      setup.py
  38. 0
      tests/core/test_exc.py

169
config/bash_completion.d/ee_auto.rc

@ -0,0 +1,169 @@
_ee_complete()
{
local cur prev BASE_LEVEL
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
mprev=${COMP_WORDS[COMP_CWORD-2]}
# SETUP THE BASE LEVEL (everything after "ee")
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen \
-W "stack site debug clean secure" \
-- $cur) )
# SETUP THE SECOND LEVEL (EVERYTHING AFTER "ee second")
elif [ $COMP_CWORD -eq 2 ]; then
case "$prev" in
# HANDLE EVERYTHING AFTER THE SECOND LEVEL NAMESPACE
"clean")
COMPREPLY=( $(compgen \
-W "--memcache --opcache --fastcgi --all" \
-- $cur) )
;;
# IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE
"debug")
COMPREPLY=( $(compgen \
-W "--start --nginx --php --fpm --mysql -i --interactive --stop " \
-- $cur) )
;;
"stack")
COMPREPLY=( $(compgen \
-W "install purge reload remove restart start status stop" \
-- $cur) )
;;
"site")
COMPREPLY=( $(compgen \
-W "create delete disable edit enable info list log show update" \
-- $cur) )
;;
"secure")
COMPREPLY=( $(compgen \
-W "--auth --port --ip" \
-- $cur) )
;;
"info")
COMPREPLY=( $(compgen \
-W "--mysql --php --nginx" \
-- $cur) )
;;
# EVERYTHING ELSE
*)
;;
esac
# SETUP THE THIRD LEVEL (EVERYTHING AFTER "ee second third")
elif [ $COMP_CWORD -eq 3 ]; then
case "$prev" in
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
"install" | "purge" | "remove" | "start" | "stop" | "reload")
COMPREPLY=( $(compgen \
-W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" \
-- $cur) )
;;
"list")
COMPREPLY=( $(compgen \
-W "--enabled --disabled" \
-- $cur) )
;;
"edit" | "enable" | "info" | "log" | "show" | "cd" | "update" | "delete")
COMPREPLY=( $(compgen \
-W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)" \
-- $cur) )
;;
"disable")
COMPREPLY=( $(compgen \
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)" \
-- $cur) )
;;
*)
;;
esac
if [[ ${COMP_WORDS[1]} == "debug" ]] && [ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]; then
retlist="--start --stop --wp --rewrite -i"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
fi
elif [ $COMP_CWORD -eq 4 ]; then
case "$mprev" in
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
"create" | "update")
COMPREPLY=( $(compgen \
-W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \
-- $cur) )
;;
"delete")
COMPREPLY=( $(compgen \
-W "--db --files --all" \
-- $cur) )
esac
fi
case "$prev" in
"--wpsubdir" | "--wpsubdomain")
COMPREPLY=( $(compgen \
-W "--w3tc --wpfc --wpsc" \
-- $cur) )
;;
"--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot")
if [[ ${COMP_WORDS[1]} == "stack" ]]; then
retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop"
fi
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
;;
"--db" | "--files" | "--all")
retlist="--db --files --all"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
;;
"--memcache" | "--opcache" | "--fastcgi" | "--all")
retlist="--memcache --opcache --fastcgi --all"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
;;
"--auth" | "--port" | "--ip")
retlist="--auth --port --ip"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
;;
*)
;;
esac
return 0
} &&
complete -F _ee_complete ee

7
config/plugins.d/example.conf → config/plugins.d/import_slow_log.conf

@ -1,11 +1,8 @@
### Example Plugin Configuration for EasyEngine
[example]
[import_slow_log]
### If enabled, load a plugin named `example` either from the Python module
### `ee.cli.plugins.example` or from the file path
### `/var/lib/ee/plugins/example.py`
enable_plugin = false
### Additional plugin configuration settings
foo = bar
enable_plugin = true

2
ee/cli/bootstrap.py

@ -5,9 +5,7 @@
from cement.core import handler
from ee.cli.controllers.base import EEBaseController
from ee.cli.controllers.isl import EEImportslowlogController
def load(app):
handler.register(EEBaseController)
handler.register(EEImportslowlogController)

6
ee/cli/controllers/base.py

@ -6,9 +6,9 @@ from cement.core.controller import CementBaseController, expose
class EEBaseController(CementBaseController):
class Meta:
label = 'base'
description = ("easyengine is the commandline tool to manage your"
" websites based on wordpress and nginx with easy to"
" use commands.")
description = ("EasyEngine is the commandline tool to manage your"
" websites based on WordPress and Nginx with easy to"
" use commands")
@expose(hide=True)
def default(self):

26
ee/cli/controllers/isl.py

@ -1,26 +0,0 @@
from cement.core.controller import CementBaseController, expose
class EEImportslowlogController(CementBaseController):
class Meta:
label = 'import_slow_log'
stacked_on = 'base'
stacked_type = 'nested'
description = 'info command used for debugging issued with stack or \
site specific configuration'
arguments = [
(['--mysql'],
dict(help='get mysql configuration information',
action='store_true')),
(['--php'],
dict(help='get php configuration information',
action='store_true')),
(['--nginx'],
dict(help='get nginx configuration information',
action='store_true')),
]
@expose(hide=True)
def default(self):
# TODO Default action for ee debug command
print("Inside EEImportslowlogController.default().")

2
ee/cli/main.py

@ -47,7 +47,7 @@ class EEApp(foundation.CementApp):
# Internal plugins (ship with application code)
plugin_bootstrap = 'ee.cli.plugins'
extensions = ['mustache', 'json']
extensions = ['mustache']
# default output handler
output_handler = 'mustache'

52
ee/cli/plugins/clean.py

@ -1,11 +1,13 @@
"""Clean Plugin for EasyEngine."""
from ee.core.shellexec import EEShellExec
from ee.core.aptget import EEAptGet
from ee.core.services import EEService
from ee.core.logging import Log
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
import os
import urllib.request
from ee.core.logging import Log
def clean_plugin_hook(app):
@ -18,52 +20,50 @@ class EECleanController(CementBaseController):
label = 'clean'
stacked_on = 'base'
stacked_type = 'nested'
description = ('clean command cleans different cache with following '
'options')
description = ('Clean NGINX FastCGI cache, Opcacache, Memcache')
arguments = [
(['--all'],
dict(help='clean all cache', action='store_true')),
dict(help='Clean all cache', action='store_true')),
(['--fastcgi'],
dict(help='clean fastcgi cache', action='store_true')),
dict(help='Clean FastCGI cache', action='store_true')),
(['--memcache'],
dict(help='clean memcache', action='store_true')),
dict(help='Clean MemCache', action='store_true')),
(['--opcache'],
dict(help='clean opcode cache cache', action='store_true'))
dict(help='Clean OpCache', action='store_true'))
]
@expose(hide=True)
def default(self):
# TODO Default action for ee clean command here
if (not (self.app.pargs.all or self.app.pargs.fastcgi or
self.app.pargs.memcache or self.app.pargs.opcache)):
self.clean_fastcgi()
if self.app.pargs.all:
self.clean_memcache()
self.clean_fastcgi()
self.clean_opcache()
if self.app.pargs.fastcgi:
self.clean_fastcgi()
if self.app.pargs.memcache:
self.clean_memcache()
if self.app.pargs.opcache:
self.clean_opcache()
if (not (self.app.pargs.all or self.app.pargs.fastcgi or
self.app.pargs.memcache or self.app.pargs.opcache)):
self.clean_fastcgi()
if self.app.pargs.all:
self.clean_memcache()
self.clean_fastcgi()
self.clean_opcache()
if self.app.pargs.fastcgi:
self.clean_fastcgi()
if self.app.pargs.memcache:
self.clean_memcache()
if self.app.pargs.opcache:
self.clean_opcache()
@expose(hide=True)
def clean_memcache(self):
try:
if(EEAptGet.is_installed("memcached")):
EEService.restart_service(self, "memcached")
Log.info(self, "Cleaning memcache...")
Log.info(self, "Cleaning MemCache")
else:
Log.error(self, "Memcache not installed")
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to restart memcached")
Log.error(self, "Unable to restart Memcached")
@expose(hide=True)
def clean_fastcgi(self):
if(os.path.isdir("/var/run/nginx-cache")):
Log.info(self, "Cleaning NGINX FastCGI cache, please wait...")
Log.info(self, "Cleaning NGINX FastCGI cache")
EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
else:
Log.error(self, "Unable to clean FastCGI cache")
@ -71,12 +71,12 @@ class EECleanController(CementBaseController):
@expose(hide=True)
def clean_opcache(self):
try:
Log.info(self, "Cleaning opcache... ")
Log.info(self, "Cleaning opcache")
wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache"
"/opcache/opgui.php?page=reset").read()
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to clean opacache")
Log.error(self, "Unable to clean OpCache")
def load(app):

41
ee/cli/plugins/debug.py

@ -1,12 +1,12 @@
"""Debug Plugin for EasyEngine."""
"""Debug Plugin for EasyEngine"""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.shellexec import EEShellExec
from ee.core.mysql import EEMysql
from ee.core.services import EEService
import os
from ee.core.logging import Log
import os
def debug_plugin_hook(app):
@ -17,7 +17,7 @@ def debug_plugin_hook(app):
class EEDebugController(CementBaseController):
class Meta:
label = 'debug'
description = 'debug command enables/disbaled stack debug'
description = 'Used for server level debugging'
stacked_on = 'base'
stacked_type = 'nested'
arguments = [
@ -58,7 +58,7 @@ class EEDebugController(CementBaseController):
for ip_addr in debug_address:
if not ("debug_connection "+ip_addr in open('/etc/nginx/'
'nginx.conf').read()):
Log.info(self, "Setting up NGINX debug connection"
Log.info(self, "Setting up Nginx debug connection"
" for "+ip_addr)
EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ "
"\\ $(echo debug_connection "
@ -67,7 +67,7 @@ class EEDebugController(CementBaseController):
self.trigger_nginx = True
if not self.trigger_nginx:
Log.info(self, "NGINX debug connection already enabled")
Log.info(self, "Nginx debug connection already enabled")
self.msg = self.msg + [" /var/log/nginx/*.error.log"]
@ -79,7 +79,7 @@ class EEDebugController(CementBaseController):
" /etc/nginx/nginx.conf")
self.trigger_nginx = True
else:
Log.info(self, "Nginx debug connection already disbaled")
Log.info(self, "Nginx debug connection already disabled")
# start site specific debug
elif self.start and self.app.pargs.site_name:
@ -120,7 +120,7 @@ class EEDebugController(CementBaseController):
else:
Log.info(self, "Debug for site allready disbaled")
Log.info(self, "Debug for site allready disabled")
else:
Log.info(self, "{0} domain not valid"
.format(self.app.pargs.site_name))
@ -135,7 +135,7 @@ class EEDebugController(CementBaseController):
"| grep 9001")):
Log.info(self, "Enabling PHP debug")
data = dict(php="9001", debug="9001")
Log.info(self, 'writting the nginx configration to file'
Log.info(self, 'Writting the Nginx debug configration to file '
'/etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
@ -153,14 +153,14 @@ class EEDebugController(CementBaseController):
"| grep 9001"):
Log.info(self, "Disabling PHP debug")
data = dict(php="9000", debug="9001")
Log.info(self, 'writting the nginx configration to file'
Log.info(self, 'Writting the Nginx debug configration to file '
'/etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
ee_nginx.close()
self.trigger_php = True
else:
Log.info(self, "PHP debug is allready disbaled")
Log.info(self, "PHP debug is allready disabled")
@expose(hide=True)
def debug_fpm(self):
@ -187,8 +187,7 @@ class EEDebugController(CementBaseController):
"/php-fpm.conf")
self.trigger_php = True
else:
Log.info(self, "PHP5-FPM log_level = debug "
" already disabled")
Log.info(self, "PHP5-FPM log_level = debug already disabled")
@expose(hide=True)
def debug_mysql(self):
@ -291,12 +290,12 @@ class EEDebugController(CementBaseController):
"SAVEQUERIES\', "
"true);/d\" {0}".format(wp_config))
else:
Log.info(self, "WordPress debug all already disbaled")
Log.info(self, "WordPress debug all already disabled")
else:
Log.info(self, "{0} domain not valid"
.format(self.app.pargs.site_name))
Log.error(self, "{0} domain not valid"
.format(self.app.pargs.site_name))
else:
Log.info(self, "Missing argument site_name")
Log.error(self, "Missing argument site name")
@expose(hide=True)
def debug_rewrite(self):
@ -309,7 +308,7 @@ class EEDebugController(CementBaseController):
"rewrite_log on;\' /etc/nginx/nginx.conf")
self.trigger_nginx = True
else:
Log.info(self, "NGINX rewrite logs already enabled")
Log.info(self, "Nginx rewrite logs already enabled")
if '/var/log/nginx/*.error.log' not in self.msg:
self.msg = self.msg + ['/var/log/nginx/*.error.log']
@ -323,14 +322,14 @@ class EEDebugController(CementBaseController):
" /etc/nginx/nginx.conf")
self.trigger_nginx = True
else:
Log.info(self, "NGINX rewrite logs already disbaled")
Log.info(self, "Nginx rewrite logs already disabled")
# Start Nginx rewrite for site
elif self.start and self.app.pargs.site_name:
config_path = ("/etc/nginx/sites-available/{0}.conf"
.format(self.app.pargs.site_name))
if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}"
.format(config_path)):
Log.info(self, "Setting up NGINX rewrite logs for {0}"
Log.info(self, "Setting up Nginx rewrite logs for {0}"
.format(self.app.pargs.site_name))
EEShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t"
"rewrite_log on;\" {0}"
@ -351,14 +350,14 @@ class EEDebugController(CementBaseController):
.format(self.app.pargs.site_name))
if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}"
.format(config_path)):
Log.info(self, "Disabling NGINX rewrite logs for {0}"
Log.info(self, "Disabling Nginx rewrite logs for {0}"
.format(self.app.pargs.site_name))
EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}"
.format(config_path))
self.trigger_nginx = True
else:
Log.info(self, "Nginx rewrite logs for {0} allready "
" disbaled".format(self.app.pargs.site_name))
" disabled".format(self.app.pargs.site_name))
@expose(hide=True)
def default(self):

50
ee/cli/plugins/example.py

@ -1,50 +0,0 @@
"""Example Plugin for EasyEngine."""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
def example_plugin_hook(app):
# do something with the ``app`` object here.
pass
class ExamplePluginController(CementBaseController):
class Meta:
# name that the controller is displayed at command line
label = 'example'
# text displayed next to the label in ``--help`` output
description = 'this is an example plugin controller'
# stack this controller on-top of ``base`` (or any other controller)
stacked_on = 'base'
# determines whether the controller is nested, or embedded
stacked_type = 'nested'
# these arguments are only going to display under
# ``$ ee example --help``
arguments = [
(
['-f', '--foo'],
dict(
help='Notorious foo option',
action='store',
)
)
]
@expose(hide=True)
def default(self):
print("Inside ExamplePluginController.default()")
@expose(help="this is an example sub-command.")
def example_plugin_command(self):
print("Inside ExamplePluginController.example_plugin_command()")
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(ExamplePluginController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', example_plugin_hook)

63
ee/cli/plugins/import_slow_log.py

@ -0,0 +1,63 @@
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.shellexec import EEShellExec
from ee.core.logging import Log
import os
def import_slow_log_plugin_hook(app):
pass
class EEImportslowlogController(CementBaseController):
class Meta:
label = 'import_slow_log'
stacked_on = 'base'
stacked_type = 'nested'
description = 'Import MySQL slow log to Anemometer database'
@expose(hide=True)
def default(self):
if os.path.isdir("/var/www/22222/htdocs/db/anemometer"):
if os.path.isfile("/var/log/mysql/mysql-slow.log"):
# Get Anemometer user name and password
Log.error(self, "Importing MySQL slow log to Anemometer")
host = os.popen("grep -e \"\'host\'\" /var/www/22222/htdocs/"
"db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
user = os.popen("grep -e \"\'user\'\" /var/www/22222/htdocs/"
"db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
password = os.popen("grep -e \"\'password\'\" /var/www/22222/"
"htdocs/db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
# Import slow log Anemometer using pt-query-digest
EEShellExec.cmd_exec(self, "pt-query-digest --user={0} "
"--password={1} "
"--review D=slow_query_log,"
"t=global_query_review "
"--history D=slow_query_log,t="
"global_query_review_history "
"--no-report --limit=0% "
"--filter=\" \\$event->{{Bytes}} = "
"length(\\$event->{{arg}}) "
"and \\$event->{{hostname}}=\\\""
"{2}\\\"\" "
"/var/log/mysql/mysql-slow.log"
.format(user, password, host))
else:
Log.error(self, "Unable to find MySQL slow log file")
else:
Log.error(self, "Anemometer is not installed")
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EEImportslowlogController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', import_slow_log_plugin_hook)

16
ee/cli/plugins/info.py

@ -19,17 +19,17 @@ class EEInfoController(CementBaseController):
label = 'info'
stacked_on = 'base'
stacked_type = 'nested'
description = 'info command used for debugging issued with stack or \
site specific configuration'
description = ('Display configuration information related to Nginx,'
' PHP and MySQL')
arguments = [
(['--mysql'],
dict(help='get mysql configuration information',
dict(help='Get MySQL configuration information',
action='store_true')),
(['--php'],
dict(help='get php configuration information',
dict(help='Get PHP configuration information',
action='store_true')),
(['--nginx'],
dict(help='get nginx configuration information',
dict(help='Get Nginx configuration information',
action='store_true')),
]
@ -174,19 +174,19 @@ class EEInfoController(CementBaseController):
if EEAptGet.is_installed(self, 'nginx-common'):
self.info_nginx()
else:
print("Nginx is not installed")
Log.error(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
self.info_php()
else:
print("PHP5 is installed")
Log.error("PHP5 is not installed")
if self.app.pargs.mysql:
if EEShellExec.cmd_exec(self, "mysqladmin ping"):
self.info_mysql()
else:
print("MySQL is not installed")
Log.error("MySQL is not installed")
def load(app):

20
ee/cli/plugins/secure.py

@ -2,12 +2,12 @@ from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables
from ee.core.logging import Log
import string
import random
import sys
import hashlib
import getpass
from ee.core.logging import Log
def secure_plugin_hook(app):
@ -15,7 +15,7 @@ def secure_plugin_hook(app):
pass
class EEsecureController(CementBaseController):
class EESecureController(CementBaseController):
class Meta:
label = 'secure'
stacked_on = 'base'
@ -43,8 +43,8 @@ class EEsecureController(CementBaseController):
@expose(hide=True)
def secure_auth(self):
passwd = ''.join([random.choice
(string.ascii_letters + string.digits)
for n in range(6)])
(string.ascii_letters + string.digits)
for n in range(6)])
username = input("Provide HTTP authentication user "
"name [{0}] :".format(EEVariables.ee_user))
password = input("Provide HTTP authentication "
@ -75,20 +75,18 @@ class EEsecureController(CementBaseController):
"/etc/nginx/sites-available/22222"
.format(port=port))
else:
Log.info(self, "Unable to change EasyEngine admin port{0}"
.format("[FAIL]"))
Log.error(self, "Unable to change EasyEngine admin port")
if EEVariables.ee_platform_distro == 'Debian':
EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen "
"{port} default_server ssl;/\" "
"/etc/nginx/sites-available/22222"
.format(port=port))
else:
Log.info(self, "Unable to change EasyEngine admin port{0}"
.format("[FAIL]"))
Log.error(self, "Unable to change EasyEngine admin port")
@expose(hide=True)
def secure_ip(self):
#TODO:remaining with ee.conf updation in file
# TODO:remaining with ee.conf updation in file
newlist = []
ip = input("Enter the comma separated IP addresses "
"to white list [127.0.0.1]:")
@ -101,7 +99,7 @@ class EEsecureController(CementBaseController):
for check_ip in user_list_ip:
if check_ip not in exist_ip_list:
newlist.extend(exist_ip_list)
# changes in acl.conf file
# changes in acl.conf file
if len(newlist) != 0:
EEShellExec.cmd_exec(self, "sed -i \"/allow.*/d\" /etc/nginx"
"/common/acl.conf")
@ -114,6 +112,6 @@ class EEsecureController(CementBaseController):
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EEsecureController)
handler.register(EESecureController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', secure_plugin_hook)

203
ee/cli/plugins/site.py

@ -8,11 +8,11 @@ from ee.cli.plugins.site_functions import *
from ee.core.services import EEService
from ee.cli.plugins.sitedb import *
from ee.core.git import EEGit
from subprocess import Popen
import sys
import os
import glob
import subprocess
from subprocess import Popen
def ee_site_hook(app):
@ -26,18 +26,18 @@ class EESiteController(CementBaseController):
label = 'site'
stacked_on = 'base'
stacked_type = 'nested'
description = ('site command manages website configuration'
description = ('Site command manages website configuration'
' with the help of the following subcommands')
arguments = [
(['site_name'],
dict(help='website name')),
dict(help='Website name')),
]
@expose(hide=True)
def default(self):
self.app.args.print_help()
@expose(help="enable site example.com")
@expose(help="Enable site example.com")
def enable(self):
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -51,7 +51,7 @@ class EESiteController(CementBaseController):
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@expose(help="disable site example.com")
@expose(help="Disable site example.com")
def disable(self):
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -63,7 +63,7 @@ class EESiteController(CementBaseController):
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@expose(help="get example.com information")
@expose(help="Get example.com information")
def info(self):
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = ''
@ -105,7 +105,7 @@ class EESiteController(CementBaseController):
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@expose(help="Edit example.com's nginx configuration")
@expose(help="Edit Nginx configuration of example.com")
def edit(self):
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -121,7 +121,7 @@ class EESiteController(CementBaseController):
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@expose(help="Display example.com's nginx configuration")
@expose(help="Display Nginx configuration of example.com")
def show(self):
# TODO Write code for ee site edit command here
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
@ -131,12 +131,12 @@ class EESiteController(CementBaseController):
.format(ee_domain))
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r")
text = f.read()
print(text)
Log.info(self, Log.ENDC + text)
f.close()
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@expose(help="change directory to site webroot")
@expose(help="Change directory to site webroot")
def cd(self):
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
@ -156,8 +156,8 @@ class EESiteCreateController(CementBaseController):
label = 'create'
stacked_on = 'site'
stacked_type = 'nested'
description = 'create command manages website configuration with the \
help of the following subcommands'
description = ('this commands set up configuration and installs '
'required files as options are provided')
arguments = [
(['site_name'],
dict(help='domain name for the site to be created.')),
@ -191,6 +191,7 @@ class EESiteCreateController(CementBaseController):
def default(self):
# self.app.render((data), 'default.mustache')
# Check domain name validation
data = ''
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -406,10 +407,10 @@ class EESiteCreateController(CementBaseController):
# Check rerequired packages are installed or not
site_package_check(self, stype)
# setup NGINX configuration, and webroot
setupDomain(self, data)
setupdomain(self, data)
# Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']:
data = setupDatabase(self, data)
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
@ -430,7 +431,7 @@ class EESiteCreateController(CementBaseController):
# Setup WordPress if Wordpress site
if data['wp']:
ee_wp_creds = setupWordpress(self, data)
ee_wp_creds = setupwordpress(self, data)
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
@ -438,11 +439,11 @@ class EESiteCreateController(CementBaseController):
msg="{0} created with {1} {2}"
.format(ee_www_domain, stype, cache))
# Setup Permissions for webroot
SetWebrootPermissions(self, data['webroot'])
setwebrootpermissions(self, data['webroot'])
if data['wp']:
Log.info(self, '\033[94m'+"WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user'])+'\033[0m')
Log.info(self, "WordPress Admin User Password : {0}"
Log.info(self, Log.ENDC + "WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user']))
Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}"
.format(ee_wp_creds['wp_pass']))
addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot)
Log.info(self, "Successfully created site"
@ -454,11 +455,14 @@ class EESiteUpdateController(CementBaseController):
label = 'update'
stacked_on = 'site'
stacked_type = 'nested'
description = 'update command manages website configuration with the \
help of the following subcommands'
description = ('This command updates websites configuration to '
'another as per the options are provided')
arguments = [
(['site_name'],
dict(help='domain name for the site to be updated')),
(['--password'],
dict(help="update to password for wordpress site user",
action='store_true')),
(['--html'],
dict(help="update to html site", action='store_true')),
(['--php'],
@ -480,8 +484,9 @@ class EESiteUpdateController(CementBaseController):
dict(help="update to wpsc cache", action='store_true')),
]
@expose(help="update site type or cache")
@expose(help="Update site type or cache")
def default(self):
data = ''
(ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -494,13 +499,20 @@ class EESiteUpdateController(CementBaseController):
oldsitetype = check_site.site_type
oldcachetype = check_site.cache_type
print(oldsitetype, oldcachetype)
if (self.app.pargs.password and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc
or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
updatewpuserpassword(self, ee_domain, ee_site_webroot)
self.app.close(0)
if (self.app.pargs.html and not (self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or
self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
pass
Log.error(self, " Cannot update {0} {1} to html"
.format(ee_domain, oldsitetype))
# PHP
if (self.app.pargs.php and not (self.app.pargs.html or
@ -549,8 +561,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wp and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
if ((oldsitetype in ['html', 'php', 'mysql', 'wp'])
and (oldcachetype not in ['w3tc', 'wpfc', 'wpsc'])):
if ((oldsitetype not in ['html', 'php', 'mysql', 'wp'])
or (oldsitetype is 'wp' and oldcachetype is 'basic')):
print(oldsitetype, oldcachetype)
Log.error(self, " Cannot update {0}, {1} {2} to wp basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -568,9 +580,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
Log.error(self, " Cannot update {0}, {1} {2}to wp w3tc"
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0}, {1} {2} to wp w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -587,8 +599,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpfc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -605,8 +617,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpsc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -627,8 +639,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'basic')):
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdir basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -646,8 +659,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0} {1} {2}"
"to wpsubdir w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -666,8 +680,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpfc')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdir wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -685,8 +700,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpsc')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdir wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -705,8 +721,9 @@ class EESiteUpdateController(CementBaseController):
self.app.pargs.php or self.app.pargs.mysql or
self.app.pargs.wpsubdir or self.app.pargs.wp)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain']
and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
or (oldsitetype is 'wpsubdomain' and oldcachetype is 'basic')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdomain basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -725,9 +742,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -746,9 +763,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpfc')):
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdomain wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -767,9 +784,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpsc')):
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -786,17 +803,17 @@ class EESiteUpdateController(CementBaseController):
cache = 'wpsc'
if not data:
Log.error(self, " Cannot update"
Log.error(self, " Cannot update {0}, Invalid Options"
.format(ee_domain))
site_package_check(self, stype)
siteBackup(self, data)
# TODO Check for required packages before update
sitebackup(self, data)
# setup NGINX configuration, and webroot
setupDomain(self, data)
setupdomain(self, data)
if 'ee_db_name' in data.keys() and not data['wp']:
data = setupDatabase(self, data)
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
@ -816,45 +833,44 @@ class EESiteUpdateController(CementBaseController):
if oldsitetype == 'mysql':
config_file = (ee_site_webroot + '/backup/{0}/ee-config.php'
.format(EEVariables.ee_date))
data['ee_db_name'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_NAME')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_user'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_USER')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_pass'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_PASSWORD')
.split(',')[1]
.split(')')[0].strip())
print(config_file, 'DB_NAME')
data['ee_db_name'] = (EEFileUtils.grep(self, config_file,
'DB_NAME')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_user'] = (EEFileUtils.grep(self, config_file,
'DB_USER')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_pass'] = (EEFileUtils.grep(self, config_file,
'DB_PASSWORD')
.split(',')[1]
.split(')')[0].strip())
# Setup WordPress if old sites are html/php/mysql sites
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
ee_wp_creds = setupWordpress(self, data)
ee_wp_creds = setupwordpress(self, data)
# Uninstall unnecessary plugins
if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']:
# Setup WordPress Network if update option is multisite
# and oldsite is WordPress single site
if data['multisite'] and oldsitetype == 'wp':
setupWordpressNetwork(self, data)
setupwordpressnetwork(self, data)
if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and
not data['w3tc', 'wpfc']):
uninstallWP_Plugin(self, 'w3-total-cache', data)
not (data['w3tc'] or data['wpfc'])):
uninstallwp_plugin(self, 'w3-total-cache', data)
if oldcachetype == 'wpsc' and not data['wpsc']:
uninstallWP_Plugin(self, 'wp-super-cache', data)
uninstallwp_plugin(self, 'wp-super-cache', data)
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and data['w3tc']:
installWP_Plugin(self, 'w3-total-cache', data)
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc']
or data['wpfc']):
installwp_plugin(self, 'w3-total-cache', data)
if oldcachetype != 'wpsc' and data['wpsc']:
installWP_Plugin(self, 'wp-super-cache', data)
installwp_plugin(self, 'wp-super-cache', data)
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
@ -863,7 +879,13 @@ class EESiteUpdateController(CementBaseController):
msg="{0} updated with {1} {2}"
.format(ee_www_domain, stype, cache))
# Setup Permissions for webroot
# SetWebrootPermissions(self, data['webroot'])
# setwebrootpermissions(self, data['webroot'])
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
Log.info(self, Log.ENDC + "WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user']))
Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}"
.format(ee_wp_creds['wp_pass']))
updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache)
Log.info(self, "Successfully updated site"
@ -875,7 +897,7 @@ class EESiteDeleteController(CementBaseController):
label = 'delete'
stacked_on = 'site'
stacked_type = 'nested'
description = 'delete command deletes website'
description = 'To delete website'
arguments = [
(['site_name'],
dict(help='domain name to be deleted')),
@ -890,12 +912,13 @@ class EESiteDeleteController(CementBaseController):
dict(help="delete webroot only", action='store_true')),
]
@expose(help="delete site")
@expose(help="Delete website configuration and files")
def default(self):
# TODO Write code for ee site update here
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = ''
ee_prompt = ''
ee_nginx_prompt = ''
if ((not self.app.pargs.db) and (not self.app.pargs.files) and
(not self.app.pargs.all)):
@ -914,7 +937,7 @@ class EESiteDeleteController(CementBaseController):
'[Y/N]: ')
else:
ee_db_prompt = 'Y'
ee_nginx_prompt = 'Y'
if ee_db_prompt == 'Y' or ee_db_prompt == 'y':
self.deleteDB(ee_site_webroot)
@ -924,7 +947,6 @@ class EESiteDeleteController(CementBaseController):
'[Y/N]: ')
else:
ee_web_prompt = 'Y'
ee_nginx_prompt = 'Y'
if ee_web_prompt == 'Y' or ee_web_prompt == 'y':
self.deleteWebRoot(ee_site_webroot)
@ -949,9 +971,10 @@ class EESiteDeleteController(CementBaseController):
self.deleteWebRoot(ee_site_webroot)
if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'):
Log.debug(self, "Removing Nginx configuration")
EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}'
.format(ee_domain))
deleteSiteInfo(self, ee_domain)
deleteSiteInfo(self, ee_domain)
Log.info(self, "Deleted site {0}".format(ee_domain))
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@ -999,15 +1022,15 @@ class EESiteListController(CementBaseController):
label = 'list'
stacked_on = 'site'
stacked_type = 'nested'
description = 'list websites'
description = 'List websites'
arguments = [
(['--enabled'],
dict(help='list enabled sites', action='store_true')),
dict(help='List enabled websites', action='store_true')),
(['--disabled'],
dict(help="list disabled sites", action='store_true')),
dict(help="List disabled websites", action='store_true')),
]
@expose(help="delete example.com")
@expose(help="Lists websites")
def default(self):
sites = getAllsites(self)
if not sites:

133
ee/cli/plugins/site_functions.py

@ -1,8 +1,3 @@
import os
import random
import string
import sys
import getpass
from ee.cli.plugins.stack import EEStackController
from ee.core.fileutils import EEFileUtils
from ee.core.mysql import EEMysql
@ -10,14 +5,19 @@ from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables
from ee.core.aptget import EEAptGet
from ee.core.logging import Log
import os
import random
import string
import sys
import getpass
import glob
def setupDomain(self, data):
def setupdomain(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
Log.info(self, "Setting up NGINX configuration ", end='')
Log.info(self, "Setting up NGINX configuration \t\t", end='')
# write nginx config for file
try:
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
@ -41,7 +41,7 @@ def setupDomain(self, data):
.format(ee_domain_name)])
# Creating htdocs & logs directory
Log.info(self, "Setting up webroot ", end='')
Log.info(self, "Setting up webroot \t\t", end='')
try:
if not os.path.exists('{0}/htdocs'.format(ee_site_webroot)):
os.makedirs('{0}/htdocs'.format(ee_site_webroot))
@ -62,14 +62,14 @@ def setupDomain(self, data):
Log.info(self, "[Done]")
def setupDatabase(self, data):
def setupdatabase(self, data):
ee_domain_name = data['site_name']
ee_random = (''.join(random.sample(string.ascii_uppercase +
string.ascii_lowercase + string.digits, 15)))
ee_replace_dot = ee_domain_name.replace('.', '_')
prompt_dbname = self.app.config.get('mysql', 'db-name')
prompt_dbuser = self.app.config.get('mysql', 'db-user')
ee_mysql_host = self.app.config.get('mysql', 'grant-host')
ee_mysql_grant_host = self.app.config.get('mysql', 'grant-host')
ee_db_name = ''
ee_db_username = ''
ee_db_password = ''
@ -89,8 +89,9 @@ def setupDatabase(self, data):
try:
ee_db_username = input('Enter the MySQL database user name [{0}]: '
.format(ee_replace_dot))
ee_db_password = input('Enter the MySQL database password [{0}]: '
.format(ee_random))
ee_db_password = getpass.getpass(prompt='Enter the MySQL database'
' password [{0}]: '
.format(ee_random))
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input database credentials")
@ -102,38 +103,39 @@ def setupDatabase(self, data):
if len(ee_db_username) > 16:
Log.info(self, 'Autofix MySQL username (ERROR 1470 (HY000)),'
' please wait...')
' please wait')
ee_random10 = (''.join(random.sample(string.ascii_uppercase +
string.ascii_lowercase + string.digits, 10)))
ee_db_name = (ee_db_name[0:6] + ee_random10)
# create MySQL database
Log.info(self, "Setting Up Database ", end='')
Log.debug(self, "creating databse {0}".format(ee_db_name))
Log.info(self, "Setting up database\t\t", end='')
Log.debug(self, "Creating databse {0}".format(ee_db_name))
EEMysql.execute(self, "create database {0}"
.format(ee_db_name))
# Create MySQL User
Log.debug(self, "creating user {0}".format(ee_db_username))
Log.debug(self, "Creating user {0}".format(ee_db_username))
EEMysql.execute(self,
"create user {0}@{1} identified by '{2}'"
.format(ee_db_username, ee_mysql_host, ee_db_password))
.format(ee_db_username, ee_mysql_grant_host,
ee_db_password))
# Grant permission
Log.debug(self, "setting up user privileges")
Log.debug(self, "Setting up user privileges")
EEMysql.execute(self,
"grant all privileges on {0}.* to {1}@{2}"
.format(ee_db_name, ee_db_username, ee_mysql_host))
.format(ee_db_name, ee_db_username, ee_mysql_grant_host))
Log.info(self, "[Done]")
data['ee_db_name'] = ee_db_name
data['ee_db_user'] = ee_db_username
data['ee_db_pass'] = ee_db_password
data['ee_db_host'] = ee_mysql_host
data['ee_db_host'] = EEVariables.ee_mysql_host
return(data)
def setupWordpress(self, data):
def setupwordpress(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
@ -147,13 +149,13 @@ def setupWordpress(self, data):
ee_wp_user = ''
ee_wp_pass = ''
Log.info(self, "Downloading Wordpress ", end='')
Log.info(self, "Downloading Wordpress \t\t", end='')
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
EEShellExec.cmd_exec(self, "wp --allow-root core download")
Log.info(self, "[Done]")
if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
data = setupDatabase(self, data)
data = setupdatabase(self, data)
if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
try:
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
@ -199,14 +201,14 @@ def setupWordpress(self, data):
if not ee_wp_user:
ee_wp_user = EEVariables.ee_user
while not ee_wp_user:
Log.warn(self, "Usernames can have only alphanumeric"
Log.warn(self, "Username can have only alphanumeric"
"characters, spaces, underscores, hyphens,"
"periods and the @ symbol.")
try:
ee_wp_user = input('Enter WordPress username: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input wp user name")
Log.error(self, "Unable to input WordPress user name")
if not ee_wp_pass:
ee_wp_pass = ee_random
@ -218,12 +220,12 @@ def setupWordpress(self, data):
ee_wp_email = input('Enter WordPress email: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input wp user email")
Log.error(self, "Unable to input WordPress user email")
Log.debug(self, "setting up WordPress Tables")
Log.debug(self, "Setting up WordPress tables")
if not data['multisite']:
Log.debug(self, "creating tables for WordPress Single site")
Log.debug(self, "Creating tables for WordPress Single site")
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install "
"--url={0} --title={0} --admin_name={1} "
.format(data['www_domain'], ee_wp_user)
@ -231,7 +233,7 @@ def setupWordpress(self, data):
.format(ee_wp_pass, ee_wp_email),
errormsg="Unable to setup WordPress Tables")
else:
Log.debug(self, "creating tables for WordPress multisite")
Log.debug(self, "Creating tables for WordPress multisite")
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root "
"core multisite-install "
"--url={0} --title={0} --admin_name={1} "
@ -250,15 +252,15 @@ def setupWordpress(self, data):
errormsg="Unable to Update WordPress permalink")
"""Install nginx-helper plugin """
installWP_Plugin(self, 'nginx-helper', data)
installwp_plugin(self, 'nginx-helper', data)
"""Install Wp Super Cache"""
if data['wpsc']:
installWP_Plugin(self, 'wp-super-cache', data)
installwp_plugin(self, 'wp-super-cache', data)
"""Install W3 Total Cache"""
if data['w3tc'] or data['wpfc']:
installWP_Plugin(self, 'w3-total-cache', data)
installwp_plugin(self, 'w3-total-cache', data)
wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass,
wp_email=ee_wp_email)
@ -266,10 +268,10 @@ def setupWordpress(self, data):
return(wp_creds)
def setupWordpressNetwork(self, data):
def setupwordpressnetwork(self, data):
ee_site_webroot = data['webroot']
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
Log.info(self, "Setting up WordPress Network ", end='')
Log.info(self, "Setting up WordPress Network \t\t", end='')
EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
' --title={0} {subdomains}'
.format(data['www_domain'], subdomains='--subdomains'
@ -277,7 +279,7 @@ def setupWordpressNetwork(self, data):
Log.info(self, "Done")
def installWP_Plugin(self, plugin_name, data):
def installwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot']
Log.debug(self, "Installing plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
@ -294,7 +296,7 @@ def installWP_Plugin(self, plugin_name, data):
.format(plugin_name))
def uninstallWP_Plugin(self, plugin_name, data):
def uninstallwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot']
Log.debug(self, "Uninstalling plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
@ -304,23 +306,23 @@ def uninstallWP_Plugin(self, plugin_name, data):
.format(plugin_name))
def SetWebrootPermissions(self, webroot):
Log.debug(self, "Setting Up Permissions...")
def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions")
EEFileUtils.chown(self, webroot, EEVariables.ee_php_user,
EEVariables.ee_php_user, recursive=True)
def siteBackup(self, data):
def sitebackup(self, data):
ee_site_webroot = data['webroot']
backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date)
if not EEFileUtils.isexist(self, backup_path):
EEFileUtils.mkdir(self, backup_path)
Log.info(self, "Backup Location : {0}".format(backup_path))
Log.info(self, "Backup location : {0}".format(backup_path))
EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}'
.format(data['site_name']), backup_path)
if data['currsitetype'] in ['html', 'php', 'mysql']:
Log.info(self, "Backing up Webroot ", end='')
Log.info(self, "Backing up Webroot \t\t", end='')
EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
Log.info(self, "[Done]")
@ -330,7 +332,7 @@ def siteBackup(self, data):
ee_db_name = (EEFileUtils.grep(self, configfiles[0],
'DB_NAME').split(',')[1]
.split(')')[0].strip().replace('\'', ''))
Log.info(self, 'Backing up Database ', end='')
Log.info(self, 'Backing up database \t\t', end='')
EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
.format(ee_db_name, backup_path),
errormsg="\nFailed: Backup Database")
@ -375,3 +377,50 @@ def site_package_check(self, stype):
"wp-cli.phar", "/usr/bin/wp",
"WP_CLI"]]
stack.install(apt_packages=apt_packages, packages=packages)
def updatewpuserpassword(self, ee_domain, ee_site_webroot):
ee_wp_user = ''
ee_wp_pass = ''
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
# Check if ee_domain is wordpress install
is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core"
" version",
errormsg="{0} : Unable to check if wp install"
.format(ee_domain))
# Exit if ee_domain is not wordpress install
if not is_wp:
Log.error(self, "{0} does not seem to be a WordPress site"
.format(ee_domain))
ee_wp_user = input("Provide WordPress user name [admin]: ")
if ee_wp_user == "?":
Log.info(self, "Fetching WordPress user list")
EEShellExec.cmd_exec(self, "wp --allow-root user list "
"--fields=user_login | grep -v user_login",
errormsg="Unable to Fetch users list")
if not ee_wp_user:
ee_wp_user = 'admin'
is_user_exist = EEShellExec.cmd_exec(self, "wp --allow-root user list "
"--fields=user_login | grep {0}$ "
.format(ee_wp_user))
if is_user_exist:
ee_wp_pass = input("Provide password for {0} user: "
.format(ee_wp_user))
if len(ee_wp_pass) > 8:
EEShellExec.cmd_exec(self, "wp --allow-root user update {0}"
" --user_pass={1}"
.format(ee_wp_user, ee_wp_pass))
Log.info(self, "Password updated successfully")
else:
Log.error(self, "Password Unchanged. Hint : Your password must be "
"8 characters long")
else:
Log.error(self, "Invalid WordPress user {0} for {1}."
.format(ee_wp_user, ee_domain))

14
ee/cli/plugins/sitedb.py

@ -3,9 +3,9 @@ from sqlalchemy import ForeignKey, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import declarative_base
from ee.core.logging import Log
import sys
from ee.core.database import db_session
from ee.core.models import SiteDB
import sys
def addNewSite(self, site, stype, cache, path,
@ -35,6 +35,10 @@ def updateSiteInfo(self, site, stype='', cache='',
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database for site info")
if not q:
Log.error(self, "{0} does not exist in database".format(site))
if stype and q.site_type != stype:
q.site_type = stype
@ -60,7 +64,11 @@ def deleteSiteInfo(self, site):
q = SiteDB.query.filter(SiteDB.sitename == site).first()
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database :")
Log.error(self, "Unable to query database")
if not q:
Log.error(self, "{0} does not exist in database".format(site))
try:
db_session.delete(q)
db_session.commit()
@ -75,4 +83,4 @@ def getAllsites(self):
return q
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database :")
Log.error(self, "Unable to query database")

2
ee/cli/plugins/stack.py

@ -1,4 +1,4 @@
"""Example Plugin for EasyEngine."""
"""Stack Plugin for EasyEngine."""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook

16
ee/cli/plugins/stack_services.py

@ -9,7 +9,7 @@ class EEStackStatusController(CementBaseController):
label = 'stack_services'
stacked_on = 'stack'
stacked_type = 'embedded'
description = 'stack command manages stack operations'
description = 'Get status of stack'
arguments = [
(['--memcache'],
dict(help='start/stop/restart stack', action='store_true')),
@ -130,25 +130,25 @@ class EEStackStatusController(CementBaseController):
def reload(self):
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service restart")
Log.debug(self, "nginx service reload")
services = services + ['nginx']
elif self.app.pargs.php:
Log.debug(self, "php5-fpm service restart")
Log.debug(self, "php5-fpm service reload")
services = services + ['php5-fpm']
elif self.app.pargs.mysql:
Log.debug(self, "mysql service restart")
Log.debug(self, "mysql service reload")
services = services + ['mysql']
elif self.app.pargs.postfix:
Log.debug(self, "postfix service restart")
Log.debug(self, "postfix service reload")
services = services + ['postfix']
elif self.app.pargs.memcache:
Log.debug(self, "memcached service restart")
Log.debug(self, "memcached service reload")
services = services + ['memcached']
elif self.app.pargs.dovecot:
Log.debug(self, "dovecot service restart")
Log.debug(self, "dovecot service reload")
services = services + ['dovecot']
else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload")
EEService.reload_service(self, service)

1
ee/cli/templates/default.mustache

@ -1 +0,0 @@
Inside {{foo}}

1
ee/core/addswap.py

@ -1,3 +1,4 @@
"""EasyEngine SWAP creation"""
from ee.core.variables import EEVariables
from ee.core.shellexec import EEShellExec
from ee.core.fileutils import EEFileUtils

12
ee/core/apt_repo.py

@ -1,6 +1,7 @@
import os
"""EasyEngine packages repository operations"""
from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables
import os
class EERepo():
@ -11,7 +12,6 @@ class EERepo():
pass
def add(self, repo_url=None, ppa=None):
# TODO add repository code
if repo_url is not None:
repo_file_path = ("/etc/apt/sources.list.d/"
@ -27,10 +27,11 @@ class EERepo():
repofile.close()
return True
except IOError as e:
print("File I/O error({0}): {1}".format(e.errno, e.strerror))
Log.debug(self, "{0}".format(e))
Log.error(self, "File I/O error.")
except Exception as e:
print("{error}".format(error=e))
return False
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to add repo")
if ppa is not None:
if EEVariables.ee_platform_distro == 'squeeze':
print("Cannot add repo for {distro}"
@ -41,7 +42,6 @@ class EERepo():
.format(ppa_name=ppa))
def remove(self, repo_url=None):
# TODO remove repository
EEShellExec.cmd_exec(self, "add-apt-repository -y "
"--remove '{ppa_name}'"
.format(ppa_name=repo_url))

11
ee/core/aptget.py

@ -59,7 +59,7 @@ class EEAptGet():
.format(space=cache.required_space))
try:
# Commit changes in cache (actually install)
cache.commit(fprogress, iprogress)
cache.commit(fprogress, iprogres)
except Exception as e:
print("package installation failed. [{err}]"
.format(err=str(e)))
@ -111,8 +111,8 @@ class EEAptGet():
.format(pkg_install_count=cache.install_count))
print("Need to get {req_download} bytes of archives"
.format(req_download=cache.required_download))
print("After this operation, {space} bytes of"
"additional disk space will be used."
print("After this operation, {space:.2f} MB of"
" additional disk space will be used."
.format(space=cache.required_space/1e6))
try:
# Commit changes in cache (actually install)
@ -170,7 +170,6 @@ class EEAptGet():
.format(package_name=pkg.name))
continue
my_selected_packages.append(pkg.name)
print(my_selected_packages)
# How logic works:
# 1) We loop trough dependencies's dependencies and add them to
# the list.
@ -211,8 +210,8 @@ class EEAptGet():
print("{pkg_remove_count} to remove."
.format(pkg_remove_count=cache.delete_count))
# app.log.debug('bytes disk space will be freed')
print("After this operation, {space} bytes disk spac"
"e will be freed.".format(space=cache.required_space))
print("After this operation, {space:.2f} MB disk space "
"will be freed.".format(space=cache.required_space/1e6))
try:
cache.commit(fprogress, iprogress)
except Exception as e:

9
ee/core/checkpackage.py

@ -1,9 +0,0 @@
"""EasyEngine package check module."""
class EEPackageCheck():
"""Intialization for package check"""
def ___init__():
# TODO Intialization for package check
pass

3
ee/core/database.py

@ -1,8 +1,9 @@
"""EasyEngine generic database creation module"""
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
#db_path = self.app.config.get('site', 'db_path')
# db_path = self.app.config.get('site', 'db_path')
engine = create_engine('sqlite:////var/lib/ee/ee.sqlite', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,

19
ee/core/domaincheck.py

@ -1,19 +0,0 @@
"""EasyEngine domain check module."""
class EEDomainCheck():
"""Intialization domain check"""
def ___init__():
# TODO Intialization for domain check
pass
"""Check for proper domain"""
def isdomain():
# TODO method for doamin check
pass
"""Check for proper Fully qualified domain"""
def isfqdn():
# TODO method for FQDN check
pass

1
ee/core/domainvalidate.py

@ -1,3 +1,4 @@
"""EasyEngine domain validation module."""
from urllib.parse import urlparse

10
ee/core/dummy.py

@ -1,10 +0,0 @@
"""EasyEngine dummy core classes."""
class EEDummy():
"""Generic errors."""
def __init__():
pass
def dummy():
print("Dummy Function")

3
ee/core/git.py

@ -1,6 +1,7 @@
"""EasyEngine GIT module"""
from sh import git, ErrorReturnCode
import os
from ee.core.logging import Log
import os
class EEGit:

23
ee/core/info.py

@ -1,23 +0,0 @@
"""EasyEngine Nginx, PHP, MySQL info module."""
class EEInfo():
"""Intialization for info"""
def ___init__():
# TODO common method for info
pass
"""Method to disaply info for PHP"""
def infophp():
# TODO info for php
pass
"""Method to disaply info for Nginx"""
def infonginx():
# TODO info for Nginx
pass
"""Method to disaply info for MySQL"""
def infomysql():
# TODO info for MySQL
pass

1
ee/core/logging.py

@ -1,3 +1,4 @@
"""EasyEngine log module"""
class Log:

8
ee/core/mysql.py

@ -44,11 +44,13 @@ class EEMysql():
try:
cur.execute(statement)
except Exception as e:
Log.error(self, 'Unable to execute statement:')
Lod.debug(self, "{0}".format(e))
cur.close()
conn.close()
sys.exit(1)
Log.debug(self, "{0}".format(e))
if not errormsg:
Log.error(self, 'Unable to execute statement')
else:
Log.error(self, '{0}'.format(errormsg))
cur.close()
conn.close()

11
ee/core/permissions.py

@ -1,11 +0,0 @@
"""EasyEngine set permission module"""
class EESetPermission():
"""Intialization set permission"""
def ___init__():
# TODO method for set permission
pass
def setPermissions(self, user, group, path, recursive=False):
pass

4
ee/core/shellexec.py

@ -1,9 +1,9 @@
"""EasyEngine shell executaion functions."""
from subprocess import Popen
from ee.core.logging import Log
import os
import sys
import subprocess
from subprocess import Popen
from ee.core.logging import Log
class EEShellExec():

8
ee/core/swapcreation.py

@ -1,8 +0,0 @@
"""EasyEngine swap creation module."""
class EESwapCreation():
"""Generice swap creation intialisation"""
def __init__():
# TODO method for swap creation
pass

8
ee/core/symboliclink.py

@ -1,8 +0,0 @@
"""EasyEngine symbolic link creation module"""
class EESymbolicLink():
"""Intialization for symbolic link"""
def ___init__():
# TODO method for symbolic link
pass

12
ee/core/variables.py

@ -10,8 +10,6 @@ import datetime
class EEVariables():
"""Intialization of core variables"""
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
# EasyEngine version
ee_version = "3.0.0"
@ -40,12 +38,14 @@ class EEVariables():
ee_php_user = 'www-data'
# Get git user name and EMail
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
try:
ee_user = config['user']['name']
ee_email = config['user']['email']
except Exception as e:
print("Unable to find GIT user name and Email")
sys.exit(1)
ee_user = input("Enter username for Git:")
ee_email = input("Enter email for Git:")
# Get System RAM and SWAP details
ee_ram = psutil.virtual_memory().total / (1024 * 1024)
@ -81,9 +81,9 @@ class EEVariables():
elif ee_platform_codename == 'wheezy':
ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all"
.format(codename=ee_platform_codename))
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap",
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline",
"php5-mysql", "memcached"]
"php5-mysql", "php5-cli", "memcached"]
# MySQL repo and packages
ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main"

16
ee/utils/test.py

@ -1,16 +0,0 @@
"""Testing utilities for EasyEngine."""
from ee.cli.main import EETestApp
from cement.utils.test import *
class EETestCase(CementTestCase):
app_class = EETestApp
def setUp(self):
"""Override setup actions (for every test)."""
super(EETestCase, self).setUp()
def tearDown(self):
"""Override teardown actions (for every test)."""
super(EETestCase, self).tearDown()

25
setup.py

@ -3,12 +3,13 @@ from setuptools import setup, find_packages
import sys
import os
import glob
import configparser
conf = []
templates = []
long_description = '''EasyEngine is the commandline tool to manage your
Websites based on WordPress and NGINX with easy to use
Websites based on WordPress and Nginx with easy to use
commands'''
for name in glob.glob('config/plugins.d/*.conf'):
@ -23,6 +24,24 @@ if not os.path.exists('/var/log/ee/'):
if not os.path.exists('/var/lib/ee/'):
os.makedirs('/var/lib/ee/')
# EasyEngine git function
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
try:
ee_user = config['user']['name']
ee_email = config['user']['email']
except Exception as e:
print("EasyEngine (ee) required your name & email address to track"
" changes you made under the Git version control")
print("EasyEngine (ee) will be able to send you daily reports & alerts in "
"upcoming version")
print("EasyEngine (ee) will NEVER send your information across")
ee_user = input("Enter username for Git:")
ee_email = input("Enter email for Git:")
os.system("git config --global user.name {0}".format(ee_user))
os.system("git config --global user.email {0}".format(ee_email))
setup(name='ee',
version='3.0',
description=long_description,
@ -56,7 +75,9 @@ setup(name='ee',
],
data_files=[('/etc/ee', ['config/ee.conf']),
('/etc/ee/plugins.d', conf),
('/usr/lib/ee/templates', templates)],
('/usr/lib/ee/templates', templates),
('/etc/bash_completion.d/',
['config/bash_completion.d/ee_auto.rc'])],
setup_requires=[],
entry_points="""
[console_scripts]

0
tests/core/test_exc.py

Loading…
Cancel
Save