@ -2,6 +2,7 @@
from cement . core . controller import CementBaseController , expose
from cement . core . controller import CementBaseController , expose
from cement . core import handler , hook
from cement . core import handler , hook
from ee . cli . plugins . site_functions import *
from ee . core . variables import EEVariables
from ee . core . variables import EEVariables
from ee . core . aptget import EEAptGet
from ee . core . aptget import EEAptGet
from ee . core . download import EEDownload
from ee . core . download import EEDownload
@ -30,6 +31,7 @@ from ee.cli.plugins.stack_services import EEStackStatusController
from ee . cli . plugins . stack_migrate import EEStackMigrateController
from ee . cli . plugins . stack_migrate import EEStackMigrateController
from ee . cli . plugins . stack_upgrade import EEStackUpgradeController
from ee . cli . plugins . stack_upgrade import EEStackUpgradeController
from ee . core . logging import Log
from ee . core . logging import Log
from ee . cli . plugins . sitedb import *
def ee_stack_hook ( app ) :
def ee_stack_hook ( app ) :
@ -56,6 +58,8 @@ class EEStackController(CementBaseController):
dict ( help = ' Install mail scanner stack ' , action = ' store_true ' ) ) ,
dict ( help = ' Install mail scanner stack ' , action = ' store_true ' ) ) ,
( [ ' --nginx ' ] ,
( [ ' --nginx ' ] ,
dict ( help = ' Install Nginx stack ' , action = ' store_true ' ) ) ,
dict ( help = ' Install Nginx stack ' , action = ' store_true ' ) ) ,
( [ ' --nginxmainline ' ] ,
dict ( help = ' Install Nginx mainline stack ' , action = ' store_true ' ) ) ,
( [ ' --php ' ] ,
( [ ' --php ' ] ,
dict ( help = ' Install PHP stack ' , action = ' store_true ' ) ) ,
dict ( help = ' Install PHP stack ' , action = ' store_true ' ) ) ,
( [ ' --mysql ' ] ,
( [ ' --mysql ' ] ,
@ -168,6 +172,12 @@ class EEStackController(CementBaseController):
Log . debug ( self , ' Adding ppa of Nginx ' )
Log . debug ( self , ' Adding ppa of Nginx ' )
EERepo . add_key ( self , EEVariables . ee_nginx_key )
EERepo . add_key ( self , EEVariables . ee_nginx_key )
if set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) :
Log . info ( self , " Adding repository for NGINX MAINLINE, please wait... " )
EERepo . add ( self , repo_url = EEVariables . ee_nginx_dev_repo )
Log . debug ( self , ' Adding ppa of Nginx-mainline ' )
EERepo . add_key ( self , EEVariables . ee_nginx_key )
if set ( EEVariables . ee_php ) . issubset ( set ( apt_packages ) ) :
if set ( EEVariables . ee_php ) . issubset ( set ( apt_packages ) ) :
Log . info ( self , " Adding repository for PHP, please wait... " )
Log . info ( self , " Adding repository for PHP, please wait... " )
# Add repository for php
# Add repository for php
@ -223,7 +233,8 @@ class EEStackController(CementBaseController):
msg = " Adding Postfix into Git " )
msg = " Adding Postfix into Git " )
EEService . reload_service ( self , ' postfix ' )
EEService . reload_service ( self , ' postfix ' )
if set ( EEVariables . ee_nginx ) . issubset ( set ( apt_packages ) ) :
if set ( EEVariables . ee_nginx ) . issubset ( set ( apt_packages ) ) or set ( EEVariables . ee_nginx_dev ) \
. issubset ( set ( apt_packages ) ) :
if set ( [ " nginx-plus " ] ) . issubset ( set ( apt_packages ) ) :
if set ( [ " nginx-plus " ] ) . issubset ( set ( apt_packages ) ) :
# Fix for white screen death with NGINX PLUS
# Fix for white screen death with NGINX PLUS
if not EEFileUtils . grep ( self , ' /etc/nginx/fastcgi_params ' ,
if not EEFileUtils . grep ( self , ' /etc/nginx/fastcgi_params ' ,
@ -233,6 +244,26 @@ class EEStackController(CementBaseController):
ee_nginx . write ( ' fastcgi_param \t SCRIPT_FILENAME '
ee_nginx . write ( ' fastcgi_param \t SCRIPT_FILENAME '
' \t $request_filename; \n ' )
' \t $request_filename; \n ' )
if os . path . isfile ( ' /etc/nginx/sites-available/22222 ' ) :
http2 = " http2 " if EEAptGet . is_installed ( self , ' nginx-mainline ' ) else " spdy "
if not EEShellExec . cmd_exec ( self , " grep -q \' {http2} \' /etc/nginx/sites-available/22222 " . format ( http2 = http2 ) ) :
Log . debug ( self , ' Setting http2/spdy in 22222 ' )
EEShellExec . cmd_exec ( self , " sed -i ' s/http2 \ |spdy/ {0} /g ' /etc/nginx/sites-available/22222 " . format ( http2 ) )
sites = getAllsites ( self )
if sites :
for site in sites :
site_name = site . sitename
siteinfo = getSiteInfo ( self , site_name )
ssl = ( " enabled " if siteinfo . is_ssl else " disabled " )
if ( ssl == " enabled " ) :
if os . path . isfile ( ' /var/www/ {0} /conf/nginx/ssl.conf ' . format ( site_name ) ) :
http2 = ( " http2 " if EEAptGet . is_installed ( self , ' nginx-mainline ' ) else " spdy " )
if not EEShellExec . cmd_exec ( self , " grep -q \' {http2} \' /var/www/ {site} /conf/nginx/ssl.conf " . format ( http2 = http2 , site = site_name ) ) :
Log . debug ( self , ' Modifying http2/spdy parameter in /var/www/ {0} /conf/nginx/ssl.conf ' . format ( site_name ) )
EEShellExec . cmd_exec ( self , " sed -i ' s/http2 \ |spdy/ {http2} /g ' /var/www/ {site} /conf/nginx/ssl.conf " . format ( http2 = http2 , site = site_name ) )
if not ( os . path . isfile ( ' /etc/nginx/common/wpfc.conf ' ) ) :
if not ( os . path . isfile ( ' /etc/nginx/common/wpfc.conf ' ) ) :
# Change EasyEngine Version in nginx.conf file
# Change EasyEngine Version in nginx.conf file
EEFileUtils . searchreplace ( self , " /etc/nginx/nginx.conf " ,
EEFileUtils . searchreplace ( self , " /etc/nginx/nginx.conf " ,
@ -273,7 +304,8 @@ class EEStackController(CementBaseController):
' /etc/nginx/common ' )
' /etc/nginx/common ' )
os . makedirs ( ' /etc/nginx/common ' )
os . makedirs ( ' /etc/nginx/common ' )
data = dict ( webroot = EEVariables . ee_webroot )
http2 = ( " http2 " if set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) else " spdy " )
data = dict ( webroot = EEVariables . ee_webroot , http2 = http2 )
Log . debug ( self , ' Writting the nginx configuration to '
Log . debug ( self , ' Writting the nginx configuration to '
' file /etc/nginx/common/acl.conf ' )
' file /etc/nginx/common/acl.conf ' )
ee_nginx = open ( ' /etc/nginx/common/acl.conf ' ,
ee_nginx = open ( ' /etc/nginx/common/acl.conf ' ,
@ -339,7 +371,7 @@ class EEStackController(CementBaseController):
ee_nginx . close ( )
ee_nginx . close ( )
# Nginx-Plus does not have nginx package structure like this
# Nginx-Plus does not have nginx package structure like this
# So cra eting directories
# So crea ting directories
if set ( [ " nginx-plus " ] ) . issubset ( set ( apt_packages ) ) :
if set ( [ " nginx-plus " ] ) . issubset ( set ( apt_packages ) ) :
Log . info ( self ,
Log . info ( self ,
" Installing EasyEngine Configurations for " " NGINX PLUS " )
" Installing EasyEngine Configurations for " " NGINX PLUS " )
@ -483,6 +515,8 @@ class EEStackController(CementBaseController):
else :
else :
self . msg = ( self . msg + [ " HTTP Auth User Name: easyengine " ]
self . msg = ( self . msg + [ " HTTP Auth User Name: easyengine " ]
+ [ " HTTP Auth Password : {0} " . format ( passwd ) ] )
+ [ " HTTP Auth Password : {0} " . format ( passwd ) ] )
else :
EEService . restart_service ( self , ' nginx ' )
if EEAptGet . is_installed ( self , ' redis-server ' ) :
if EEAptGet . is_installed ( self , ' redis-server ' ) :
if os . path . isfile ( " /etc/nginx/nginx.conf " ) and ( not
if os . path . isfile ( " /etc/nginx/nginx.conf " ) and ( not
@ -1576,7 +1610,7 @@ class EEStackController(CementBaseController):
and ( not self . app . pargs . pagespeed ) and
and ( not self . app . pargs . pagespeed ) and
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all )
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all )
and ( not self . app . pargs . redis ) and
and ( not self . app . pargs . redis ) and ( not self . app . pargs . nginxmainline ) and
( not self . app . pargs . phpredisadmin ) ) :
( not self . app . pargs . phpredisadmin ) ) :
self . app . pargs . web = True
self . app . pargs . web = True
self . app . pargs . admin = True
self . app . pargs . admin = True
@ -1634,7 +1668,7 @@ class EEStackController(CementBaseController):
Log . info ( self , " Mail server is already installed " )
Log . info ( self , " Mail server is already installed " )
if self . app . pargs . pagespeed :
if self . app . pargs . pagespeed :
if not EEAptGet . is_installed ( self , ' nginx-custom ' ) :
if not ( EEAptGet . is_installed ( self , ' nginx-custom ' ) or EEAptGet . is_installed ( self , ' nginx-mainline ' ) ) :
self . app . pargs . nginx = True
self . app . pargs . nginx = True
else :
else :
Log . info ( self , " Nginx already installed " )
Log . info ( self , " Nginx already installed " )
@ -1649,7 +1683,7 @@ class EEStackController(CementBaseController):
if self . app . pargs . nginx :
if self . app . pargs . nginx :
Log . debug ( self , " Setting apt_packages variable for Nginx " )
Log . debug ( self , " Setting apt_packages variable for Nginx " )
if not EEAptGet . is_installed ( self , ' nginx-custom ' ) :
if not ( EEAptGet . is_installed ( self , ' nginx-custom ' ) or EEAptGet . is_installed ( self , ' nginx-mainline ' ) ) :
if not EEAptGet . is_installed ( self , ' nginx-plus ' ) :
if not EEAptGet . is_installed ( self , ' nginx-plus ' ) :
apt_packages = apt_packages + EEVariables . ee_nginx
apt_packages = apt_packages + EEVariables . ee_nginx
else :
else :
@ -1660,6 +1694,25 @@ class EEStackController(CementBaseController):
else :
else :
Log . debug ( self , " Nginx already installed " )
Log . debug ( self , " Nginx already installed " )
Log . info ( self , " Nginx already installed " )
Log . info ( self , " Nginx already installed " )
if self . app . pargs . nginxmainline :
if EEVariables . ee_nginx_dev_repo == None :
Log . error ( self , " NGINX Mainline Version is not supported in wheezy " )
Log . debug ( self , " Setting apt_packages variable for Nginx " )
if not ( EEAptGet . is_installed ( self , ' nginx-custom ' ) or EEAptGet . is_installed ( self , ' nginx-mainline ' ) ) :
if not EEAptGet . is_installed ( self , ' nginx-plus ' ) :
apt_packages = apt_packages + EEVariables . ee_nginx_dev
else :
Log . info ( self , " NGINX PLUS Detected ... " )
apt = [ " nginx-plus " ] + EEVariables . ee_nginx
#apt_packages = apt_packages + EEVariables.ee_nginx
self . post_pref ( apt , packages )
else :
Log . debug ( self , " Nginx already installed " )
Log . info ( self , " Nginx already installed " )
if self . app . pargs . php :
if self . app . pargs . php :
Log . debug ( self , " Setting apt_packages variable for PHP " )
Log . debug ( self , " Setting apt_packages variable for PHP " )
if not EEAptGet . is_installed ( self , ' php5-fpm ' ) :
if not EEAptGet . is_installed ( self , ' php5-fpm ' ) :
@ -1856,7 +1909,7 @@ class EEStackController(CementBaseController):
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all ) and
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all ) and
( not self . app . pargs . pagespeed ) and ( not self . app . pargs . redis ) and
( not self . app . pargs . pagespeed ) and ( not self . app . pargs . redis ) and
( not self . app . pargs . phpredisadmin ) ) :
( not self . app . pargs . phpredisadmin ) and ( not self . app . pargs . nginxmainline ) ) :
self . app . pargs . web = True
self . app . pargs . web = True
self . app . pargs . admin = True
self . app . pargs . admin = True
@ -1897,8 +1950,17 @@ class EEStackController(CementBaseController):
packages = packages + [ ' /etc/nginx/conf.d/pagespeed.conf ' ]
packages = packages + [ ' /etc/nginx/conf.d/pagespeed.conf ' ]
if self . app . pargs . nginx :
if self . app . pargs . nginx :
if EEAptGet . is_installed ( self , ' nginx-custom ' ) :
Log . debug ( self , " Removing apt_packages variable of Nginx " )
Log . debug ( self , " Removing apt_packages variable of Nginx " )
apt_packages = apt_packages + EEVariables . ee_nginx
apt_packages = apt_packages + EEVariables . ee_nginx
else :
Log . error ( self , " Cannot Remove! Nginx Stable version not found. " )
if self . app . pargs . nginxmainline :
if EEAptGet . is_installed ( self , ' nginx-mainline ' ) :
Log . debug ( self , " Removing apt_packages variable of Nginx MAINLINE " )
apt_packages = apt_packages + EEVariables . ee_nginx_dev
else :
Log . error ( self , " Cannot Remove! Nginx Mainline version not found. " )
if self . app . pargs . php :
if self . app . pargs . php :
Log . debug ( self , " Removing apt_packages variable of PHP " )
Log . debug ( self , " Removing apt_packages variable of PHP " )
apt_packages = apt_packages + EEVariables . ee_php
apt_packages = apt_packages + EEVariables . ee_php
@ -1959,6 +2021,11 @@ class EEStackController(CementBaseController):
' operation : ' )
' operation : ' )
if ee_prompt == ' YES ' or ee_prompt == ' yes ' :
if ee_prompt == ' YES ' or ee_prompt == ' yes ' :
if ( set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) or
set ( [ " nginx-custom " ] ) . issubset ( set ( apt_packages ) ) ) :
EEService . stop_service ( self , ' nginx ' )
if len ( packages ) :
if len ( packages ) :
EEFileUtils . remove ( self , packages )
EEFileUtils . remove ( self , packages )
EEAptGet . auto_remove ( self )
EEAptGet . auto_remove ( self )
@ -1969,6 +2036,11 @@ class EEStackController(CementBaseController):
EEAptGet . remove ( self , apt_packages )
EEAptGet . remove ( self , apt_packages )
EEAptGet . auto_remove ( self )
EEAptGet . auto_remove ( self )
if set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) :
Log . info ( self , " Removing repository for NGINX MAINLINE, " )
EERepo . remove ( self , repo_url = EEVariables . ee_nginx_dev_repo )
Log . info ( self , " Successfully removed packages " )
Log . info ( self , " Successfully removed packages " )
@expose ( help = " Purge packages " )
@expose ( help = " Purge packages " )
@ -1986,7 +2058,7 @@ class EEStackController(CementBaseController):
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . adminer ) and ( not self . app . pargs . utils ) and
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all ) and
( not self . app . pargs . mailscanner ) and ( not self . app . pargs . all ) and
( not self . app . pargs . pagespeed ) and ( not self . app . pargs . redis ) and
( not self . app . pargs . pagespeed ) and ( not self . app . pargs . redis ) and
( not self . app . pargs . phpredisadmin ) ) :
( not self . app . pargs . phpredisadmin ) and ( not self . app . pargs . nginxmainline ) ) :
self . app . pargs . web = True
self . app . pargs . web = True
self . app . pargs . admin = True
self . app . pargs . admin = True
@ -2027,8 +2099,17 @@ class EEStackController(CementBaseController):
packages = packages + [ ' /etc/nginx/conf.d/pagespeed.conf ' ]
packages = packages + [ ' /etc/nginx/conf.d/pagespeed.conf ' ]
if self . app . pargs . nginx :
if self . app . pargs . nginx :
if EEAptGet . is_installed ( self , ' nginx-custom ' ) :
Log . debug ( self , " Purge apt_packages variable of Nginx " )
Log . debug ( self , " Purge apt_packages variable of Nginx " )
apt_packages = apt_packages + EEVariables . ee_nginx
apt_packages = apt_packages + EEVariables . ee_nginx
else :
Log . error ( self , " Cannot Purge! Nginx Stable version not found. " )
if self . app . pargs . nginxmainline :
if EEAptGet . is_installed ( self , ' nginx-mainline ' ) :
Log . debug ( self , " Purge apt_packages variable of Nginx Mainline " )
apt_packages = apt_packages + EEVariables . ee_nginx_dev
else :
Log . error ( self , " Cannot Purge! Nginx Mainline version not found. " )
if self . app . pargs . php :
if self . app . pargs . php :
Log . debug ( self , " Purge apt_packages variable PHP " )
Log . debug ( self , " Purge apt_packages variable PHP " )
apt_packages = apt_packages + EEVariables . ee_php
apt_packages = apt_packages + EEVariables . ee_php
@ -2088,6 +2169,11 @@ class EEStackController(CementBaseController):
' operation : ' )
' operation : ' )
if ee_prompt == ' YES ' or ee_prompt == ' yes ' :
if ee_prompt == ' YES ' or ee_prompt == ' yes ' :
if ( set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) or
set ( [ " nginx-custom " ] ) . issubset ( set ( apt_packages ) ) ) :
EEService . stop_service ( self , ' nginx ' )
if len ( apt_packages ) :
if len ( apt_packages ) :
Log . info ( self , " Purging packages, please wait... " )
Log . info ( self , " Purging packages, please wait... " )
EEAptGet . remove ( self , apt_packages , purge = True )
EEAptGet . remove ( self , apt_packages , purge = True )
@ -2097,6 +2183,11 @@ class EEStackController(CementBaseController):
EEFileUtils . remove ( self , packages )
EEFileUtils . remove ( self , packages )
EEAptGet . auto_remove ( self )
EEAptGet . auto_remove ( self )
if set ( [ " nginx-mainline " ] ) . issubset ( set ( apt_packages ) ) :
Log . info ( self , " Removing repository for NGINX MAINLINE, " )
EERepo . remove ( self , repo_url = EEVariables . ee_nginx_dev_repo )
Log . info ( self , " Successfully purged packages " )
Log . info ( self , " Successfully purged packages " )
def load ( app ) :
def load ( app ) :