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. 60
      ee/cli/plugins/stack.py

23
ee/cli/plugins/site.py

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

41
ee/cli/plugins/site_functions.py

@ -3,10 +3,12 @@ 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
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 glob
@ -178,9 +180,9 @@ def SetupWordpress(self, data):
+ "--dbuser={0} --dbpass={1} "
"--extra-php<<PHP \n {var1} {var2} \nPHP"
.format(data['ee_db_user'], data['ee_db_pass'],
var1=
var1=""
"\n define('WP_ALLOW_MULTISITE', true);",
var2=
var2=""
"\n define('WPMU_ACCEL_REDIRECT', true);")
)
@ -317,3 +319,38 @@ def siteBackup(self, data):
EEFileUtils.mvfile(self, configfiles[0], backup_path)
else:
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)

60
ee/cli/plugins/stack.py

@ -904,6 +904,7 @@ class EEStackController(CementBaseController):
@expose()
def install(self, packages=[], apt_packages=[]):
self.msg = []
try:
if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")
@ -932,7 +933,8 @@ class EEStackController(CementBaseController):
apt_packages = apt_packages + EEVariables.ee_mail
packages = packages + [["https://github.com/opensolutions/"
"ViMbAdmin/archive/3.0.10.tar.gz",
"/tmp/vimbadmin.tar.gz", "ViMbAdmin"],
"/tmp/vimbadmin.tar.gz",
"ViMbAdmin"],
["https://github.com/roundcube/"
"roundcubemail/releases/download/"
"1.0.4/roundcubemail-1.0.4.tar.gz",
@ -940,7 +942,8 @@ class EEStackController(CementBaseController):
"Roundcube"]]
if EEVariables.ee_ram > 1024:
apt_packages = apt_packages + EEVariables.ee_mailscanner
apt_packages = (apt_packages +
EEVariables.ee_mailscanner)
else:
Log.info(self, "Mail server is allready installed")
@ -979,52 +982,61 @@ class EEStackController(CementBaseController):
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",
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"]]
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:
Log.debug(self, "Setting packages variable for utils")
packages = packages + [["http://phpmemcacheadmin.googlecode.com/"
"files/phpMemcachedAdmin-1.2.2"
packages = packages + [["http://phpmemcacheadmin.googlecode"
".com/files/phpMemcachedAdmin-1.2.2"
"-r262.tar.gz", '/tmp/memcache.tar.gz',
'phpMemcachedAdmin'],
["https://raw.githubusercontent.com/rtCamp/"
"eeadmin/master/cache/nginx/clean.php",
["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",
["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",
["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"
"/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb"
"/ocp.php",
"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-too"
"lkit-dev/percona-toolkit/2.1/download/he"
"ad:/ptquerydigest-20110624220137-or26tn4"
["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",
["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):

Loading…
Cancel
Save