Fix wo stack install --cheat

This commit is contained in:
VirtuBox
2019-10-28 20:07:38 +01:00
parent a4c7d615ab
commit 5b9a17c116
5 changed files with 66 additions and 21 deletions

View File

@@ -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` - Incorrect PHP-FPM log path is `wo log`
- force-ssl.conf not removed after removing a site - force-ssl.conf not removed after removing a site
- `wo clean --opcache` not working with invalid SSL certificate - `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 ### v3.9.9.4 - 2019-10-18

19
install
View File

@@ -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 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() { wo_clean_repo() {
# remove old EasyEngine Nginx repository # remove old EasyEngine Nginx repository
if [ -f /etc/apt/sources.list.d/ee-repo.list ]; then if [ -f /etc/apt/sources.list.d/ee-repo.list ]; then
@@ -721,8 +711,7 @@ else
_run wo_upgrade_nginx "Upgrading Nginx" _run wo_upgrade_nginx "Upgrading Nginx"
_run wo_clean_ee "Cleaning previous EasyEngine install" _run wo_clean_ee "Cleaning previous EasyEngine install"
fi fi
_run wo_install_acme_sh _run wo_install_acme_sh "Running post-install steps"
_run wo_cheat_install "Running post-install steps"
_run wo_domain_suffix _run wo_domain_suffix
_run wo_update_wp_cli _run wo_update_wp_cli
_run wo_update_latest _run wo_update_latest
@@ -738,10 +727,10 @@ else
elif [ "$wo_upgrade" = "1" ]; then elif [ "$wo_upgrade" = "1" ]; then
wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!" wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!"
echo echo
wo_lib_echo "To upgrade WordOps stacks use the command:" wo_lib_echo "To upgrade WordOps web stacks use the command:"
wo_lib_echo_info "wo stack upgrade --all" wo_lib_echo_info "wo stack upgrade"
echo 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" wo_lib_echo_info "wo maintenance"
else else
wo_lib_echo "WordOps (wo) installed successfully" wo_lib_echo "WordOps (wo) installed successfully"

View File

@@ -85,6 +85,8 @@ class WOStackController(CementBaseController):
(['--ngxblocker'], (['--ngxblocker'],
dict(help='Install Nginx Ultimate Bad Bot Blocker', dict(help='Install Nginx Ultimate Bad Bot Blocker',
action='store_true')), action='store_true')),
(['--cheat'],
dict(help='Install cheat.sh', action='store_true')),
(['--force'], (['--force'],
dict(help='Force install/remove/purge without prompt', dict(help='Force install/remove/purge without prompt',
action='store_true')), action='store_true')),
@@ -116,6 +118,7 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and (not pargs.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and (not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and (not pargs.extplorer) and (not pargs.clamav) and
(not pargs.cheat) and
(not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)): (not pargs.php73)):
@@ -147,6 +150,7 @@ class WOStackController(CementBaseController):
pargs.dashboard = True pargs.dashboard = True
pargs.phpredisadmin = True pargs.phpredisadmin = True
pargs.extplorer = True pargs.extplorer = True
pargs.cheat = True
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -426,6 +430,7 @@ class WOStackController(CementBaseController):
Log.debug(self, "eXtplorer is already installed") Log.debug(self, "eXtplorer is already installed")
Log.info(self, "eXtplorer is already installed") Log.info(self, "eXtplorer is already installed")
# ultimate ngx_blocker
if pargs.ngxblocker: if pargs.ngxblocker:
if not os.path.isdir('/etc/nginx/bots.d'): if not os.path.isdir('/etc/nginx/bots.d'):
Log.debug(self, "Setting packages variable for ngxblocker") Log.debug(self, "Setting packages variable for ngxblocker")
@@ -439,6 +444,21 @@ class WOStackController(CementBaseController):
Log.debug(self, "ngxblocker is already installed") Log.debug(self, "ngxblocker is already installed")
Log.info(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 # UTILS
if pargs.utils: if pargs.utils:
Log.debug(self, "Setting packages variable for 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.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and (not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and (not pargs.extplorer) and (not pargs.clamav) and
(not pargs.cheat) and
(not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)): (not pargs.php73)):
@@ -565,6 +586,7 @@ class WOStackController(CementBaseController):
pargs.utils = True pargs.utils = True
pargs.netdata = True pargs.netdata = True
pargs.mysqltuner = True pargs.mysqltuner = True
pargs.cheat = True
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -674,6 +696,14 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing packages for MySQLTuner ") Log.debug(self, "Removing packages for MySQLTuner ")
packages = packages + ['/usr/bin/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 # PHPREDISADMIN
if pargs.phpredisadmin: if pargs.phpredisadmin:
Log.debug(self, "Removing package variable of 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.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and (not pargs.redis) and (not pargs.proftpd) and
(not pargs.extplorer) and (not pargs.clamav) and (not pargs.extplorer) and (not pargs.clamav) and
(not pargs.cheat) and
(not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.ufw) and (not pargs.ngxblocker) and
(not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.phpredisadmin) and (not pargs.sendmail) and
(not pargs.php73)): (not pargs.php73)):
@@ -823,6 +854,7 @@ class WOStackController(CementBaseController):
pargs.composer = True pargs.composer = True
pargs.netdata = True pargs.netdata = True
pargs.mysqltuner = True pargs.mysqltuner = True
pargs.cheat = True
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -939,6 +971,14 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing packages for MySQLTuner ") Log.debug(self, "Removing packages for MySQLTuner ")
packages = packages + ['/usr/bin/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 # PHPREDISADMIN
if pargs.phpredisadmin: if pargs.phpredisadmin:
Log.debug(self, "Removing package variable of phpRedisAdmin ") Log.debug(self, "Removing package variable of phpRedisAdmin ")

View File

@@ -1192,6 +1192,21 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner") Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner")
WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775) 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 # netdata install
if any('/var/lib/wo/tmp/kickstart.sh' == x[1] if any('/var/lib/wo/tmp/kickstart.sh' == x[1]
for x in packages): for x in packages):
@@ -1488,8 +1503,8 @@ def pre_stack(self):
WOTemplate.deploy( WOTemplate.deploy(
self, '/etc/update-motd.d/98-wo-update', self, '/etc/update-motd.d/98-wo-update',
'wo-update.mustache', data) 'wo-update.mustache', data)
WOFileUtils.chmod( WOFileUtils.chmod(
self, "/etc/update-motd.d/98-wo-update", 0o755) self, "/etc/update-motd.d/98-wo-update", 0o755)
# restart motd-news service if available # restart motd-news service if available
if os.path.isfile('/lib/systemd/system/motd-news.service'): if os.path.isfile('/lib/systemd/system/motd-news.service'):
WOService.restart_service(self, 'motd-news') WOService.restart_service(self, 'motd-news')

View File

@@ -1,5 +1,5 @@
"""Testing utilities for WordOps""" """Testing utilities for WordOps"""
from cement.utils.tests import CementTestCase from cement.utils.test import CementTestCase
from wo.cli.main import WOTestApp from wo.cli.main import WOTestApp