add fail2ban
This commit is contained in:
1074
smtp-cli.pl
1074
smtp-cli.pl
File diff suppressed because it is too large
Load Diff
@@ -71,6 +71,8 @@ class WOStackController(CementBaseController):
|
|||||||
dict(help='Install WordOps dashboard', action='store_true')),
|
dict(help='Install WordOps dashboard', action='store_true')),
|
||||||
(['--adminer'],
|
(['--adminer'],
|
||||||
dict(help='Install Adminer stack', action='store_true')),
|
dict(help='Install Adminer stack', action='store_true')),
|
||||||
|
(['--fail2ban'],
|
||||||
|
dict(help='Install Fail2ban stack', action='store_true')),
|
||||||
(['--utils'],
|
(['--utils'],
|
||||||
dict(help='Install Utils stack', action='store_true')),
|
dict(help='Install Utils stack', action='store_true')),
|
||||||
(['--redis'],
|
(['--redis'],
|
||||||
@@ -1014,6 +1016,23 @@ class WOStackController(CementBaseController):
|
|||||||
WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
|
WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
|
||||||
WOService.reload_service(self, 'mysql')
|
WOService.reload_service(self, 'mysql')
|
||||||
|
|
||||||
|
if set(WOVariables.wo_fail2ban).issubset(set(apt_packages)):
|
||||||
|
if not os.path.isfile("/etc/fail2ban/jail.d/custom.conf"):
|
||||||
|
data = dict()
|
||||||
|
Log.debug(self, "Setting up fail2ban jails configuration")
|
||||||
|
wo_fail2ban = open('/etc/fail2ban/jail.d/custom.conf',
|
||||||
|
encoding='utf-8', mode='w')
|
||||||
|
self.app.render((data), 'fail2ban.mustache',
|
||||||
|
out=wo_fail2ban)
|
||||||
|
wo_fail2ban.close()
|
||||||
|
|
||||||
|
Log.debug(self, "Setting up fail2ban wp filter")
|
||||||
|
wo_fail2ban = open('/etc/fail2ban/filter.d/wo-wordpress.conf',
|
||||||
|
encoding='utf-8', mode='w')
|
||||||
|
self.app.render((data), 'fail2ban-wp.mustache',
|
||||||
|
out=wo_fail2ban)
|
||||||
|
wo_fail2ban.close()
|
||||||
|
|
||||||
if len(packages):
|
if len(packages):
|
||||||
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"
|
||||||
@@ -1441,6 +1460,15 @@ class WOStackController(CementBaseController):
|
|||||||
Log.debug(self, "WP-CLI is already installed")
|
Log.debug(self, "WP-CLI is already installed")
|
||||||
Log.info(self, "WP-CLI is already installed")
|
Log.info(self, "WP-CLI is already installed")
|
||||||
|
|
||||||
|
# fail2ban
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
Log.debug(self, "Setting apt_packages variable for Fail2ban")
|
||||||
|
if not WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
apt_packages = apt_packages + WOVariables.wo_fail2ban
|
||||||
|
else:
|
||||||
|
Log.debug(self, "Fail2ban already installed")
|
||||||
|
Log.info(self, "Fail2ban already installed")
|
||||||
|
|
||||||
# PHPMYADMIN
|
# PHPMYADMIN
|
||||||
if self.app.pargs.phpmyadmin:
|
if self.app.pargs.phpmyadmin:
|
||||||
Log.debug(self, "Setting packages variable for phpMyAdmin ")
|
Log.debug(self, "Setting packages variable for phpMyAdmin ")
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ class WOStackStatusController(CementBaseController):
|
|||||||
self.app.pargs.php73 or
|
self.app.pargs.php73 or
|
||||||
self.app.pargs.mysql or
|
self.app.pargs.mysql or
|
||||||
self.app.pargs.memcached or
|
self.app.pargs.memcached or
|
||||||
self.app.pargs.redis):
|
self.app.pargs.redis or
|
||||||
|
self.app.pargs.fail2ban or
|
||||||
|
self.app.pargs.netdata):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
@@ -78,6 +80,12 @@ class WOStackStatusController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Redis server is not installed")
|
Log.info(self, "Redis server is not installed")
|
||||||
|
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
services = services + ['fail2ban-client']
|
||||||
|
else:
|
||||||
|
Log.info(self, "fail2ban is not installed")
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
Log.debug(self, "Starting service: {0}".format(service))
|
Log.debug(self, "Starting service: {0}".format(service))
|
||||||
WOService.start_service(self, service)
|
WOService.start_service(self, service)
|
||||||
@@ -143,6 +151,12 @@ class WOStackStatusController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Redis server is not installed")
|
Log.info(self, "Redis server is not installed")
|
||||||
|
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
services = services + ['fail2ban-client']
|
||||||
|
else:
|
||||||
|
Log.info(self, "fail2ban is not installed")
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
Log.debug(self, "Stopping service: {0}".format(service))
|
Log.debug(self, "Stopping service: {0}".format(service))
|
||||||
WOService.stop_service(self, service)
|
WOService.stop_service(self, service)
|
||||||
@@ -155,7 +169,8 @@ class WOStackStatusController(CementBaseController):
|
|||||||
self.app.pargs.php73 or
|
self.app.pargs.php73 or
|
||||||
self.app.pargs.mysql or
|
self.app.pargs.mysql or
|
||||||
self.app.pargs.memcached or
|
self.app.pargs.memcached or
|
||||||
self.app.pargs.redis):
|
self.app.pargs.redis or
|
||||||
|
self.app.pargs.fail2ban):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
@@ -209,6 +224,12 @@ class WOStackStatusController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Redis server is not installed")
|
Log.info(self, "Redis server is not installed")
|
||||||
|
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
services = services + ['fail2ban-client']
|
||||||
|
else:
|
||||||
|
Log.info(self, "fail2ban is not installed")
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
Log.debug(self, "Restarting service: {0}".format(service))
|
Log.debug(self, "Restarting service: {0}".format(service))
|
||||||
WOService.restart_service(self, service)
|
WOService.restart_service(self, service)
|
||||||
@@ -221,7 +242,8 @@ class WOStackStatusController(CementBaseController):
|
|||||||
self.app.pargs.php73 or
|
self.app.pargs.php73 or
|
||||||
self.app.pargs.mysql or
|
self.app.pargs.mysql or
|
||||||
self.app.pargs.memcached or
|
self.app.pargs.memcached or
|
||||||
self.app.pargs.redis):
|
self.app.pargs.redis or
|
||||||
|
self.app.pargs.fail2ban):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
@@ -274,6 +296,12 @@ class WOStackStatusController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Redis server is not installed")
|
Log.info(self, "Redis server is not installed")
|
||||||
|
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
services = services + ['fail2ban-client']
|
||||||
|
else:
|
||||||
|
Log.info(self, "fail2ban is not installed")
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
if WOService.get_service_status(self, service):
|
if WOService.get_service_status(self, service):
|
||||||
Log.info(self, "{0:10}: {1}".format(service, "Running"))
|
Log.info(self, "{0:10}: {1}".format(service, "Running"))
|
||||||
@@ -286,7 +314,8 @@ class WOStackStatusController(CementBaseController):
|
|||||||
self.app.pargs.php73 or
|
self.app.pargs.php73 or
|
||||||
self.app.pargs.mysql or
|
self.app.pargs.mysql or
|
||||||
self.app.pargs.memcached or
|
self.app.pargs.memcached or
|
||||||
self.app.pargs.redis):
|
self.app.pargs.redis or
|
||||||
|
self.app.pargs.fail2ban):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
@@ -340,6 +369,12 @@ class WOStackStatusController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Redis server is not installed")
|
Log.info(self, "Redis server is not installed")
|
||||||
|
|
||||||
|
if self.app.pargs.fail2ban:
|
||||||
|
if WOAptGet.is_installed(self, 'fail2ban'):
|
||||||
|
services = services + ['fail2ban-client']
|
||||||
|
else:
|
||||||
|
Log.info(self, "fail2ban is not installed")
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
Log.debug(self, "Reloading service: {0}".format(service))
|
Log.debug(self, "Reloading service: {0}".format(service))
|
||||||
WOService.reload_service(self, service)
|
WOService.reload_service(self, service)
|
||||||
|
|||||||
Reference in New Issue
Block a user