Fix cheat
This commit is contained in:
@@ -165,14 +165,6 @@ class WOStackController(CementBaseController):
|
||||
pargs.fail2ban = 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
|
||||
if pargs.nginx:
|
||||
Log.debug(self, "Setting apt_packages variable for Nginx")
|
||||
@@ -196,6 +188,14 @@ class WOStackController(CementBaseController):
|
||||
else:
|
||||
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
|
||||
if pargs.php:
|
||||
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")
|
||||
if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
|
||||
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
|
||||
if pargs.mysqlclient:
|
||||
Log.debug(self, "Setting apt_packages variable "
|
||||
"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
|
||||
if pargs.wpcli:
|
||||
@@ -341,6 +348,10 @@ class WOStackController(CementBaseController):
|
||||
"htdocs/db/adminer/adminer.css"
|
||||
.format(WOVariables.wo_webroot),
|
||||
"Adminer theme"]]
|
||||
else:
|
||||
Log.debug(self, "Adminer already installed")
|
||||
Log.info(self, "Adminer already installed")
|
||||
|
||||
# mysqltuner
|
||||
if pargs.mysqltuner:
|
||||
if not os.path.isfile("/usr/bin/mysqltuner"):
|
||||
@@ -352,6 +363,9 @@ class WOStackController(CementBaseController):
|
||||
"/master/mysqltuner.pl",
|
||||
"/usr/bin/mysqltuner",
|
||||
"MySQLTuner"]]
|
||||
else:
|
||||
Log.debug(self, "MySQLtuner already installed")
|
||||
Log.info(self, "MySQLtuner already installed")
|
||||
|
||||
# Netdata
|
||||
if pargs.netdata:
|
||||
@@ -443,17 +457,19 @@ class WOStackController(CementBaseController):
|
||||
["https://github.com/box/Anemometer/"
|
||||
"archive/master.tar.gz",
|
||||
'/var/lib/wo/tmp/anemometer.tar.gz',
|
||||
'Anemometer']
|
||||
]
|
||||
'Anemometer']]
|
||||
if pargs.cheat:
|
||||
if (not os.path.isfile('/usr/local/bin/cht.sh') and
|
||||
not os.path.isfile('/usr/bin/cht.sh')):
|
||||
Log.debug(self, "Setting packages variable for cht.sh")
|
||||
packages = packages + [["https://cht.sh/:cht.sh",
|
||||
"/usr/local/bin/cht.sh",
|
||||
"cheat.sh"]]
|
||||
WOShellExec.cmd_exec(
|
||||
self, "/usr/bin/curl https://cht.sh/:cht.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:
|
||||
Log.debug(self, "cht.sh is already installed")
|
||||
Log.debug(self, "cheat.sh is already installed")
|
||||
Log.info(self, "cheat.sh is already installed")
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -1068,7 +1068,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
Log.debug(self, "{0}".format(e))
|
||||
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",
|
||||
encoding='utf-8', mode='a') as f2bproftpd:
|
||||
f2bproftpd.write("\n\n[proftpd]\nenabled = true\n")
|
||||
@@ -1173,11 +1175,13 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
'added by WordOps')
|
||||
|
||||
if (packages):
|
||||
# WP-CLI
|
||||
if any('/usr/local/bin/wp' == x[1] for x in packages):
|
||||
Log.debug(self, "Setting Privileges"
|
||||
" to /usr/local/bin/wp file ")
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
|
||||
|
||||
# PHPMyAdmin
|
||||
if any('/var/lib/wo/tmp/pma.tar.gz' == x[1]
|
||||
for x in packages):
|
||||
WOExtract.extract(
|
||||
@@ -1259,7 +1263,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
'www-data',
|
||||
'www-data',
|
||||
recursive=True)
|
||||
|
||||
# MySQLtuner
|
||||
if any('/usr/bin/mysqltuner' == x[1]
|
||||
for x in packages):
|
||||
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]
|
||||
for x in packages):
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/cht.sh", 0o775)
|
||||
if not WOFileUtils.grep(self, "~/.bashrc", "cheat"):
|
||||
with open("~/.bashrc",
|
||||
if (not WOFileUtils.grep(self, "/root/.bashrc", "cheat") and
|
||||
not WOFileUtils.grep(self, "/home/ubuntu/.bashrc", "cheat")):
|
||||
with open("/root/.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
|
||||
if any('/var/lib/wo/tmp/pra.tar.gz' == x[1]
|
||||
|
||||
Reference in New Issue
Block a user