Skip to content

Commit 61e4043

Browse files
lafmurrant
andauthored
Add support for updating on certain days (librenms#19880)
* Add support for updating on certain days * Update daily.php * Update Updating.md * distinct days --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
1 parent 3fbec89 commit 61e4043

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

daily.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
exit(0);
5454
}
5555

56+
$on_days = LibrenmsConfig::get('update_on_days', []);
57+
58+
if (is_array($on_days) && ! empty($on_days)) {
59+
$today = strtolower(date('l')); // monday..sunday
60+
61+
if (! in_array($today, $on_days, true)) {
62+
exit(0);
63+
}
64+
}
65+
5666
if (LibrenmsConfig::get('update_channel') == 'master') {
5767
exit(1);
5868
} elseif (LibrenmsConfig::get('update_channel') == 'release') {

doc/General/Updating.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,16 @@ This can be disabled in the WebUI:
4242
```bash
4343
lnms config:set update false
4444
```
45+
46+
## Updating on set days
47+
48+
You can configure LibreNMS to only perform updates on set days. This configuration is an
49+
array and is blank by default.
50+
51+
!!! setting "system/updates"
52+
```bash
53+
lnms config:get update_on_days
54+
```
55+
```bash
56+
lnms config:set update_on_days.+ "monday"
57+
```

lang/en/settings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,10 @@
24102410
'release' => 'Monthly',
24112411
],
24122412
],
2413+
'update_on_days' => [
2414+
'description' => 'Only run updates on these days',
2415+
'help' => 'If set (non-empty), daily.sh will only run code updates when today matches one of these values: monday-sunday or mon-sun. Leave empty to allow updates every day.',
2416+
],
24132417
'uptime_warning' => [
24142418
'description' => 'Show Device as warning if Uptime below (seconds)',
24152419
'help' => 'Shows Device as warning if Uptime is below this value. Custom maps status will reflect this setting. 0 disables warning. Default 24h',

resources/definitions/config_definitions.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7311,6 +7311,26 @@
73117311
"release": "release"
73127312
}
73137313
},
7314+
"update_on_days": {
7315+
"default": ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"],
7316+
"type": "array",
7317+
"options": {
7318+
"monday": "Monday",
7319+
"tuesday": "Tuesday",
7320+
"wednesday": "Wednesday",
7321+
"thursday": "Thursday",
7322+
"friday": "Friday",
7323+
"saturday": "Saturday",
7324+
"sunday": "Sunday"
7325+
},
7326+
"validate": {
7327+
"value": "array",
7328+
"value.*": "distinct|in:monday,tuesday,wednesday,thursday,friday,saturday,sunday"
7329+
},
7330+
"group": "system",
7331+
"section": "updates",
7332+
"order": 2
7333+
},
73147334
"uptime_warning": {
73157335
"group": "webui",
73167336
"section": "device",

0 commit comments

Comments
 (0)