Browse Source

Merge branch 'feature/v3.4.1' into develop

develop
Prabuddha Chakraborty 9 years ago
parent
commit
dc36d5c79a
  1. 28
      .travis.yml
  2. 8
      CHANGELOG.txt
  3. 57
      ee/cli/plugins/site.py
  4. 50
      ee/cli/plugins/site_functions.py
  5. 47
      ee/cli/plugins/stack.py
  6. 22
      ee/cli/plugins/stack_upgrade.py
  7. 34
      ee/core/aptget.py
  8. 4
      ee/core/cron.py
  9. 4
      ee/core/sslutils.py
  10. 4
      ee/core/variables.py
  11. 11
      install
  12. 2
      setup.py

28
.travis.yml

@ -37,47 +37,33 @@ script:
- sudo ee site create mysql.com --mysql - sudo ee site create mysql.com --mysql
- sudo ee site create site1.com --wp - sudo ee site create site1.com --wp
- sudo ee site create site2.com --wpsc
- sudo ee site create site2.net --wp --wpsc - sudo ee site create site2.net --wp --wpsc
- sudo ee site create site2.org --wpsc --wp
- sudo ee site create site3.com --w3tc
- sudo ee site create site3.net --wp --w3tc - sudo ee site create site3.net --wp --w3tc
- sudo ee site create site3.org --w3tc --wp
- sudo ee site create site4.com --wpfc - sudo ee site create site4.com --wpfc
- sudo ee site create site4.net --wp --wpfc - sudo ee site create site4.net --wp --wpfc
- sudo ee site create site4.org --wpfc --wp - sudo ee site create site4.org --wpfc --wp
- sudo ee site create site5.com --wpsubdir - sudo ee site create site5.com --wpsubdir
- sudo ee site create site5.net --wpsubdir
- sudo ee site create site6.com --wpsubdir --wpsc - sudo ee site create site6.com --wpsubdir --wpsc
- sudo ee site create site6.net --wpsc --wpsubdir
- sudo ee site create site7.com --wpsubdir --w3tc - sudo ee site create site7.com --wpsubdir --w3tc
- sudo ee site create site7.net --w3tc --wpsubdir
- sudo ee site create site8.com --wpsubdir --wpfc - sudo ee site create site8.com --wpsubdir --wpfc
- sudo ee site create site8.net --wpfc --wpsubdir - sudo ee site create site8.net --wpfc --wpsubdir
- sudo ee site create site9.com --wpsubdomain - sudo ee site create site9.com --wpsubdomain
- sudo ee site create site10.org --wpsubdomain --wpsc - sudo ee site create site10.org --wpsubdomain --wpsc
- sudo ee site create site10.in --wpsc --wpsubdomain
- sudo ee site create site11.org --wpsubdomain --w3tc - sudo ee site create site11.org --wpsubdomain --w3tc
- sudo ee site create site11.in --w3tc --wpsubdomain
- sudo ee site create site12.org --wpsubdomain --wpfc - sudo ee site create site12.org --wpsubdomain --wpfc
- sudo ee site create site12.in --wpfc --wpsubdomain - sudo ee site create site12.in --wpfc --wpsubdomain
- sudo ee site create site12.net --wpfc --wpsubdomain
- yes | sudo ee site create site.hhvm.pagespeed2.com --wpsc --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed2.com --wpsc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed3.com --w3tc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed4.com --wpfc --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed4.com --wpfc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed5.com --wpsubdir --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed5.com --wpsubdir --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed6.com --wpsubdir --wpsc --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed6.com --wpsubdir --wpsc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed7.com --wpsubdir --w3tc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed8.com --wpsubdir --wpfc --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed8.com --wpsubdir --wpfc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed9.com --wpsubdomain --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed9.com --wpsubdomain --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed10.org --wpsubdomain --wpsc --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed10.org --wpsubdomain --wpsc --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed11.in --w3tc --wpsubdomain --hhvm --pagespeed
- yes | sudo ee site create site.hhvm.pagespeed12.in --wpfc --wpsubdomain --hhvm --pagespeed - yes | sudo ee site create site.hhvm.pagespeed12.in --wpfc --wpsubdomain --hhvm --pagespeed
- sudo ee site create site.localtest.me --php --mysql --html
- sudo ee site create site1.localtest.me --php --mysql - sudo ee site create site1.localtest.me --php --mysql
- sudo ee site create site2.localtest.me --mysql --html - sudo ee site create site2.localtest.me --mysql --html
- sudo ee site create site3.localtest.me --php --html - sudo ee site create site3.localtest.me --php --html
@ -106,11 +92,9 @@ script:
- yes | sudo ee site update site1.com --wpredis - yes | sudo ee site update site1.com --wpredis
- sudo ee site update site5.com --wpsubdir --wpfc - sudo ee site update site5.com --wpsubdir --wpfc
- sudo ee site update site5.com --wpsubdir --w3tc
- sudo ee site update site5.com --wpsubdir --wpsc - sudo ee site update site5.com --wpsubdir --wpsc
- sudo ee site update site9.com --wpsubdomain --wpfc - sudo ee site update site9.com --wpsubdomain --wpfc
- sudo ee site update site9.com --wpsubdomain --w3tc
- sudo ee site update site9.com --wpsubdomain --wpsc - sudo ee site update site9.com --wpsubdomain --wpsc
- yes | sudo ee site update site.hhvm.pagespeed12.in --pagespeed=off --hhvm=off - yes | sudo ee site update site.hhvm.pagespeed12.in --pagespeed=off --hhvm=off
- yes | sudo ee site update site9.com --hhvm --pagespeed - yes | sudo ee site update site9.com --hhvm --pagespeed
@ -123,11 +107,15 @@ script:
- sudo ee site delete www.subsite.site-1.com --all --no-prompt - sudo ee site delete www.subsite.site-1.com --all --no-prompt
- sudo ee site delete site12.in --all --no-prompt - sudo ee site delete site12.in --all --no-prompt
- sudo ee site delete site12.net --no-prompt
- sudo ee site delete site12.org --no-prompt
- sudo ee site delete site9.com --no-prompt
- sudo ee stack install --mail - echo "yes" | sudo ee stack install --nginxmainline
- nginx -v
- sudo ee site create site-nm.localtest.me --php --mysql --html
- sudo ee site update site-nm.localtest.me --wp
- yes | sudo ee site update site-nm.localtest.me --hhvm --pagespeed --wpredis
- sudo ee site delete site-nm.localtest.me --no-prompt
- travis_wait sudo ee stack install --mail
- sudo ls /var/www/ - sudo ls /var/www/
- sudo wp --allow-root --info - sudo wp --allow-root --info
- sudo bash -c 'cat /var/log/ee/ee.log' - sudo bash -c 'cat /var/log/ee/ee.log'

8
CHANGELOG.txt

@ -1,4 +1,10 @@
v3.4.0 - Jan 6, 2015 v3.4.1 - Jan 20, 2016
- Fixed and update ee stack install --nginx/--nginxmainline
- Fixed --letsencrypt minor issues
- Fixed #665 #659
- Fixed other minor bug
v3.4.0 - Jan 6, 2016
- Added Let's Encrypt support - Added Let's Encrypt support
- ee site create example.com [--wp/..] --letsencrypt - ee site create example.com [--wp/..] --letsencrypt
- ee site update example.com --letsencrypt=on/off/renew - ee site update example.com --letsencrypt=on/off/renew

57
ee/cli/plugins/site.py

@ -753,8 +753,8 @@ class EESiteCreateController(CementBaseController):
setupLetsEncrypt(self, ee_domain) setupLetsEncrypt(self, ee_domain)
httpsRedirect(self,ee_domain) httpsRedirect(self,ee_domain)
Log.info(self,"Creating Cron Job for cert auto-renewal") Log.info(self,"Creating Cron Job for cert auto-renewal")
EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null'.format(ee_domain),'Renew ' EECron.setcron_weekly(self,'ee site update --le=renew --all 2> /dev/null'.format(ee_domain),'Renew all'
'letsencrypt SSL cert. Set by EasyEngine') ' letsencrypt SSL cert. Set by EasyEngine')
if not EEService.reload_service(self, 'nginx'): if not EEService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "
@ -828,8 +828,6 @@ class EESiteUpdateController(CementBaseController):
dict(help="configure letsencrypt ssl for the site", dict(help="configure letsencrypt ssl for the site",
action='store' or 'store_const', action='store' or 'store_const',
choices=('on', 'off', 'renew'), const='on', nargs='?')), choices=('on', 'off', 'renew'), const='on', nargs='?')),
(['--min_expiry_limit'],
dict(help="pass minimum expiry days to renew let's encrypt cert")),
(['--proxy'], (['--proxy'],
dict(help="update to proxy site", nargs='+')), dict(help="update to proxy site", nargs='+')),
(['--experimental'], (['--experimental'],
@ -1090,9 +1088,15 @@ class EESiteUpdateController(CementBaseController):
pargs.pagespeed = False pargs.pagespeed = False
#--letsencrypt=renew code goes here #--letsencrypt=renew code goes here
if pargs.letsencrypt == "renew" and not pargs.min_expiry_limit: if pargs.letsencrypt == "renew" and not pargs.all:
expiry_days = SSL.getExpirationDays(self,ee_domain)
min_expiry_days = 30
if check_ssl: if check_ssl:
if (expiry_days <= min_expiry_days):
renewLetsEncrypt(self,ee_domain) renewLetsEncrypt(self,ee_domain)
else:
Log.error(self,"More than 60 days left for certificate Expiry. Not renewing now.")
else: else:
Log.error(self,"Cannot RENEW ! SSL is not configured for given site .") Log.error(self,"Cannot RENEW ! SSL is not configured for given site .")
@ -1103,33 +1107,30 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "Expiration DATE: " + str(SSL.getExpirationDate(self,ee_domain))) Log.info(self, "Expiration DATE: " + str(SSL.getExpirationDate(self,ee_domain)))
else: else:
Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ") Log.warn(self, "Your cert already EXPIRED !. PLEASE renew soon . ")
if pargs.min_expiry_limit:
if not int(pargs.min_expiry_limit)>0 or not int(pargs.min_expiry_limit)< 90:
Log.error(self,'INVALID --min_expiry_limit argument provided. Please use range 1-89 .')
if not pargs.letsencrypt == "renew": if pargs.all and pargs.letsencrypt == "renew":
Log.error(self,'--min_expiry_limit parameter cannot be used as a standalone. Provide --le=renew')
if not check_ssl: if check_ssl:
Log.error(self,"Cannot RENEW ! SSL is not configured for given site .") expiry_days = SSL.getExpirationDays(self,ee_domain,True)
if expiry_days < 0:
expiry_days = SSL.getExpirationDays(self,ee_domain) return 0
min_expiry_days = int(pargs.min_expiry_limit) min_expiry_days = 30
if (expiry_days <= min_expiry_days): if (expiry_days <= min_expiry_days):
renewLetsEncrypt(self,ee_domain) renewLetsEncrypt(self,ee_domain)
Log.info(self, "SUCCESS: Certificate was successfully renewed For" Log.info(self, "SUCCESS: Certificate was successfully renewed For"
" https://{0}".format(ee_domain)) " https://{0}".format(ee_domain))
else: else:
Log.info(self, "Not renewing SSL .") Log.info(self,"More than 60 days left for certificate Expiry. Not renewing now.\n")
if (SSL.getExpirationDays(self,ee_domain)>0): if (SSL.getExpirationDays(self,ee_domain)>0):
Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.") Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.")
Log.info(self, "Expiration DATE: " + str(SSL.getExpirationDate(self,ee_domain))) Log.info(self, "Expiration DATE: \n\n" + str(SSL.getExpirationDate(self,ee_domain)))
return 0
#else:
# Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ")
else: else:
Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ") Log.info(self,"SSL not configured for site http://{0}".format(ee_domain))
return 0 return 0
if pargs.letsencrypt: if pargs.letsencrypt:
@ -1300,7 +1301,7 @@ class EESiteUpdateController(CementBaseController):
if 'proxy' in data.keys() and data['proxy']: if 'proxy' in data.keys() and data['proxy']:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache, updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
return 0 return 0
@ -1323,7 +1324,7 @@ class EESiteUpdateController(CementBaseController):
httpsRedirect(self,ee_domain) httpsRedirect(self,ee_domain)
Log.info(self,"Creating Cron Job for cert auto-renewal") Log.info(self,"Creating Cron Job for cert auto-renewal")
EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null'.format(ee_domain),'Renew' EECron.setcron_weekly(self,'ee site update --le=renew --all 2> /dev/null'.format(ee_domain),'Renew all'
' letsencrypt SSL cert. Set by EasyEngine') ' letsencrypt SSL cert. Set by EasyEngine')
if not EEService.reload_service(self, 'nginx'): if not EEService.reload_service(self, 'nginx'):
@ -1350,8 +1351,8 @@ class EESiteUpdateController(CementBaseController):
if not EEService.reload_service(self, 'nginx'): if not EEService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command") "check issues with `nginx -t` command")
Log.info(self,"Removing Cron Job set for cert auto-renewal") #Log.info(self,"Removing Cron Job set for cert auto-renewal")
EECron.remove_cron(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null'.format(ee_domain)) #EECron.remove_cron(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null'.format(ee_domain))
Log.info(self, "Successfully Disabled SSl for Site " Log.info(self, "Successfully Disabled SSl for Site "
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
@ -1371,7 +1372,7 @@ class EESiteUpdateController(CementBaseController):
"check issues with `nginx -t` command") "check issues with `nginx -t` command")
updateSiteInfo(self, ee_domain, stype=stype, cache=cache, updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
@ -1589,10 +1590,10 @@ class EESiteUpdateController(CementBaseController):
db_user=data['ee_db_user'], db_user=data['ee_db_user'],
db_password=data['ee_db_pass'], db_password=data['ee_db_pass'],
db_host=data['ee_db_host'], hhvm=hhvm, db_host=data['ee_db_host'], hhvm=hhvm,
pagespeed=pagespeed) pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
else: else:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache, updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
return 0 return 0

50
ee/cli/plugins/site_functions.py

@ -1186,7 +1186,8 @@ def operateOnPagespeed(self, data):
def cloneLetsEncrypt(self): def cloneLetsEncrypt(self):
letsencrypt_repo = "https://github.com/letsencrypt/letsencrypt" letsencrypt_repo = "https://github.com/letsencrypt/letsencrypt"
if not os.path.isdir("/opt"):
EEFileUtils.mkdir(self,"/opt")
try: try:
Log.info(self, "Downloading {0:20}".format("LetsEncrypt"), end=' ') Log.info(self, "Downloading {0:20}".format("LetsEncrypt"), end=' ')
EEFileUtils.chdir(self, '/opt/') EEFileUtils.chdir(self, '/opt/')
@ -1213,6 +1214,12 @@ def setupLetsEncrypt(self, ee_domain_name):
EEFileUtils.chdir(self, '/opt/letsencrypt') EEFileUtils.chdir(self, '/opt/letsencrypt')
EEShellExec.cmd_exec(self, "git pull") EEShellExec.cmd_exec(self, "git pull")
if os.path.isfile("/etc/letsencrypt/renewal/{0}.conf".format(ee_domain_name)):
Log.debug(self, "LetsEncrypt SSL Certificate found for the domain {0}"
.format(ee_domain_name))
ssl= archivedCertificateHandle(self,ee_domain_name,ee_wp_email)
else:
Log.warn(self,"Please Wait while we fetch SSL Certificate for your site.\nIt may take time depending upon network.")
ssl = EEShellExec.cmd_exec(self, "./letsencrypt-auto certonly --webroot -w /var/www/{0}/htdocs/ -d {0} -d www.{0} " ssl = EEShellExec.cmd_exec(self, "./letsencrypt-auto certonly --webroot -w /var/www/{0}/htdocs/ -d {0} -d www.{0} "
.format(ee_domain_name) .format(ee_domain_name)
+ "--email {0} --text --agree-tos".format(ee_wp_email)) + "--email {0} --text --agree-tos".format(ee_wp_email))
@ -1331,7 +1338,48 @@ def httpsRedirect(self,ee_domain_name,redirect=True):
Log.info(self, "Disabled HTTPS Force Redirection for Site " Log.info(self, "Disabled HTTPS Force Redirection for Site "
" http://{0}".format(ee_domain_name)) " http://{0}".format(ee_domain_name))
def archivedCertificateHandle(self,domain,ee_wp_email):
Log.warn(self,"You already have an existing certificate for the domain requested.\n"
"(ref: /etc/letsencrypt/renewal/{0}.conf)".format(domain) +
"\nPlease select an option from below?"
"\n\t1: Reinstall existing certificate"
"\n\t2: Keep the existing certificate for now"
"\n\t3: Renew & replace the certificate (limit ~5 per 7 days)"
"")
check_prompt = input("\nType the appropriate number [1-3] or any other key to cancel: ")
if not os.path.isfile("/etc/letsencrypt/live/{0}/cert.pem".format(domain)):
Log.error(self,"/etc/letsencrypt/live/{0}/cert.pem file is missing.".format(domain))
if check_prompt == "1":
Log.info(self,"Please Wait while we reinstall SSL Certificate for your site.\nIt may take time depending upon network.")
ssl = EEShellExec.cmd_exec(self, "./letsencrypt-auto certonly --reinstall --webroot -w /var/www/{0}/htdocs/ -d {0} -d www.{0} "
.format(domain)
+ "--email {0} --text --agree-tos".format(ee_wp_email))
elif check_prompt == "2" :
Log.info(self,"Using Existing Certificate files")
if not (os.path.isfile("/etc/letsencrypt/live/{0}/fullchain.pem".format(domain)) or
os.path.isfile("/etc/letsencrypt/live/{0}/privkey.pem".format(domain))):
Log.error(self,"Certificate files not found. Skipping.\n"
"Please check if following file exist\n\t/etc/letsencrypt/live/{0}/fullchain.pem\n\t"
"/etc/letsencrypt/live/{0}/privkey.pem".format(domain))
ssl = True
elif check_prompt == "3":
Log.info(self,"Please Wait while we renew SSL Certificate for your site.\nIt may take time depending upon network.")
ssl = EEShellExec.cmd_exec(self, "./letsencrypt-auto --renew certonly --webroot -w /var/www/{0}/htdocs/ -d {0} -d www.{0} "
.format(domain)
+ "--email {0} --text --agree-tos".format(ee_wp_email))
else:
Log.error(self,"Operation cancelled by user.")
if os.path.isfile("{0}/conf/nginx/ssl.conf"
.format(domain)):
Log.info(self, "Existing ssl.conf . Backing it up ..")
EEFileUtils.mvfile(self, "/var/www/{0}/conf/nginx/ssl.conf"
.format(domain),
'/var/www/{0}/conf/nginx/ssl.conf.bak'
.format(domain))
return ssl

47
ee/cli/plugins/stack.py

@ -1693,11 +1693,34 @@ class EEStackController(CementBaseController):
self.post_pref(apt, packages) self.post_pref(apt, packages)
else: else:
Log.debug(self, "Nginx already installed") Log.debug(self, "Nginx already installed")
Log.info(self, "Nginx already installed") if EEAptGet.is_installed(self, 'nginx-mainline'):
Log.warn(self,'Nginx Mainline already found on your system.\nDo you want to remove Nginx mainline '
'and install Nginx Stable.,\nAny answer other than "yes" will be stop this '
'operation.')
ee_prompt = input("Type \"YES\" or \"yes\" to continue [n]: ")
if ee_prompt == 'YES' or ee_prompt == 'yes':
EEService.stop_service(self, 'nginx')
Log.debug(self, "Removing apt_packages variable of NGINX")
Log.info(self, "Removing packages, please wait...")
EEAptGet.remove(self, EEVariables.ee_nginx_dev)
EEAptGet.auto_remove(self)
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,"Initializing NGINX Mainline Packages... Please Wait")
if EEAptGet.download_only(self,EEVariables.ee_nginx,EEVariables.ee_nginx_repo,EEVariables.ee_nginx_key):
apt_packages = apt_packages + EEVariables.ee_nginx
else:
#revert the changes
EERepo.add(self, repo_url=EEVariables.ee_nginx_dev_repo)
Log.error(self,"Error installing NGINX Stable\nReverting back to NGINX Mainline ..",False)
apt_packages = apt_packages + EEVariables.ee_nginx_dev
else:
Log.info(self, "NGINX Stable already installed")
if self.app.pargs.nginxmainline: if self.app.pargs.nginxmainline:
if EEVariables.ee_nginx_dev_repo == None: if EEVariables.ee_nginx_dev_repo == None:
Log.error(self, "NGINX Mainline Version is not supported in wheezy") Log.error(self, "NGINX Mainline Version is not supported in your platform")
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
@ -1711,7 +1734,25 @@ class EEStackController(CementBaseController):
self.post_pref(apt, packages) self.post_pref(apt, packages)
else: else:
Log.debug(self, "Nginx already installed") Log.debug(self, "Nginx already installed")
Log.info(self, "Nginx already installed") if EEAptGet.is_installed(self, 'nginx-custom'):
Log.warn(self,'Nginx Stable already found on your system.\nDo you want to remove Nginx stable '
'and install Nginx Mainline.,\nAny answer other than "yes" will be stop this '
'operation.')
ee_prompt = input("Type \"YES\" or \"yes\" to continue [n]: ")
if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.info(self,"Initializing... Please Wait")
if EEAptGet.download_only(self,EEVariables.ee_nginx_dev,EEVariables.ee_nginx_dev_repo,EEVariables.ee_nginx_key):
EEService.stop_service(self, 'nginx')
Log.debug(self, "Removing apt_packages variable of Nginx")
Log.info(self, "Removing packages, please wait...")
EEAptGet.remove(self, EEVariables.ee_nginx)
EEAptGet.auto_remove(self)
Log.info(self, "Successfully removed packages")
apt_packages = apt_packages + EEVariables.ee_nginx_dev
else:
Log.error(self,"Skipped installing NGINX Mainline",False)
else:
Log.info(self, "NGINX Mainline 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")

22
ee/cli/plugins/stack_upgrade.py

@ -32,6 +32,8 @@ class EEStackUpgradeController(CementBaseController):
dict(help='Upgrade mail scanner stack', action='store_true')), dict(help='Upgrade mail scanner stack', action='store_true')),
(['--nginx'], (['--nginx'],
dict(help='Upgrade Nginx stack', action='store_true')), dict(help='Upgrade Nginx stack', action='store_true')),
(['--nginxmainline'],
dict(help='Upgrade Nginx Mainline stack', action='store_true')),
(['--php'], (['--php'],
dict(help='Upgrade PHP stack', action='store_true')), dict(help='Upgrade PHP stack', action='store_true')),
(['--mysql'], (['--mysql'],
@ -112,7 +114,7 @@ class EEStackUpgradeController(CementBaseController):
(not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.hhvm) and (not self.app.pargs.postfix) and (not self.app.pargs.hhvm) 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.wpcli) and (not self.app.pargs.redis)): and (not self.app.pargs.wpcli) and (not self.app.pargs.redis) and (not self.app.pargs.nginxmainline)):
self.app.pargs.web = True self.app.pargs.web = True
if self.app.pargs.all: if self.app.pargs.all:
@ -120,7 +122,12 @@ class EEStackUpgradeController(CementBaseController):
self.app.pargs.mail = True self.app.pargs.mail = True
if self.app.pargs.web: if self.app.pargs.web:
if EEAptGet.is_installed(self, 'nginx-custom'):
self.app.pargs.nginx = True self.app.pargs.nginx = True
elif EEAptGet.is_installed(self, 'nginx-mainline'):
self.app.pargs.nginxmainline = True
else:
Log.info(self, "Nginx is not already installed")
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
@ -139,11 +146,17 @@ class EEStackUpgradeController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.nginx: if self.app.pargs.nginx :
if EEAptGet.is_installed(self, 'nginx-custom'): if EEAptGet.is_installed(self, 'nginx-custom'):
apt_packages = apt_packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
else: else:
Log.info(self, "Nginx is not already installed") Log.info(self, "Nginx Stable is not already installed")
if self.app.pargs.nginxmainline:
if EEAptGet.is_installed(self, 'nginx-mainline'):
apt_packages = apt_packages + EEVariables.ee_nginx_dev
else:
Log.info(self, "Nginx Mainline is not already installed")
if self.app.pargs.php: if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'): if EEAptGet.is_installed(self, 'php5-fpm'):
@ -210,7 +223,8 @@ class EEStackUpgradeController(CementBaseController):
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)
# Post Actions after package updates # Post Actions after package updates
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))):
EEService.restart_service(self, 'nginx') EEService.restart_service(self, 'nginx')
if set(EEVariables.ee_php).issubset(set(apt_packages)): if set(EEVariables.ee_php).issubset(set(apt_packages)):
EEService.restart_service(self, 'php5-fpm') EEService.restart_service(self, 'php5-fpm')

34
ee/core/aptget.py

@ -195,3 +195,37 @@ class EEAptGet():
return True return True
# apt_cache.close() # apt_cache.close()
return False return False
def download_only(self,package_name,repo_url=None,repo_key=None):
"""
Similar to `apt-get install --download-only PACKAGE_NAME`
"""
packages = ' '.join(package_name)
try:
with open('/var/log/ee/ee.log', 'a') as f:
if repo_url is not None:
EERepo.add(self, repo_url=repo_url)
if repo_key is not None:
EERepo.add_key(self, repo_key)
proc = subprocess.Popen("apt-get update && DEBIAN_FRONTEND=noninteractive "
"apt-get install -o "
"Dpkg::Options::=\"--force-confdef\""
" -o "
"Dpkg::Options::=\"--force-confold\""
" -y --download-only {0}"
.format(packages), shell=True,
stdin=None, stdout=f, stderr=f,
executable="/bin/bash")
proc.wait()
if proc.returncode == 0:
return True
else:
Log.error(self,"Error in fetching dpkg package.\nReverting changes ..",False)
if repo_url is not None:
EERepo.remove(self, repo_url=repo_url)
return False
except Exception as e:
Log.error(self, "Error while downloading packages, "
"apt-get exited with error")

4
ee/core/cron.py

@ -6,13 +6,13 @@ Set CRON on LINUX system.
""" """
class EECron(): class EECron():
def setcron_daily(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12): def setcron_weekly(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12):
if not EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)): if not EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e" "2> /dev/null | {{ cat; echo -e"
" \\\"" " \\\""
"\\n0 12 * * * " "\\n0 0 * * 0 "
"{0}".format(cmd) + "{0}".format(cmd) +
" # {0}".format(comment)+ " # {0}".format(comment)+
"\\\"; } | crontab -\"") "\\\"; } | crontab -\"")

4
ee/core/sslutils.py

@ -5,12 +5,14 @@ from ee.core.logging import Log
class SSL: class SSL:
def getExpirationDays(self,domain): def getExpirationDays(self,domain,returnonerror=False):
# check if exist # check if exist
if not os.path.isfile('/etc/letsencrypt/live/{0}/cert.pem' if not os.path.isfile('/etc/letsencrypt/live/{0}/cert.pem'
.format(domain)): .format(domain)):
Log.error(self,'File Not Found : /etc/letsencrypt/live/{0}/cert.pem' Log.error(self,'File Not Found : /etc/letsencrypt/live/{0}/cert.pem'
.format(domain),False) .format(domain),False)
if returnonerror:
return -1
Log.error(self, "Check logs for reason " Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")

4
ee/core/variables.py

@ -12,11 +12,11 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.4.0" ee_version = "3.4.1"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.21.1" ee_wp_cli = "0.22.0"
ee_adminer = "4.2.1" ee_adminer = "4.2.1"
ee_roundcube = "1.1.4" ee_roundcube = "1.1.4"
ee_vimbadmin = "3.0.12" ee_vimbadmin = "3.0.12"

11
install

@ -48,7 +48,7 @@ fi
# Define variables for later use # Define variables for later use
ee_branch=$1 ee_branch=$1
readonly ee_version_old="2.2.3" readonly ee_version_old="2.2.3"
readonly ee_version_new="3.4.0" readonly ee_version_new="3.4.1"
readonly ee_log_dir=/var/log/ee/ readonly ee_log_dir=/var/log/ee/
readonly ee_install_log=/var/log/ee/install.log readonly ee_install_log=/var/log/ee/install.log
readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}') readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}')
@ -525,6 +525,15 @@ function ee_update_latest()
sed -i 's/HIGH:!aNULL:!MD5:!kEDH;/ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;/' /etc/nginx/nginx.conf sed -i 's/HIGH:!aNULL:!MD5:!kEDH;/ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;/' /etc/nginx/nginx.conf
fi fi
#Fix for SSL cert --all
crontab -l | grep -q '\-\-min_expiry_limit'
if [[ $? -eq 0 ]]; then
crontab -l > /var/spool/cron/cron-backup.txt #backup cron before editing
crontab -l | sed '/--min_expiry_limit/d' | crontab -
/bin/bash -c "crontab -l 2> /dev/null | { cat; echo -e \"\n0 0 * * 0 ee site update --le=renew --all 2> /dev/null # Renew all letsencrypt SSL cert. Set by EasyEngine\"; } | crontab -"
fi
} }

2
setup.py

@ -58,7 +58,7 @@ if not os.path.isfile('/root/.gitconfig'):
shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
setup(name='ee', setup(name='ee',
version='3.4.0', version='3.4.1',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],

Loading…
Cancel
Save