Browse Source

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

bugfixes
shital.rtcamp 10 years ago
parent
commit
dc0d5ebf52
  1. 105
      README.md
  2. 1
      config/plugins.d/site.conf
  3. 8
      ee/cli/plugins/debug.py
  4. 1
      ee/cli/plugins/import_slow_log.py
  5. 4
      ee/cli/plugins/info.py
  6. 60
      ee/cli/plugins/site.py
  7. 12
      ee/cli/plugins/sitedb.py
  8. 7
      ee/cli/plugins/stack.py
  9. 5
      ee/cli/plugins/stack_services.py
  10. 1
      ee/core/addswap.py
  11. 1
      ee/core/checkfqdn.py
  12. 3
      ee/core/database.py
  13. 5
      ee/core/download.py
  14. 1
      ee/core/extract.py
  15. 1
      ee/core/mysql.py
  16. 1
      ee/core/shellexec.py
  17. 4
      ee/core/variables.py
  18. 241
      install
  19. 10
      setup.py
  20. 114
      upgrade

105
README.md

@ -1,35 +1,96 @@
IMPORTANT
============================================
How To setup this version on your system??
#### We are looking for [Python Developers] (https://rtcamp.com/careers/python-developer/) to join our team. We offer work from home, so you can join EasyEngine team anywhere! _[Why Python?] (https://rtcamp.com/blog/easyengine-3-roadmap/#whypython)_
---
[![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine)
[![Stories in Progress](https://badge.waffle.io/rtcamp/easyengine.png?label=in%20progress&title=In%20Progress)](https://waffle.io/rtcamp/easyengine)
<img src="https://d3qt5vpr7p9rgn.cloudfront.net/wp-content/uploads/2013/08/easy-engine-logo-2-RS1.png" alt="EasyEngine Logo" align="right" />
[![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine)
EasyEngine (ee) is a linux shell-script collection, which makes it easy to manage your wordpress sites running on nginx web-server.
**EasyEngine currently supports:**
- Ubuntu 12.04 & 14.04
- Debian 7
## Quick Start
```bash
wget -qO ee rt.cx/ee && sudo bash ee # install easyengine
sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com
```
## Update EasyEngine
Update Procedure For EasyEngine
```bash
wget -qO eeup http://rt.cx/eeup && sudo bash eeup
```
## More Site Creation Commands
### Standard WordPress Sites
```bash
sudo apt-get install python3-pip git
sudo pip3 install virtualenv
git clone -b python https://github.com/rtCamp/easyengine.git
cd easyengine
virtualenv ./env --system-site-packages
source ./env/bin/activate
sudo pip3 install -r requirements.txt
sudo python3 setup.py develop
ee --help
ee site create example.com --wp # install wordpress without any page caching
ee site create example.com --w3tc # install wordpress with w3-total-cache plugin
ee site create example.com --wpsc # install wordpress with wp-super-cache plugin
ee site create example.com --wpfc # install wordpress + nginx fastcgi_cache
```
How to install this version on your system??
### WordPress Multsite with subdirectory
```bash
sudo apt-get update
sudo apt-get -y install python3 python3-apt python3-setuptools python3-dev git
git clone -b python https://github.com/rtCamp/easyengine.git
cd easyengine
sudo python3 setup.py install
ee --help
ee site create example.com --wpsubdir # install wpmu-subdirectory without any page caching
ee site create example.com --wpsubdir --w3tc # install wpmu-subdirectory with w3-total-cache plugin
ee site create example.com --wpsubdir --wpsc # install wpmu-subdirectory with wp-super-cache plugin
ee site create example.com --wpsubdir --wpfc # install wpmu-subdirectory + nginx fastcgi_cache
```
### WordPress Multsite with subdomain
```bash
ee site create example.com --wpsubdomin # install wpmu-subdomain without any page caching
ee site create example.com --wpsubdomain --w3tc # install wpmu-subdomain with w3-total-cache plugin
ee site create example.com --wpsubdomain --wpsc # install wpmu-subdomain with wp-super-cache plugin
ee site create example.com --wpsubdomain --wpfc # install wpmu-subdomain + nginx fastcgi_cache
```
### Non-WordPress Sites
```bash
ee site create example.com --html # create example.com for static/html sites
ee site create example.com --php # create example.com with php support
ee site create example.com --mysql # create example.com with php & mysql support
```
## Cheatsheet - Site creation
| | Single Site | Multisite w/ Subdir | Multisite w/ Subdom |
|--------------------|---------------|-----------------------|-----------------------|
| **NO Cache** | --wp | --wpsubdir | --wpsubdomain |
| **WP Super Cache** | --wpsc | --wpsubdir --wpsc | --wpsubdomain --wpsc |
| **W3 Total Cache** | --w3tc | --wpsubdir --w3tc | --wpsubdomain --w3tc |
| **Nginx cache** | --wpfc | --wpsubdir --wpfc | --wpsubdomain --wpfc |
EasyEngine 3.x Developement version
## Useful Links
- [Documentation] (http://rtcamp.com/easyengine/docs/)
- [FAQ] (http://rtcamp.com/easyengine/faq/)
- [Conventions used] (http://rtcamp.com/wordpress-nginx/tutorials/conventions/)
## Donations
Thinking To Contribute???
[![Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)] (https://rtcamp.com/donate/?project=easyengine)
refer docs to know more on EasyEngine Developement
## License
follow instruction from step 3 in Creating cement app
http://builtoncement.com/2.4/dev/boss_templates.html
Same [GPL] (http://www.gnu.org/licenses/gpl-2.0.txt) that WordPress uses!

1
config/plugins.d/site.conf

@ -6,4 +6,3 @@
### `ee.cli.plugins.example` or from the file path
### `/var/lib/ee/plugins/example.py`
enable_plugin = true
db_path = sqlite:////var/lib/ee/ee.sqlite

8
ee/cli/plugins/debug.py

@ -53,6 +53,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_nginx(self):
"""Start/Stop Nginx debug"""
# start global debug
if self.start and not self.app.pargs.site_name:
try:
@ -134,6 +135,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_php(self):
"""Start/Stop PHP debug"""
# PHP global debug start
if self.start:
if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php"
@ -173,6 +175,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_fpm(self):
"""Start/Stop PHP5-FPM debug"""
# PHP5-FPM start global debug
if self.start:
if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" "
@ -214,6 +217,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_mysql(self):
"""Start/Stop MySQL debug"""
# MySQL start global debug
if self.start:
if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like"
@ -262,6 +266,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_wp(self):
"""Start/Stop WordPress debug"""
if self.start and self.app.pargs.site_name:
wp_config = ("{0}{1}/wp-config.php"
.format(EEVariables.ee_webroot,
@ -332,6 +337,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def debug_rewrite(self):
"""Start/Stop Nginx rewrite rules debug"""
# Start Nginx rewrite debug globally
if self.start and not self.app.pargs.site_name:
if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" "
@ -396,6 +402,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def signal_handler(self, signal, frame):
"""Handle Ctrl+c hevent for -i option of debug"""
self.start = False
if self.app.pargs.nginx:
self.debug_nginx()
@ -421,6 +428,7 @@ class EEDebugController(CementBaseController):
@expose(hide=True)
def default(self):
"""Default function of debug"""
self.start = True
self.interactive = False
self.msg = []

1
ee/cli/plugins/import_slow_log.py

@ -19,6 +19,7 @@ class EEImportslowlogController(CementBaseController):
@expose(hide=True)
def default(self):
"""Default function for import slow log"""
if os.path.isdir("{0}22222/htdocs/db/anemometer"
.format(EEVariables.ee_webroot)):
if os.path.isfile("/var/log/mysql/mysql-slow.log"):

4
ee/cli/plugins/info.py

@ -36,6 +36,7 @@ class EEInfoController(CementBaseController):
@expose(hide=True)
def info_nginx(self):
"""Display Nginx information"""
version = os.popen("nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | "
"cut -d'/' -f2 | tr -d '\n'").read()
allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
@ -65,6 +66,7 @@ class EEInfoController(CementBaseController):
@expose(hide=True)
def info_php(self):
"""Display PHP information"""
version = os.popen("php -v | head -n1 | cut -d' ' -f2 |"
" cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser()
@ -138,6 +140,7 @@ class EEInfoController(CementBaseController):
@expose(hide=True)
def info_mysql(self):
"""Display MySQL information"""
version = os.popen("mysql -V | awk '{print($5)}' | cut -d ',' "
"-f1 | tr -d '\n'").read()
host = "localhost"
@ -165,6 +168,7 @@ class EEInfoController(CementBaseController):
@expose(hide=True)
def default(self):
"""default function for info"""
if (not self.app.pargs.nginx and not self.app.pargs.php
and not self.app.pargs.mysql):
self.app.pargs.nginx = True

60
ee/cli/plugins/site.py

@ -79,6 +79,13 @@ class EESiteController(CementBaseController):
ee_db_pass = ''
if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(ee_domain)):
check_site = getSiteInfo(self, ee_domain)
if check_site is None:
Log.error(self, " Site {0} does not exist.".format(ee_domain))
else:
sitetype = check_site.site_type
cachetype = check_site.cache_type
ee_site_webroot = EEVariables.ee_webroot + ee_domain
access_log = (ee_site_webroot + '/logs/access.log')
error_log = (ee_site_webroot + '/logs/error.log')
@ -98,7 +105,10 @@ class EESiteController(CementBaseController):
data = dict(domain=ee_domain, webroot=ee_site_webroot,
accesslog=access_log, errorlog=error_log,
dbname=ee_db_name, dbuser=ee_db_user,
dbpass=ee_db_pass)
dbpass=ee_db_pass, type=sitetype + " " + cachetype +
" ({0})".format("enabled"
if check_site.is_enabled else
"disabled"))
self.app.render((data), 'siteinfo.mustache')
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@ -578,9 +588,9 @@ class EESiteUpdateController(CementBaseController):
or self.app.pargs.wpfc or self.app.pargs.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"
or (oldsitetype == 'wp' and oldcachetype == 'basic')):
Log.error(self, "Cannot update {0} {1} {2} to wp basic"
.format(ee_domain, oldsitetype, oldcachetype))
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -597,8 +607,8 @@ class EESiteUpdateController(CementBaseController):
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
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"
or (oldsitetype == 'wp' and oldcachetype == '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,
@ -616,7 +626,7 @@ class EESiteUpdateController(CementBaseController):
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpfc')):
or (oldsitetype == 'wp' and oldcachetype == 'wpfc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -634,7 +644,7 @@ class EESiteUpdateController(CementBaseController):
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpsc')):
or (oldsitetype == 'wp' and oldcachetype == 'wpsc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -657,7 +667,7 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'basic')):
or (oldsitetype == 'wpsubdir' and oldcachetype == 'basic')):
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdir basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -677,7 +687,7 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'w3tc')):
or (oldsitetype == 'wpsubdir' and oldcachetype == 'w3tc')):
Log.error(self, " Cannot update {0} {1} {2}"
"to wpsubdir w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -698,8 +708,8 @@ class EESiteUpdateController(CementBaseController):
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}"
or (oldsitetype == 'wpsubdir' and oldcachetype == 'wpfc')):
Log.error(self, "Cannot update {0} {1} {2}"
" to wpsubdir wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -718,7 +728,7 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpsc')):
or (oldsitetype == 'wpsubdir' and oldcachetype == 'wpsc')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdir wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -736,13 +746,16 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or
self.app.pargs.wpsubdir or self.app.pargs.wp)):
if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
or (oldsitetype == 'wpsubdomain' and
oldcachetype == 'basic')):
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))
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdomain basic"
.format(ee_domain, oldsitetype, oldcachetype))
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=True, w3tc=False,
@ -760,7 +773,8 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'w3tc')):
(oldsitetype == 'wpsubdomain' and oldcachetype == 'w3tc')):
print(oldsitetype, oldcachetype)
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -781,7 +795,8 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpfc')):
(oldsitetype == 'wpsubdomain' and oldcachetype == 'wpfc')):
print(oldsitetype, oldcachetype)
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdomain wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -802,7 +817,8 @@ class EESiteUpdateController(CementBaseController):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpsc')):
(oldsitetype == 'wpsubdomain' and oldcachetype == 'wpsc')):
print(oldsitetype, oldcachetype)
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain wpsc"
.format(ee_domain, oldsitetype, oldcachetype))

12
ee/cli/plugins/sitedb.py

@ -9,7 +9,10 @@ import sys
def addNewSite(self, site, stype, cache, path,
enabled=True, ssl=False, fs='ext4', db=''):
enabled=True, ssl=False, fs='ext4', db='mysql'):
"""
Add New Site record information into ee database.
"""
try:
newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db)
db_session.add(newRec)
@ -20,6 +23,9 @@ def addNewSite(self, site, stype, cache, path,
def getSiteInfo(self, site):
"""
Retrieves site record from ee databse
"""
try:
q = SiteDB.query.filter(SiteDB.sitename == site).first()
return q
@ -30,6 +36,7 @@ def getSiteInfo(self, site):
def updateSiteInfo(self, site, stype='', cache='',
enabled=True, ssl=False, fs='', db=''):
"""updates site record in database"""
try:
q = SiteDB.query.filter(SiteDB.sitename == site).first()
except Exception as e:
@ -39,6 +46,7 @@ def updateSiteInfo(self, site, stype='', cache='',
if not q:
Log.error(self, "{0} does not exist in database".format(site))
# Check if new record matches old if not then only update database
if stype and q.site_type != stype:
q.site_type = stype
@ -60,6 +68,7 @@ def updateSiteInfo(self, site, stype='', cache='',
def deleteSiteInfo(self, site):
"""Delete site record in database"""
try:
q = SiteDB.query.filter(SiteDB.sitename == site).first()
except Exception as e:
@ -78,6 +87,7 @@ def deleteSiteInfo(self, site):
def getAllsites(self):
try:
q = SiteDB.query.all()
return q

7
ee/cli/plugins/stack.py

@ -68,11 +68,12 @@ class EEStackController(CementBaseController):
@expose(hide=True)
def default(self):
# TODO Default action for ee stack command
"""default action of ee stack command"""
self.app.args.print_help()
@expose(hide=True)
def pre_pref(self, apt_packages):
"""Pre settings to do before installation packages"""
if set(EEVariables.ee_postfix).issubset(set(apt_packages)):
Log.info(self, "Pre-seeding Postfix")
EEShellExec.cmd_exec(self, "echo \"postfix postfix"
@ -143,6 +144,7 @@ class EEStackController(CementBaseController):
@expose(hide=True)
def post_pref(self, apt_packages, packages):
"""Post activity after installation of packages"""
if len(apt_packages):
if set(EEVariables.ee_postfix).issubset(set(apt_packages)):
EEGit.add(self, ["/etc/postfix"],
@ -1033,6 +1035,7 @@ class EEStackController(CementBaseController):
@expose(help="Install packages")
def install(self, packages=[], apt_packages=[], disp_msg=True):
"""Start installation of packages"""
self.msg = []
try:
# Default action for stack installation
@ -1225,6 +1228,7 @@ class EEStackController(CementBaseController):
@expose(help="Remove packages")
def remove(self):
"""Start removal of packages"""
apt_packages = []
packages = []
@ -1312,6 +1316,7 @@ class EEStackController(CementBaseController):
@expose(help="Purge packages")
def purge(self):
"""Start purging of packages"""
apt_packages = []
packages = []

5
ee/cli/plugins/stack_services.py

@ -19,6 +19,7 @@ class EEStackStatusController(CementBaseController):
@expose(help="Start stack services")
def start(self):
"""Start services"""
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service start")
@ -46,6 +47,7 @@ class EEStackStatusController(CementBaseController):
@expose(help="Stop stack services")
def stop(self):
"""Stop services"""
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service stop")
@ -73,6 +75,7 @@ class EEStackStatusController(CementBaseController):
@expose(help="Restart stack services")
def restart(self):
"""Restart services"""
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service restart")
@ -100,6 +103,7 @@ class EEStackStatusController(CementBaseController):
@expose(help="Get stack status")
def status(self):
"""Status of services"""
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service status")
@ -128,6 +132,7 @@ class EEStackStatusController(CementBaseController):
@expose(help="Reload stack services")
def reload(self):
"""Reload service"""
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service reload")

1
ee/core/addswap.py

@ -13,6 +13,7 @@ class EESwap():
pass
def add(self):
"""Swap addition with EasyEngine"""
if EEVariables.ee_ram < 512:
if EEVariables.ee_swap < 1000:
Log.info(self, "Adding SWAP")

1
ee/core/checkfqdn.py

@ -4,6 +4,7 @@ import os
def check_fqdn(self, ee_host):
"""FQDN check with EasyEngine, for mail server hostname must be FQDN"""
#ee_host=os.popen("hostname -f | tr -d '\n'").read()
if '.' in ee_host:
EEVariables.ee_fqdn = ee_host

3
ee/core/database.py

@ -2,9 +2,10 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from ee.core.variables import EEVariables
# db_path = self.app.config.get('site', 'db_path')
engine = create_engine('sqlite:////var/lib/ee/ee.sqlite', convert_unicode=True)
engine = create_engine(EEVariables.ee_db_uri, convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))

5
ee/core/download.py

@ -11,6 +11,8 @@ class EEDownload():
pass
def download(self, packages):
"""Download packages, packges must be list in format of
[url, path, package name]"""
for package in packages:
url = package[0]
filename = package[1]
@ -21,7 +23,8 @@ class EEDownload():
os.makedirs(directory)
Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ')
urllib.request.urlretrieve(url, filename)
Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]"))
Log.info(self, "{0}".format("[" + Log.ENDC + "Done"
+ Log.OKBLUE + "]"))
except urllib.error.URLError as e:
Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to donwload file, {0}"

1
ee/core/extract.py

@ -8,6 +8,7 @@ class EEExtract():
"""Method to extract from tar.gz file"""
def extract(self, file, path):
"""Function to extract tar.gz file"""
try:
tar = tarfile.open(file)
tar.extractall(path=path)

1
ee/core/mysql.py

@ -10,6 +10,7 @@ class EEMysql():
"""Method for MySQL connection"""
def execute(self, statement, errormsg=''):
"""Get login details from ~/.my.cnf & Execute MySQL query"""
config = configparser.RawConfigParser()
cnfpath = expanduser("~")+"/.my.cnf"
if [cnfpath] == config.read(cnfpath):

1
ee/core/shellexec.py

@ -12,6 +12,7 @@ class EEShellExec():
pass
def cmd_exec(self, command, errormsg=''):
"""Run shell command from Python"""
try:
Log.debug(self, "Running command: {0}".format(command))
retcode = subprocess.getstatusoutput(command)

4
ee/core/variables.py

@ -115,5 +115,9 @@ class EEVariables():
ee_repo_file = "ee-repo.list"
ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file)
# Application dabase file path
basedir = os.path.abspath(os.path.dirname('/var/lib/ee/'))
ee_db_uri = 'sqlite:///' + os.path.join(basedir, 'ee.db')
def __init__(self):
pass

241
install

@ -0,0 +1,241 @@
#!/bin/bash
# EasyEngine update script.
# This script is designed to install latest EasyEngine or
# to update current EasyEngine from 2.x to 3.x
old_ee_version="2.2.3"
branch=$1
# Define echo function
# Blue color
function ee_lib_echo()
{
echo $(tput setaf 4)$@$(tput sgr0)
}
# White color
function ee_lib_echo_info()
{
echo $(tput setaf 7)$@$(tput sgr0)
}
# Red color
function ee_lib_echo_fail()
{
echo $(tput setaf 1)$@$(tput sgr0)
}
# Capture errors
function ee_lib_error()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)"
exit $2
}
function install_dep()
{
# Execute: apt-get update
ee_lib_echo "Executing apt-get update"
apt-get update &>> /dev/null
# Install Python3 on users system
ee_lib_echo "Installing pre depedencies"
apt-get -y install python3 python3-apt python3-setuptools python3-dev sqlite3 git
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install pre depedencies"
exit 1
fi
}
function sync_db()
{
mkdir /var/lib/ee
# Sqlite query to create table `sites` into ee.db which will be used by ee.3.0
echo "CREATE TABLE sites (
id INTEGER PRIMARY KEY AUTOINCREMENT,
sitename UNIQUE,
site_type CHAR,
cache_type CHAR,
site_path CHAR,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_enabled INT,
is_ssl INT,
storage_fs CHAR,
storage_db CHAR
);" | sqlite3 /var/lib/ee/ee.db
for site in $(ls /etc/nginx/sites-available/ | grep -v default);
do
if [ -f /etc/nginx/sites-available/$site ]; then
ENABLE_STATUS='1'
else
ENABLE_STATUS='0'
fi
# Find out information about current NGINX configuration
EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$site | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5)
# Detect current website type and cache
if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then
EE_SITE_CURRENT="html"
EE_SITE_CURRENT_CACHE="basic"
elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then
EE_SITE_CURRENT="php"
EE_SITE_CURRENT_CACHE="basic"
elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then
EE_SITE_CURRENT="mysql"
EE_SITE_CURRENT_CACHE="basic"
# Single WordPress
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then
EE_SITE_CURRENT="wp"
EE_SITE_CURRENT_CACHE="basic"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then
EE_SITE_CURRENT="wp"
EE_SITE_CURRENT_CACHE="wpsc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then
EE_SITE_CURRENT="wp"
EE_SITE_CURRENT_CACHE="w3tc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then
EE_SITE_CURRENT="wp"
EE_SITE_CURRENT_CACHE="wpfc"
# WordPress subdirectory
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then
EE_SITE_CURRENT="wpsubdir"
EE_SITE_CURRENT_CACHE="basic"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then
EE_SITE_CURRENT="wpsubdir"
EE_SITE_CURRENT_CACHE="wpsc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then
EE_SITE_CURRENT="wpsubdir"
EE_SITE_CURRENT_CACHE="w3tc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then
EE_SITE_CURRENT="wpsubdir"
EE_SITE_CURRENT_CACHE="wpfc"
# WordPress subdomain
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then
EE_SITE_CURRENT="wpsubdomain"
EE_SITE_CURRENT_CACHE="basic"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then
EE_SITE_CURRENT="wpsubdomain"
EE_SITE_CURRENT_CACHE="wpsc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then
EE_SITE_CURRENT="wpsubdomain"
EE_SITE_CURRENT_CACHE="w3tc"
elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then
EE_SITE_CURRENT="wpsubdomain"
EE_SITE_CURRENT_CACHE="wpfc"
fi
WEBROOT="/var/www/$site"
# Insert query to insert old site information into ee.db
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
VALUES (\"$site\", \"$EE_SITE_CURRENT\", \"$EE_SITE_CURRENT_CACHE\", \"$WEBROOT\", \"$ENABLE_STATUS\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/ee/ee.db
done
}
function install_ee3()
{
# Remove old clone of EasyEngine (ee) if any
rm -rf /tmp/easyengine &>> /dev/null
# Clone EE 3.0 Python branch
ee_lib_echo "Cloning EasyEngine 3.0"
if [ "$branch" = "" ]; then
branch=python
fi
git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine --quiet > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1
cd /tmp/easyengine
ee_lib_echo "Installing EasyEngine 3.0"
python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1
}
function update_to_ee3()
{
# Preserve old configuration
ee_lib_echo "Updating EasyEngine 3.0 configuration"
grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }')
db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }')
wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }')
ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }')
sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \
sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \
sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \
sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \
sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \
sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \
sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \
sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1
# Remove old EasyEngine
ee_lib_echo "Removing EasyEngine 2"
rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine
}
function git_init()
{
# Do git intialisation on EasyEngine configuration
cd /etc/ee
if [ ! -d /etc/ee/.git ]; then
git init > /dev/null
fi
git add .
git commit -am "Installed/Updated to EasyEngine 3" > /dev/null
}
# Checking permissions
if [[ $EUID -ne 0 ]]; then
ee_lib_echo_fail "Sudo privilege required..."
ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee"
exit 1
fi
# Check old EasyEngine is installed or not
if [ ! -f /usr/local/sbin/easyengine ]; then
# Check latest EasyEngine is installed or not
if [ ! -f /usr/local/bin/ee ]; then
install_dep
install_ee3
git_init
else
ee_lib_echo_fail "EasyEngine 3 allready installed on ur system"
exit 1
fi
else
# Check old EasyEngine version
ee version | grep ${old_ee_version} &>> /dev/null
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system"
ee_lib_echo_fail "Please update it using command: ee update"
exit 1
fi
install_dep
sync_db
install_ee3
update_to_ee3
git_init
fi

10
setup.py

@ -86,3 +86,13 @@ setup(name='ee',
""",
namespace_packages=[],
)
print("""\033[94m
For EasyEngine (ee) auto completion, run the following command
\033[92m
source /etc/bash_completion.d/ee_auto.rc
\033[94m
EasyEngine (ee) installed successfully
EasyEngine (ee) help: https://rtcamp.com/easyengine/docs/
\033[0m
""")

114
upgrade

@ -1,114 +0,0 @@
#!/bin/bash
# EasyEngine update script.
# This script is designed to update current EasyEngine from 2.2.2 to 3.x
# Define echo function
old_ee_version="2.2.3"
branch=$1
# Blue color
function ee_lib_echo()
{
echo $(tput setaf 4)$@$(tput sgr0)
}
# White color
function ee_lib_echo_info()
{
echo $(tput setaf 7)$@$(tput sgr0)
}
# Red color
function ee_lib_echo_fail()
{
echo $(tput setaf 1)$@$(tput sgr0)
}
# Checking permissions
if [[ $EUID -ne 0 ]]; then
ee_lib_echo_fail "Sudo privilege required..."
ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee"
exit 1
fi
# Check old EasyEngine is installed or not
if [ ! -f /usr/local/sbin/easyengine ]; then
ee_lib_echo_fail "EasyEngine 2.0 not found"
exit 1
fi
# Check old EasyEngine version
ee version | grep ${old_ee_version} &>> /dev/null
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system"
ee_lib_echo_fail "Please update is using command: ee update"
exit 1
fi
# Capture errors
function ee_lib_error()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)"
exit $2
}
# Execute: apt-get update
ee_lib_echo "Executing apt-get update"
apt-get update &>> /dev/null
# Install Python3 on users system
ee_lib_echo "Installing Python3"
apt-get -y install python3 python3-apt python3-setuptools python3-dev
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install Python3 on system"
exit 1
fi
# Remove old version of EasyEngine (ee)
rm -rf /tmp/easyengine &>> /dev/null
# Clone EE 3.0 Python branch
ee_lib_echo "Cloning EasyEngine 3.0"
if [ "$branch" = "" ]; then
branch=python
fi
git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1
cd /tmp/easyengine
ee_lib_echo "Installing EasyEngine 3.0"
python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1
# Preserve old configuration
ee_lib_echo "Updating EasyEngine 3.0 configuration"
grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }')
db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }')
wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }')
ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }')
sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \
sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \
sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \
sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \
sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \
sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \
sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \
sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1
# Remove old EasyEngine
ee_lib_echo "Removing EasyEngine 2"
rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine
ee_lib_echo "Doing GIT init"
cd /etc/ee
if [ ! -d /etc/ee/.git ]; then
git init > /dev/null
fi
git commit -am "Update EasyEngine 2 to EasyEngine 3" > /dev/null
ee_lib_echo "Successfully update to EasyEngine 3"
Loading…
Cancel
Save