Browse Source

Added package insttallation during site creation, finally :)

bugfixes
gau1991 10 years ago
parent
commit
b5005967a7
  1. 23
      ee/cli/plugins/site.py
  2. 41
      ee/cli/plugins/site_functions.py
  3. 288
      ee/cli/plugins/stack.py

23
ee/cli/plugins/site.py

@ -216,7 +216,7 @@ class EESiteCreateController(CementBaseController):
stype = 'html' stype = 'html'
cache = 'basic' cache = 'basic'
#PHP # PHP
if (self.app.pargs.php and not (self.app.pargs.html or if (self.app.pargs.php and not (self.app.pargs.html or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc 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 or self.app.pargs.wpfc or self.app.pargs.wpsc or
@ -228,7 +228,7 @@ class EESiteCreateController(CementBaseController):
wpsubdir=False, webroot=ee_site_webroot) wpsubdir=False, webroot=ee_site_webroot)
stype = 'php' stype = 'php'
cache = 'basic' cache = 'basic'
#MySQL # MySQL
if (self.app.pargs.mysql and not (self.app.pargs.html or if (self.app.pargs.mysql and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or or self.app.pargs.wpfc or self.app.pargs.wpsc or
@ -242,7 +242,7 @@ class EESiteCreateController(CementBaseController):
ee_db_host='') ee_db_host='')
stype = 'mysql' stype = 'mysql'
cache = 'basic' cache = 'basic'
#WP # WP
if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or
self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.wpsc) and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.php or self.app.pargs.mysql or
@ -296,7 +296,7 @@ class EESiteCreateController(CementBaseController):
stype = 'wp' stype = 'wp'
cache = 'wpsc' cache = 'wpsc'
#WPSUBDIR # WPSUBDIR
if (self.app.pargs.wpsubdir and not (self.app.pargs.html or if (self.app.pargs.wpsubdir and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.php or self.app.pargs.mysql or
self.app.pargs.wpsubdomain or self.app.pargs.wp)): self.app.pargs.wpsubdomain or self.app.pargs.wp)):
@ -348,7 +348,7 @@ class EESiteCreateController(CementBaseController):
stype = 'wpsubdir' stype = 'wpsubdir'
cache = 'wpsc' cache = 'wpsc'
#WPSUBDOAIN # WPSUBDOAIN
if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or 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.php or self.app.pargs.mysql or
self.app.pargs.wpsubdir or self.app.pargs.wp)): self.app.pargs.wpsubdir or self.app.pargs.wp)):
@ -401,6 +401,9 @@ class EESiteCreateController(CementBaseController):
stype = 'wpsubdomain' stype = 'wpsubdomain'
cache = 'wpsc' cache = 'wpsc'
# Check rerequired packages are installed or not
site_package_check(self, stype)
# setup NGINX configuration, and webroot # setup NGINX configuration, and webroot
SetupDomain(self, data) SetupDomain(self, data)
# Setup database for MySQL site # Setup database for MySQL site
@ -498,7 +501,7 @@ class EESiteUpdateController(CementBaseController):
self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
pass pass
#PHP # PHP
if (self.app.pargs.php and not (self.app.pargs.html or if (self.app.pargs.php and not (self.app.pargs.html or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc 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 or self.app.pargs.wpfc or self.app.pargs.wpsc or
@ -517,7 +520,7 @@ class EESiteUpdateController(CementBaseController):
stype = 'php' stype = 'php'
cache = 'basic' cache = 'basic'
#MySQL # MySQL
if (self.app.pargs.mysql and not (self.app.pargs.html or if (self.app.pargs.mysql and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or or self.app.pargs.wpfc or self.app.pargs.wpsc or
@ -537,7 +540,7 @@ class EESiteUpdateController(CementBaseController):
stype = 'mysql' stype = 'mysql'
cache = 'basic' cache = 'basic'
#WP # WP
if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or
self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.wpsc) and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.php or self.app.pargs.mysql or
@ -616,7 +619,7 @@ class EESiteUpdateController(CementBaseController):
stype = 'wp' stype = 'wp'
cache = 'wpsc' cache = 'wpsc'
#WPSUBDIR # WPSUBDIR
if (self.app.pargs.wpsubdir and not (self.app.pargs.html or if (self.app.pargs.wpsubdir and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.php or self.app.pargs.mysql or
self.app.pargs.wpsubdomain or self.app.pargs.wp)): self.app.pargs.wpsubdomain or self.app.pargs.wp)):
@ -860,7 +863,7 @@ class EESiteUpdateController(CementBaseController):
msg="{0} updated with {1} {2}" msg="{0} updated with {1} {2}"
.format(ee_www_domain, stype, cache)) .format(ee_www_domain, stype, cache))
# Setup Permissions for webroot # Setup Permissions for webroot
#SetWebrootPermissions(self, data['webroot']) # SetWebrootPermissions(self, data['webroot'])
updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache)
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"

41
ee/cli/plugins/site_functions.py

@ -3,10 +3,12 @@ import random
import string import string
import sys import sys
import getpass import getpass
from ee.cli.plugins.stack import EEStackController
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from ee.core.mysql import EEMysql from ee.core.mysql import EEMysql
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables from ee.core.variables import EEVariables
from ee.core.aptget import EEAptGet
from ee.core.logging import Log from ee.core.logging import Log
import glob import glob
@ -178,9 +180,9 @@ def SetupWordpress(self, data):
+ "--dbuser={0} --dbpass={1} " + "--dbuser={0} --dbpass={1} "
"--extra-php<<PHP \n {var1} {var2} \nPHP" "--extra-php<<PHP \n {var1} {var2} \nPHP"
.format(data['ee_db_user'], data['ee_db_pass'], .format(data['ee_db_user'], data['ee_db_pass'],
var1= var1=""
"\n define('WP_ALLOW_MULTISITE', true);", "\n define('WP_ALLOW_MULTISITE', true);",
var2= var2=""
"\n define('WPMU_ACCEL_REDIRECT', true);") "\n define('WPMU_ACCEL_REDIRECT', true);")
) )
@ -317,3 +319,38 @@ def siteBackup(self, data):
EEFileUtils.mvfile(self, configfiles[0], backup_path) EEFileUtils.mvfile(self, configfiles[0], backup_path)
else: else:
EEFileUtils.copyfile(self, configfiles[0], backup_path) EEFileUtils.copyfile(self, configfiles[0], backup_path)
def site_package_check(self, stype):
apt_packages = []
packages = []
stack = EEStackController()
stack.app = self.app
if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for Nginx")
if not EEAptGet.is_installed(self, 'nginx-common'):
apt_packages = apt_packages + EEVariables.ee_nginx
if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP")
if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL")
if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + EEVariables.ee_mysql
if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PostFix")
if not EEAptGet.is_installed(self, 'postfix'):
apt_packages = apt_packages + EEVariables.ee_postfix
if stype in ['wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting packages variable for WPCLI")
if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v0.17.1/"
"wp-cli.phar", "/usr/bin/wp",
"WP_CLI"]]
stack.install(apt_packages=apt_packages, packages=packages)

288
ee/cli/plugins/stack.py

@ -904,145 +904,157 @@ class EEStackController(CementBaseController):
@expose() @expose()
def install(self, packages=[], apt_packages=[]): def install(self, packages=[], apt_packages=[]):
self.msg = [] self.msg = []
if self.app.pargs.web: try:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" if self.app.pargs.web:
" ,MySQL ") Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
self.app.pargs.nginx = True " ,MySQL ")
self.app.pargs.php = True self.app.pargs.nginx = True
self.app.pargs.mysql = True self.app.pargs.php = True
self.app.pargs.wpcli = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.wpcli = True
self.app.pargs.postfix = True
if self.app.pargs.admin:
self.app.pargs.nginx = True if self.app.pargs.admin:
self.app.pargs.php = True self.app.pargs.nginx = True
self.app.pargs.mysql = True self.app.pargs.php = True
self.app.pargs.adminer = True self.app.pargs.mysql = True
self.app.pargs.phpmyadmin = True self.app.pargs.adminer = True
self.app.pargs.utils = True self.app.pargs.phpmyadmin = True
self.app.pargs.utils = True
if self.app.pargs.mail:
self.app.pargs.nginx = True if self.app.pargs.mail:
self.app.pargs.php = True self.app.pargs.nginx = True
self.app.pargs.mysql = True self.app.pargs.php = True
self.app.pargs.postfix = True self.app.pargs.mysql = True
self.app.pargs.postfix = True
if not EEAptGet.is_installed(self, 'dovecot-core'):
Log.debug(self, "Setting apt_packages variable for mail") if not EEAptGet.is_installed(self, 'dovecot-core'):
apt_packages = apt_packages + EEVariables.ee_mail Log.debug(self, "Setting apt_packages variable for mail")
packages = packages + [["https://github.com/opensolutions/" apt_packages = apt_packages + EEVariables.ee_mail
"ViMbAdmin/archive/3.0.10.tar.gz", packages = packages + [["https://github.com/opensolutions/"
"/tmp/vimbadmin.tar.gz", "ViMbAdmin"], "ViMbAdmin/archive/3.0.10.tar.gz",
["https://github.com/roundcube/" "/tmp/vimbadmin.tar.gz",
"roundcubemail/releases/download/" "ViMbAdmin"],
"1.0.4/roundcubemail-1.0.4.tar.gz", ["https://github.com/roundcube/"
"/tmp/roundcube.tar.gz", "roundcubemail/releases/download/"
"Roundcube"]] "1.0.4/roundcubemail-1.0.4.tar.gz",
"/tmp/roundcube.tar.gz",
if EEVariables.ee_ram > 1024: "Roundcube"]]
apt_packages = apt_packages + EEVariables.ee_mailscanner
else: if EEVariables.ee_ram > 1024:
Log.info(self, "Mail server is allready installed") apt_packages = (apt_packages +
EEVariables.ee_mailscanner)
if self.app.pargs.nginx: else:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.info(self, "Mail server is allready installed")
if not EEAptGet.is_installed(self, 'nginx-common'):
apt_packages = apt_packages + EEVariables.ee_nginx
else:
Log.info(self, "Nginx allready installed")
if self.app.pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP")
if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
else:
Log.info(self, "PHP allready installed")
if self.app.pargs.mysql:
Log.debug(self, "Setting apt_packages variable for MySQL")
if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + EEVariables.ee_mysql
else:
Log.info(self, "MySQL connection is allready alive")
if self.app.pargs.postfix:
Log.debug(self, "Setting apt_packages variable for PostFix")
if not EEAptGet.is_installed(self, 'postfix'):
apt_packages = apt_packages + EEVariables.ee_postfix
else:
Log.info(self, "Postfix is allready installed")
if self.app.pargs.wpcli:
Log.debug(self, "Setting packages variable for WPCLI")
if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v0.17.1/"
"wp-cli.phar", "/usr/bin/wp",
"WP_CLI"]]
else:
Log.info(self, "WP-CLI is allready installed")
if self.app.pargs.phpmyadmin:
Log.debug(self, "Setting packages varible for phpMyAdmin ")
packages = packages + [["https://github.com/phpmyadmin/phpmyadmin"
"/archive/STABLE.tar.gz",
"/tmp/pma.tar.gz", "phpMyAdmin"]]
if self.app.pargs.adminer:
Log.debug(self, "Setting packages variable for Adminer ")
packages = packages + [["http://downloads.sourceforge.net/adminer"
"/adminer-4.1.0.php", "/var/www/22222/"
"htdocs/db/adminer/index.php", "Adminer"]]
if self.app.pargs.utils: if self.app.pargs.nginx:
Log.debug(self, "Setting packages variable for utils") Log.debug(self, "Setting apt_packages variable for Nginx")
packages = packages + [["http://phpmemcacheadmin.googlecode.com/" if not EEAptGet.is_installed(self, 'nginx-common'):
"files/phpMemcachedAdmin-1.2.2" apt_packages = apt_packages + EEVariables.ee_nginx
"-r262.tar.gz", '/tmp/memcache.tar.gz', else:
'phpMemcachedAdmin'], Log.info(self, "Nginx allready installed")
["https://raw.githubusercontent.com/rtCamp/" if self.app.pargs.php:
"eeadmin/master/cache/nginx/clean.php", Log.debug(self, "Setting apt_packages variable for PHP")
"/var/www/22222/htdocs/cache/" if not EEAptGet.is_installed(self, 'php5-fpm'):
"nginx/clean.php", "clean.php"], apt_packages = apt_packages + EEVariables.ee_php
["https://raw.github.com/rlerdorf/opcache-" else:
"status/master/opcache.php", Log.info(self, "PHP allready installed")
"/var/www/22222/htdocs/cache/" if self.app.pargs.mysql:
"opcache/opcache.php", "opcache.php"], Log.debug(self, "Setting apt_packages variable for MySQL")
["https://raw.github.com/amnuts/opcache-gui" if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
"/master/index.php", apt_packages = apt_packages + EEVariables.ee_mysql
"/var/www/22222/htdocs/" else:
"cache/opcache/opgui.php", "index.php"], Log.info(self, "MySQL connection is allready alive")
["https://gist.github.com/ck-on/4959032/raw" if self.app.pargs.postfix:
"/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb" Log.debug(self, "Setting apt_packages variable for PostFix")
"/ocp.php", if not EEAptGet.is_installed(self, 'postfix'):
"/var/www/22222/htdocs/cache/" apt_packages = apt_packages + EEVariables.ee_postfix
"opcache/ocp.php", "ocp.php"], else:
["https://github.com/jokkedk/webgrind/" Log.info(self, "Postfix is allready installed")
"archive/master.tar.gz", if self.app.pargs.wpcli:
'/tmp/webgrind.tar.gz', 'Webgrind'], Log.debug(self, "Setting packages variable for WPCLI")
["http://bazaar.launchpad.net/~percona-too" if not EEShellExec.cmd_exec(self, "which wp"):
"lkit-dev/percona-toolkit/2.1/download/he" packages = packages + [["https://github.com/wp-cli/wp-cli/"
"ad:/ptquerydigest-20110624220137-or26tn4" "releases/download/v0.17.1/"
"expb9ul2a-16/pt-query-digest", "wp-cli.phar", "/usr/bin/wp",
"/usr/bin/pt-query-advisor", "WP_CLI"]]
"pt-query-digest"], else:
["https://github.com/box/Anemometer/archive" Log.info(self, "WP-CLI is allready installed")
"/master.tar.gz", if self.app.pargs.phpmyadmin:
'/tmp/anemometer.tar.gz', 'Anemometer'] Log.debug(self, "Setting packages varible for phpMyAdmin ")
] packages = packages + [["https://github.com/phpmyadmin/"
Log.debug(self, "Calling pre_pref ") "phpmyadmin/archive/STABLE.tar.gz",
self.pre_pref(apt_packages) "/tmp/pma.tar.gz", "phpMyAdmin"]]
if len(apt_packages):
EESwap.add(self) if self.app.pargs.adminer:
Log.debug(self, "Updating apt-cache") Log.debug(self, "Setting packages variable for Adminer ")
EEAptGet.update(self) packages = packages + [["http://downloads.sourceforge.net/"
Log.debug(self, "Installing all apt_packages") "adminer/adminer-4.1.0.php",
print(apt_packages) "/var/www/22222/"
EEAptGet.install(self, apt_packages) "htdocs/db/adminer/index.php",
if len(packages): "Adminer"]]
Log.debug(self, "Downloading all packages")
EEDownload.download(self, packages) if self.app.pargs.utils:
Log.debug(self, "Calling post_pref") Log.debug(self, "Setting packages variable for utils")
self.post_pref(apt_packages, packages) packages = packages + [["http://phpmemcacheadmin.googlecode"
if len(self.msg): ".com/files/phpMemcachedAdmin-1.2.2"
for msg in self.msg: "-r262.tar.gz", '/tmp/memcache.tar.gz',
Log.info(self, msg) 'phpMemcachedAdmin'],
Log.info(self, "Successfully installed packages") ["https://raw.githubusercontent.com"
"/rtCamp/eeadmin/master/cache/nginx/"
"clean.php",
"/var/www/22222/htdocs/cache/"
"nginx/clean.php", "clean.php"],
["https://raw.github.com/rlerdorf/"
"opcache-status/master/opcache.php",
"/var/www/22222/htdocs/cache/"
"opcache/opcache.php", "opcache.php"],
["https://raw.github.com/amnuts/"
"opcache-gui/master/index.php",
"/var/www/22222/htdocs/"
"cache/opcache/opgui.php",
"index.php"],
["https://gist.github.com/ck-on/4959032"
"/raw/0b871b345fd6cfcd6d2be030c1f33d1"
"ad6a475cb/ocp.php",
"/var/www/22222/htdocs/cache/"
"opcache/ocp.php", "ocp.php"],
["https://github.com/jokkedk/webgrind/"
"archive/master.tar.gz",
'/tmp/webgrind.tar.gz', 'Webgrind'],
["http://bazaar.launchpad.net/~"
"percona-toolkit-dev/percona-toolkit/"
"2.1/download/head:/ptquerydigest-"
"20110624220137-or26tn4"
"expb9ul2a-16/pt-query-digest",
"/usr/bin/pt-query-advisor",
"pt-query-digest"],
["https://github.com/box/Anemometer/"
"archive/master.tar.gz",
'/tmp/anemometer.tar.gz', 'Anemometer']
]
except Exception as e:
pass
if len(apt_packages) or len(packages):
Log.debug(self, "Calling pre_pref ")
self.pre_pref(apt_packages)
if len(apt_packages):
EESwap.add(self)
Log.debug(self, "Updating apt-cache")
EEAptGet.update(self)
Log.debug(self, "Installing all apt_packages")
print(apt_packages)
EEAptGet.install(self, apt_packages)
if len(packages):
Log.debug(self, "Downloading all packages")
EEDownload.download(self, packages)
Log.debug(self, "Calling post_pref")
self.post_pref(apt_packages, packages)
if len(self.msg):
for msg in self.msg:
Log.info(self, msg)
Log.info(self, "Successfully installed packages")
@expose() @expose()
def remove(self): def remove(self):

Loading…
Cancel
Save