From d6f722ebbfcb3ddb8bd52af3061ffe6b8906b634 Mon Sep 17 00:00:00 2001 From: Thom Date: Sat, 11 Nov 2023 22:38:33 +0100 Subject: [PATCH] Enable the Fail2Ban service after installing (#114) --- lib/os/class.ISPConfigBaseOS.inc.php | 5 +++++ lib/os/class.ISPConfigDebian10OS.inc.php | 2 +- lib/os/class.ISPConfigDebianOS.inc.php | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/os/class.ISPConfigBaseOS.inc.php b/lib/os/class.ISPConfigBaseOS.inc.php index b3a4827..35d3293 100644 --- a/lib/os/class.ISPConfigBaseOS.inc.php +++ b/lib/os/class.ISPConfigBaseOS.inc.php @@ -419,6 +419,11 @@ class ISPConfigBaseOS { return $this->exec($cmd); } + protected function enableService($service_name) { + $cmd = $this->getRestartServiceCommand($service_name, 'enable'); + return $this->exec($cmd); + } + protected function isServiceRunning($service_name) { $cmd = $this->getRestartServiceCommand($service_name, 'status'); $result = $this->exec($cmd); diff --git a/lib/os/class.ISPConfigDebian10OS.inc.php b/lib/os/class.ISPConfigDebian10OS.inc.php index c155636..ed31ba3 100644 --- a/lib/os/class.ISPConfigDebian10OS.inc.php +++ b/lib/os/class.ISPConfigDebian10OS.inc.php @@ -12,7 +12,7 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS { } public function getRestartServiceCommand($service, $command = 'restart') { - if($command != 'start' && $command != 'stop' && $command != 'status') { + if($command != 'start' && $command != 'stop' && $command != 'enable' && $command != 'status') { $command = 'restart'; } diff --git a/lib/os/class.ISPConfigDebianOS.inc.php b/lib/os/class.ISPConfigDebianOS.inc.php index fb7891d..10d3fd8 100644 --- a/lib/os/class.ISPConfigDebianOS.inc.php +++ b/lib/os/class.ISPConfigDebianOS.inc.php @@ -75,7 +75,7 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { } public function getRestartServiceCommand($service, $command = 'restart') { - if($command != 'start' && $command != 'stop' && $command != 'status') { + if($command != 'start' && $command != 'stop' && $command != 'enable' && $command != 'status') { $command = 'restart'; } @@ -2022,6 +2022,9 @@ SCRIPTWHITELIST=/usr/bin/lwp-request'; $this->restartService('fail2ban'); + // Fail2Ban is disabled by default on Ubuntu 22.04 and newer. Enabling it on any OS does not hurt. + $this->enableService('fail2ban'); + $this->fixDbconfigCommon(); $this->configureSecureShell(); -- GitLab