Fix cheat

This commit is contained in:
VirtuBox
2019-08-29 20:02:35 +02:00
parent 29a290c935
commit 960ee01d10
2 changed files with 41 additions and 20 deletions

View File

@@ -165,14 +165,6 @@ class WOStackController(CementBaseController):
pargs.fail2ban = True pargs.fail2ban = True
pargs.clamav = True pargs.clamav = True
# Redis
if pargs.redis:
if not WOAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + WOVariables.wo_redis
pargs.php = True
else:
Log.info(self, "Redis already installed")
# Nginx # Nginx
if pargs.nginx: if pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
@@ -196,6 +188,14 @@ class WOStackController(CementBaseController):
else: else:
Log.debug(self, "Nginx Stable already installed") Log.debug(self, "Nginx Stable already installed")
# Redis
if pargs.redis:
if not WOAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + WOVariables.wo_redis
pargs.php = True
else:
Log.info(self, "Redis already installed")
# PHP 7.2 # PHP 7.2
if pargs.php: if pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP 7.2") Log.debug(self, "Setting apt_packages variable for PHP 7.2")
@@ -228,12 +228,19 @@ class WOStackController(CementBaseController):
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"): if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql apt_packages = apt_packages + WOVariables.wo_mysql
else:
Log.debug(self, "MySQL already installed and alive")
Log.info(self, "MySQL already installed and alive")
# mysqlclient # mysqlclient
if pargs.mysqlclient: if pargs.mysqlclient:
Log.debug(self, "Setting apt_packages variable " Log.debug(self, "Setting apt_packages variable "
"for MySQL Client") "for MySQL Client")
apt_packages = apt_packages + WOVariables.wo_mysql_client if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql_client
else:
Log.debug(self, "MySQL already installed and alive")
Log.info(self, "MySQL already installed and alive")
# WP-CLI # WP-CLI
if pargs.wpcli: if pargs.wpcli:
@@ -341,6 +348,10 @@ class WOStackController(CementBaseController):
"htdocs/db/adminer/adminer.css" "htdocs/db/adminer/adminer.css"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
"Adminer theme"]] "Adminer theme"]]
else:
Log.debug(self, "Adminer already installed")
Log.info(self, "Adminer already installed")
# mysqltuner # mysqltuner
if pargs.mysqltuner: if pargs.mysqltuner:
if not os.path.isfile("/usr/bin/mysqltuner"): if not os.path.isfile("/usr/bin/mysqltuner"):
@@ -352,6 +363,9 @@ class WOStackController(CementBaseController):
"/master/mysqltuner.pl", "/master/mysqltuner.pl",
"/usr/bin/mysqltuner", "/usr/bin/mysqltuner",
"MySQLTuner"]] "MySQLTuner"]]
else:
Log.debug(self, "MySQLtuner already installed")
Log.info(self, "MySQLtuner already installed")
# Netdata # Netdata
if pargs.netdata: if pargs.netdata:
@@ -443,17 +457,19 @@ class WOStackController(CementBaseController):
["https://github.com/box/Anemometer/" ["https://github.com/box/Anemometer/"
"archive/master.tar.gz", "archive/master.tar.gz",
'/var/lib/wo/tmp/anemometer.tar.gz', '/var/lib/wo/tmp/anemometer.tar.gz',
'Anemometer'] 'Anemometer']]
]
if pargs.cheat: if pargs.cheat:
if (not os.path.isfile('/usr/local/bin/cht.sh') and if (not os.path.isfile('/usr/local/bin/cht.sh') and
not os.path.isfile('/usr/bin/cht.sh')): not os.path.isfile('/usr/bin/cht.sh')):
Log.debug(self, "Setting packages variable for cht.sh") Log.debug(self, "Setting packages variable for cht.sh")
packages = packages + [["https://cht.sh/:cht.sh", WOShellExec.cmd_exec(
"/usr/local/bin/cht.sh", self, "/usr/bin/curl https://cht.sh/:cht.sh "
"cheat.sh"]] "| sudo tee /usr/local/bin/cht.sh")
WOShellExec(self, "/usr/bin/curl "
"https://cheat.sh/:bash_completion |"
"sudo tee /etc/bash_completion.d/cht.sh")
else: else:
Log.debug(self, "cht.sh is already installed") Log.debug(self, "cheat.sh is already installed")
Log.info(self, "cheat.sh is already installed") Log.info(self, "cheat.sh is already installed")
except Exception as e: except Exception as e:

View File

@@ -1068,7 +1068,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to add UFW rule") Log.error(self, "Unable to add UFW rule")
if os.path.isfile("/etc/fail2ban/jail.d/custom.conf"): if ((os.path.isfile("/etc/fail2ban/jail.d/custom.conf")) and
(not WOFileUtils.grep(self, "/etc/fail2ban/jail.d/custom.conf",
"proftpd"))):
with open("/etc/fail2ban/jail.d/custom.conf", with open("/etc/fail2ban/jail.d/custom.conf",
encoding='utf-8', mode='a') as f2bproftpd: encoding='utf-8', mode='a') as f2bproftpd:
f2bproftpd.write("\n\n[proftpd]\nenabled = true\n") f2bproftpd.write("\n\n[proftpd]\nenabled = true\n")
@@ -1173,11 +1175,13 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'added by WordOps') 'added by WordOps')
if (packages): if (packages):
# WP-CLI
if any('/usr/local/bin/wp' == x[1] for x in packages): if any('/usr/local/bin/wp' == x[1] for x in packages):
Log.debug(self, "Setting Privileges" Log.debug(self, "Setting Privileges"
" to /usr/local/bin/wp file ") " to /usr/local/bin/wp file ")
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775) WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
# PHPMyAdmin
if any('/var/lib/wo/tmp/pma.tar.gz' == x[1] if any('/var/lib/wo/tmp/pma.tar.gz' == x[1]
for x in packages): for x in packages):
WOExtract.extract( WOExtract.extract(
@@ -1259,7 +1263,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'www-data', 'www-data',
'www-data', 'www-data',
recursive=True) recursive=True)
# MySQLtuner
if any('/usr/bin/mysqltuner' == x[1] if any('/usr/bin/mysqltuner' == x[1]
for x in packages): for x in packages):
Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner") Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner")
@@ -1481,10 +1485,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if any('/usr/local/bin/cht.sh' == x[1] if any('/usr/local/bin/cht.sh' == x[1]
for x in packages): for x in packages):
WOFileUtils.chmod(self, "/usr/local/bin/cht.sh", 0o775) WOFileUtils.chmod(self, "/usr/local/bin/cht.sh", 0o775)
if not WOFileUtils.grep(self, "~/.bashrc", "cheat"): if (not WOFileUtils.grep(self, "/root/.bashrc", "cheat") and
with open("~/.bashrc", not WOFileUtils.grep(self, "/home/ubuntu/.bashrc", "cheat")):
with open("/root/.bashrc",
"a") as wo_bashrc: "a") as wo_bashrc:
wo_bashrc.write("\nalias cheat='cht.sh'\n") wo_bashrc.write("\nalias cheat='/usr/local/bin/cht.sh'\n")
# phpredisadmin # phpredisadmin
if any('/var/lib/wo/tmp/pra.tar.gz' == x[1] if any('/var/lib/wo/tmp/pra.tar.gz' == x[1]