Browse Source

Added package insttallation during site creation, finally :)

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

3
ee/cli/plugins/site.py

@ -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

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)

60
ee/cli/plugins/stack.py

@ -904,6 +904,7 @@ class EEStackController(CementBaseController):
@expose() @expose()
def install(self, packages=[], apt_packages=[]): def install(self, packages=[], apt_packages=[]):
self.msg = [] self.msg = []
try:
if self.app.pargs.web: if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ") " ,MySQL ")
@ -932,7 +933,8 @@ class EEStackController(CementBaseController):
apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mail
packages = packages + [["https://github.com/opensolutions/" packages = packages + [["https://github.com/opensolutions/"
"ViMbAdmin/archive/3.0.10.tar.gz", "ViMbAdmin/archive/3.0.10.tar.gz",
"/tmp/vimbadmin.tar.gz", "ViMbAdmin"], "/tmp/vimbadmin.tar.gz",
"ViMbAdmin"],
["https://github.com/roundcube/" ["https://github.com/roundcube/"
"roundcubemail/releases/download/" "roundcubemail/releases/download/"
"1.0.4/roundcubemail-1.0.4.tar.gz", "1.0.4/roundcubemail-1.0.4.tar.gz",
@ -940,7 +942,8 @@ class EEStackController(CementBaseController):
"Roundcube"]] "Roundcube"]]
if EEVariables.ee_ram > 1024: if EEVariables.ee_ram > 1024:
apt_packages = apt_packages + EEVariables.ee_mailscanner apt_packages = (apt_packages +
EEVariables.ee_mailscanner)
else: else:
Log.info(self, "Mail server is allready installed") Log.info(self, "Mail server is allready installed")
@ -979,52 +982,61 @@ class EEStackController(CementBaseController):
Log.info(self, "WP-CLI is allready installed") Log.info(self, "WP-CLI is allready installed")
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
Log.debug(self, "Setting packages varible for phpMyAdmin ") Log.debug(self, "Setting packages varible for phpMyAdmin ")
packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" packages = packages + [["https://github.com/phpmyadmin/"
"/archive/STABLE.tar.gz", "phpmyadmin/archive/STABLE.tar.gz",
"/tmp/pma.tar.gz", "phpMyAdmin"]] "/tmp/pma.tar.gz", "phpMyAdmin"]]
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Setting packages variable for Adminer ") Log.debug(self, "Setting packages variable for Adminer ")
packages = packages + [["http://downloads.sourceforge.net/adminer" packages = packages + [["http://downloads.sourceforge.net/"
"/adminer-4.1.0.php", "/var/www/22222/" "adminer/adminer-4.1.0.php",
"htdocs/db/adminer/index.php", "Adminer"]] "/var/www/22222/"
"htdocs/db/adminer/index.php",
"Adminer"]]
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Setting packages variable for utils") Log.debug(self, "Setting packages variable for utils")
packages = packages + [["http://phpmemcacheadmin.googlecode.com/" packages = packages + [["http://phpmemcacheadmin.googlecode"
"files/phpMemcachedAdmin-1.2.2" ".com/files/phpMemcachedAdmin-1.2.2"
"-r262.tar.gz", '/tmp/memcache.tar.gz', "-r262.tar.gz", '/tmp/memcache.tar.gz',
'phpMemcachedAdmin'], 'phpMemcachedAdmin'],
["https://raw.githubusercontent.com/rtCamp/" ["https://raw.githubusercontent.com"
"eeadmin/master/cache/nginx/clean.php", "/rtCamp/eeadmin/master/cache/nginx/"
"clean.php",
"/var/www/22222/htdocs/cache/" "/var/www/22222/htdocs/cache/"
"nginx/clean.php", "clean.php"], "nginx/clean.php", "clean.php"],
["https://raw.github.com/rlerdorf/opcache-" ["https://raw.github.com/rlerdorf/"
"status/master/opcache.php", "opcache-status/master/opcache.php",
"/var/www/22222/htdocs/cache/" "/var/www/22222/htdocs/cache/"
"opcache/opcache.php", "opcache.php"], "opcache/opcache.php", "opcache.php"],
["https://raw.github.com/amnuts/opcache-gui" ["https://raw.github.com/amnuts/"
"/master/index.php", "opcache-gui/master/index.php",
"/var/www/22222/htdocs/" "/var/www/22222/htdocs/"
"cache/opcache/opgui.php", "index.php"], "cache/opcache/opgui.php",
["https://gist.github.com/ck-on/4959032/raw" "index.php"],
"/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb" ["https://gist.github.com/ck-on/4959032"
"/ocp.php", "/raw/0b871b345fd6cfcd6d2be030c1f33d1"
"ad6a475cb/ocp.php",
"/var/www/22222/htdocs/cache/" "/var/www/22222/htdocs/cache/"
"opcache/ocp.php", "ocp.php"], "opcache/ocp.php", "ocp.php"],
["https://github.com/jokkedk/webgrind/" ["https://github.com/jokkedk/webgrind/"
"archive/master.tar.gz", "archive/master.tar.gz",
'/tmp/webgrind.tar.gz', 'Webgrind'], '/tmp/webgrind.tar.gz', 'Webgrind'],
["http://bazaar.launchpad.net/~percona-too" ["http://bazaar.launchpad.net/~"
"lkit-dev/percona-toolkit/2.1/download/he" "percona-toolkit-dev/percona-toolkit/"
"ad:/ptquerydigest-20110624220137-or26tn4" "2.1/download/head:/ptquerydigest-"
"20110624220137-or26tn4"
"expb9ul2a-16/pt-query-digest", "expb9ul2a-16/pt-query-digest",
"/usr/bin/pt-query-advisor", "/usr/bin/pt-query-advisor",
"pt-query-digest"], "pt-query-digest"],
["https://github.com/box/Anemometer/archive" ["https://github.com/box/Anemometer/"
"/master.tar.gz", "archive/master.tar.gz",
'/tmp/anemometer.tar.gz', 'Anemometer'] '/tmp/anemometer.tar.gz', 'Anemometer']
] ]
except Exception as e:
pass
if len(apt_packages) or len(packages):
Log.debug(self, "Calling pre_pref ") Log.debug(self, "Calling pre_pref ")
self.pre_pref(apt_packages) self.pre_pref(apt_packages)
if len(apt_packages): if len(apt_packages):

Loading…
Cancel
Save