Skip to content

Commit 877a0ee

Browse files
committed
Refactor to use is_installed helper function
1 parent 3ebca32 commit 877a0ee

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

server/lib/classes/cron.d/100-monitor_iptables.inc.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public function onRunJob() {
6767
$type = 'iptables_rules';
6868

6969
/* This monitoring is only available if fail2ban is installed */
70-
system('which iptables > /dev/null', $retval); // Debian, Ubuntu, Fedora
71-
if ($retval === 0) {
70+
if ($app->system->is_installed('iptables')) {
7271
/* Get the data of the log */
7372
$data['output'] = '<h2>iptables -S (ipv4)</h2>'.shell_exec('iptables -S 2>/dev/null');
7473

@@ -83,8 +82,7 @@ public function onRunJob() {
8382

8483

8584
/* This monitoring is only available if fail2ban is installed */
86-
system('which ip6tables > /dev/null', $retval); // Debian, Ubuntu, Fedora
87-
if ($retval === 0) {
85+
if ($app->system->is_installed('ip6tables')) {
8886
/* Get the data of the log */
8987
$data['output'] .= '<br><h2>ip6tables -S (ipv6)</h2>'.shell_exec('ip6tables -S 2>/dev/null');
9088

server/lib/classes/cron.d/100-monitor_raid.inc.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ public function onRunJob() {
126126
* Check, if we have mpt-status installed (LSIsoftware-raid)
127127
*/
128128
if (file_exists('/proc/mpt/summary')) {
129-
system('which mpt-status', $retval);
130-
if ($retval === 0) {
129+
if ($app->system->is_installed('mpt-status')) {
131130
/*
132131
* Fetch the output
133132
*/
@@ -174,8 +173,7 @@ public function onRunJob() {
174173
/*
175174
* 3ware Controller
176175
*/
177-
system('which tw_cli', $retval);
178-
if($retval === 0) {
176+
if($app->system->is_installed('tw_cli')) {
179177

180178
// TYPOWORX FIX | Determine Controler-ID
181179
$availableControlers = shell_exec('tw_cli info | grep -Eo "c[0-9]+"');
@@ -232,8 +230,7 @@ public function onRunJob() {
232230
/*
233231
* HP Proliant
234232
*/
235-
system('which hpacucli', $retval);
236-
if($retval === 0) {
233+
if($app->system->is_installed('hpacucli')) {
237234
$state = 'ok';
238235
$data['output'] = shell_exec('/usr/sbin/hpacucli ctrl all show config');
239236
$tmp = explode("\n", $data['output']);
@@ -298,8 +295,7 @@ public function onRunJob() {
298295
/*
299296
* Adaptec-RAID
300297
*/
301-
system('which arcconf', $retval);
302-
if($retval === 0) {
298+
if($app->system->is_installed('arcconf')) {
303299
$state = 'ok';
304300
$data['output'] = shell_exec('arcconf GETCONFIG 1 LD');
305301
if(is_array($data['output'])) {

server/lib/classes/cron.d/100-monitor_rkhunter.inc.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public function onRunJob() {
6767
$type = 'rkhunter';
6868

6969
/* This monitoring is only available if rkhunter is installed */
70-
system('which rkhunter', $retval);
71-
if ($retval === 0) {
70+
if ($app->system->is_installed('rkhunter')) {
7271
/*
7372
* Fetch the output
7473
*/

server/lib/classes/cron.d/500-backup_mail.inc.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public function onRunJob() {
7878
} else {
7979
chmod($backup_dir, $backup_dir_permissions);
8080
}
81-
system('which pigz > /dev/null', $ret);
82-
if($ret === 0) {
81+
if($app->system->is_installed('pigz')) {
8382
$use_pigz = true;
8483
} else {
8584
$use_pigz = false;

0 commit comments

Comments
 (0)