Skip to content

Commit 81768b8

Browse files
committed
use dnf as default package manager whenever possible
1 parent 40d783f commit 81768b8

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

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

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,38 @@ public function onRunJob() {
160160
*/
161161
$data['output'] = shell_exec('zypper lu');
162162
} elseif(file_exists('/etc/redhat-release')) {
163-
/*
164-
* update and find the upgrade.
165-
* if there is any output, then there is a needed update
166-
*/
167-
$aptData = shell_exec('yum -q list updates');
168-
if ($aptData == '') {
169-
/* There is nothing to update! */
170-
$state = 'ok';
171-
} else {
172-
/*
173-
* There is something to update! this is in most cases not critical, so we can
174-
* do a system-update once a month or so...
175-
*/
176-
$state = 'info';
177-
}
178-
179-
/*
180-
* Fetch the output
181-
*/
182-
$data['output'] = shell_exec('yum -q list updates');
163+
/*
164+
* update and find the upgrade.
165+
* if there is any output, then there is a needed update
166+
*/
167+
168+
/* try to figure out the default package manager first */
169+
if(file_exists('/usr/bin/dnf') && (is_link('/usr/bin/yum'))) {
170+
$rhPkgMgr = 'dnf';
171+
} elseif(file_exists('/usr/bin/dnf') && (!file_exists('/usr/bin/yum')) || (!is_link('/usr/bin/yum'))) {
172+
$rhPkgMgr = 'dnf';
173+
} else {
174+
$rhPkgMgr = 'yum';
175+
}
176+
177+
$aptData = shell_exec($rhPkgMgr. ' -q list updates');
178+
if ($aptData == '') {
179+
/* There is nothing to update! */
180+
$state = 'ok';
181+
} else {
182+
/*
183+
* There is something to update! this is in most cases not critical, so we can
184+
* do a system-update once a month or so...
185+
*/
186+
$state = 'info';
187+
}
188+
189+
/*
190+
* Fetch the output
191+
*/
192+
$data['output'] = shell_exec($rhPkgMgr. ' -q list updates');
183193

184-
} else {
194+
} else {
185195
/*
186196
* It is not Debian/Ubuntu, so there is no data and no state
187197
*

0 commit comments

Comments
 (0)