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'
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)

288
ee/cli/plugins/stack.py

@ -904,145 +904,157 @@ class EEStackController(CementBaseController):
@expose()
def install(self, packages=[], apt_packages=[]):
self.msg = []
if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True
if self.app.pargs.admin:
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.adminer = True
self.app.pargs.phpmyadmin = True
self.app.pargs.utils = True
if self.app.pargs.mail:
self.app.pargs.nginx = True
self.app.pargs.php = 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")
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"],
["https://github.com/roundcube/"
"roundcubemail/releases/download/"
"1.0.4/roundcubemail-1.0.4.tar.gz",
"/tmp/roundcube.tar.gz",
"Roundcube"]]
if EEVariables.ee_ram > 1024:
apt_packages = apt_packages + EEVariables.ee_mailscanner
else:
Log.info(self, "Mail server is allready installed")
if self.app.pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx")
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"]]
try:
if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True
if self.app.pargs.admin:
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.adminer = True
self.app.pargs.phpmyadmin = True
self.app.pargs.utils = True
if self.app.pargs.mail:
self.app.pargs.nginx = True
self.app.pargs.php = 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")
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"],
["https://github.com/roundcube/"
"roundcubemail/releases/download/"
"1.0.4/roundcubemail-1.0.4.tar.gz",
"/tmp/roundcube.tar.gz",
"Roundcube"]]
if EEVariables.ee_ram > 1024:
apt_packages = (apt_packages +
EEVariables.ee_mailscanner)
else:
Log.info(self, "Mail server is allready installed")
if self.app.pargs.utils:
Log.debug(self, "Setting packages variable for utils")
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",
"/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"
"/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb"
"/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"
"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']
]
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")
if self.app.pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx")
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:
Log.debug(self, "Setting packages variable for utils")
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",
"/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()
def remove(self):

Loading…
Cancel
Save