diff --git a/CHANGELOG.md b/CHANGELOG.md index e67e8bd..9a87c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Incorrect PHP-FPM log path is `wo log` - force-ssl.conf not removed after removing a site - `wo clean --opcache` not working with invalid SSL certificate +- `wo stack install --cheat` wasn't working properly previously ### v3.9.9.4 - 2019-10-18 diff --git a/install b/install index a0222bf..2dd3a85 100755 --- a/install +++ b/install @@ -606,16 +606,6 @@ wo_uninstall() { rm -rf /usr/local/lib/python3.*/dist-packages/{pystache-*,cement-2.*,wo-*,wordops-*} /usr/local/bin/wo /etc/bash_completion.d/wo_auto.rc /var/lib/wo /etc/wo /usr/lib/wo/templates } -wo_cheat_install() { - curl -sL https://cht.sh/:cht.sh >/usr/local/bin/cht.sh - chmod +x /usr/local/bin/cht.sh - [ ! -h /usr/local/bin/cheat ] && { - rm -f /usr/local/bin/cheat - ln -s /usr/local/bin/cht.sh /usr/local/bin/cheat - } - curl -sL https://cheat.sh/:bash_completion >/etc/bash_completion.d/cht.sh -} - wo_clean_repo() { # remove old EasyEngine Nginx repository if [ -f /etc/apt/sources.list.d/ee-repo.list ]; then @@ -721,8 +711,7 @@ else _run wo_upgrade_nginx "Upgrading Nginx" _run wo_clean_ee "Cleaning previous EasyEngine install" fi - _run wo_install_acme_sh - _run wo_cheat_install "Running post-install steps" + _run wo_install_acme_sh "Running post-install steps" _run wo_domain_suffix _run wo_update_wp_cli _run wo_update_latest @@ -738,10 +727,10 @@ else elif [ "$wo_upgrade" = "1" ]; then wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!" echo - wo_lib_echo "To upgrade WordOps stacks use the command:" - wo_lib_echo_info "wo stack upgrade --all" + wo_lib_echo "To upgrade WordOps web stacks use the command:" + wo_lib_echo_info "wo stack upgrade" echo - wo_lib_echo "To update all other server packages use the command:" + wo_lib_echo "To update all other packages use the command:" wo_lib_echo_info "wo maintenance" else wo_lib_echo "WordOps (wo) installed successfully" diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index de3c606..f152104 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -85,6 +85,8 @@ class WOStackController(CementBaseController): (['--ngxblocker'], dict(help='Install Nginx Ultimate Bad Bot Blocker', action='store_true')), + (['--cheat'], + dict(help='Install cheat.sh', action='store_true')), (['--force'], dict(help='Force install/remove/purge without prompt', action='store_true')), @@ -116,6 +118,7 @@ class WOStackController(CementBaseController): (not pargs.adminer) and (not pargs.utils) and (not pargs.redis) and (not pargs.proftpd) and (not pargs.extplorer) and (not pargs.clamav) and + (not pargs.cheat) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php73)): @@ -147,6 +150,7 @@ class WOStackController(CementBaseController): pargs.dashboard = True pargs.phpredisadmin = True pargs.extplorer = True + pargs.cheat = True if pargs.security: pargs.fail2ban = True @@ -426,6 +430,7 @@ class WOStackController(CementBaseController): Log.debug(self, "eXtplorer is already installed") Log.info(self, "eXtplorer is already installed") + # ultimate ngx_blocker if pargs.ngxblocker: if not os.path.isdir('/etc/nginx/bots.d'): Log.debug(self, "Setting packages variable for ngxblocker") @@ -439,6 +444,21 @@ class WOStackController(CementBaseController): Log.debug(self, "ngxblocker is already installed") Log.info(self, "ngxblocker is already installed") + # cheat.sh + if pargs.cheat: + if ((not os.path.exists('/usr/local/bin/cht.sh')) and + (not os.path.exists('/usr/bin/cht.sh'))): + Log.debug(self, 'Setting packages variable for cheat.sh') + packages = packages + [[ + "https://raw.githubusercontent.com/chubin/cheat.sh" + "/master/share/cht.sh.txt", + "/usr/local/bin/cht.sh", + "cheat.sh"], + ["https://raw.githubusercontent.com/chubin/cheat.sh" + "/master/share/bash_completion.txt", + "/etc/bash_completion.d/cht.sh", + "cheat.sh bash_completion"]] + # UTILS if pargs.utils: Log.debug(self, "Setting packages variable for utils") @@ -536,6 +556,7 @@ class WOStackController(CementBaseController): (not pargs.adminer) and (not pargs.utils) and (not pargs.redis) and (not pargs.proftpd) and (not pargs.extplorer) and (not pargs.clamav) and + (not pargs.cheat) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php73)): @@ -565,6 +586,7 @@ class WOStackController(CementBaseController): pargs.utils = True pargs.netdata = True pargs.mysqltuner = True + pargs.cheat = True if pargs.security: pargs.fail2ban = True @@ -674,6 +696,14 @@ class WOStackController(CementBaseController): Log.debug(self, "Removing packages for MySQLTuner ") packages = packages + ['/usr/bin/mysqltuner'] + # cheat.sh + if pargs.cheat: + if os.path.isfile('/usr/local/bin/cht.sh'): + Log.debug(self, "Removing packages for cheat.sh ") + packages = packages + [ + '/usr/local/bin/cht.sh', '/usr/local/bin/cheat', + '/etc/bash_completion.d/cht.sh'] + # PHPREDISADMIN if pargs.phpredisadmin: Log.debug(self, "Removing package variable of phpRedisAdmin ") @@ -794,6 +824,7 @@ class WOStackController(CementBaseController): (not pargs.adminer) and (not pargs.utils) and (not pargs.redis) and (not pargs.proftpd) and (not pargs.extplorer) and (not pargs.clamav) and + (not pargs.cheat) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php73)): @@ -823,6 +854,7 @@ class WOStackController(CementBaseController): pargs.composer = True pargs.netdata = True pargs.mysqltuner = True + pargs.cheat = True if pargs.security: pargs.fail2ban = True @@ -939,6 +971,14 @@ class WOStackController(CementBaseController): Log.debug(self, "Removing packages for MySQLTuner ") packages = packages + ['/usr/bin/mysqltuner'] + # cheat.sh + if pargs.cheat: + if os.path.isfile('/usr/local/bin/cht.sh'): + Log.debug(self, "Removing packages for cheat.sh ") + packages = packages + [ + '/usr/local/bin/cht.sh', '/usr/local/bin/cheat', + '/etc/bash_completion.d/cht.sh'] + # PHPREDISADMIN if pargs.phpredisadmin: Log.debug(self, "Removing package variable of phpRedisAdmin ") diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 1b85165..d55f1d2 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -1192,6 +1192,21 @@ def post_pref(self, apt_packages, packages, upgrade=False): Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner") WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775) + # cheat.sh + if any('/usr/local/bin/cht.sh' == x[1] + for x in packages): + Log.debug(self, "CHMOD cht.sh in /usr/local/bin/cht.sh") + WOFileUtils.chmod(self, "/usr/local/bin/cht.sh", 0o775) + if WOFileUtils.grepcheck(self, '/etc/bash_completion.d/cht.sh', + 'cht_complete cht.sh'): + WOFileUtils.searchreplace( + self, '/etc/bash_completion.d/cht.sh', + '_cht_complete cht.sh', + '_cht_complete cheat') + if not os.path.islink('/usr/local/bin/cheat'): + WOFileUtils.create_symlink( + self, ['/usr/local/bin/cht.sh', '/usr/local/bin/cheat']) + # netdata install if any('/var/lib/wo/tmp/kickstart.sh' == x[1] for x in packages): @@ -1488,8 +1503,8 @@ def pre_stack(self): WOTemplate.deploy( self, '/etc/update-motd.d/98-wo-update', 'wo-update.mustache', data) - WOFileUtils.chmod( - self, "/etc/update-motd.d/98-wo-update", 0o755) - # restart motd-news service if available - if os.path.isfile('/lib/systemd/system/motd-news.service'): - WOService.restart_service(self, 'motd-news') + WOFileUtils.chmod( + self, "/etc/update-motd.d/98-wo-update", 0o755) + # restart motd-news service if available + if os.path.isfile('/lib/systemd/system/motd-news.service'): + WOService.restart_service(self, 'motd-news') diff --git a/wo/utils/test.py b/wo/utils/test.py index 6c46790..d737fdd 100644 --- a/wo/utils/test.py +++ b/wo/utils/test.py @@ -1,5 +1,5 @@ """Testing utilities for WordOps""" -from cement.utils.tests import CementTestCase +from cement.utils.test import CementTestCase from wo.cli.main import WOTestApp