mirror of
https://github.com/unraid/webgui.git
synced 2026-04-23 10:38:50 -05:00
Added separate unRAID OS check schedule and associated notifications
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
@@ -22,19 +22,18 @@ $unraid = parse_plugin_cfg('dynamix', true);
|
||||
$notify = "$docroot/webGui/scripts/notify";
|
||||
$server = strtoupper($var['NAME']);
|
||||
$output = $unraid['notify']['plugin'];
|
||||
$builtin = ['unRAIDServer','dynamix'];
|
||||
|
||||
plugin("checkall");
|
||||
plugin('checkall');
|
||||
foreach (glob("/tmp/plugins/*.plg", GLOB_NOSORT) as $file) {
|
||||
$plg = basename($file);
|
||||
$name = basename($plg, '.plg');
|
||||
if (in_array($name,$builtin)) continue;
|
||||
$old = plugin('version', "/var/log/plugins/$plg");
|
||||
$new = plugin('version', $file);
|
||||
// silently suppress bad download of PLG file
|
||||
if (strcmp($new, $old) > 0) {
|
||||
$unRAID = plugin('unRAID', $file);
|
||||
if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) {
|
||||
$name = basename($file, '.plg');
|
||||
exec("$notify -e ".escapeshellarg("Plugin - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -x");
|
||||
}
|
||||
exec("$notify -e ".escapeshellarg("Plugin - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -x");
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
$var = parse_ini_file('/var/local/emhttp/var.ini');
|
||||
$current = parse_ini_file('/etc/unraid-version');
|
||||
$unraid = parse_plugin_cfg('dynamix', true);
|
||||
$notify = "$docroot/webGui/scripts/notify";
|
||||
$server = strtoupper($var['NAME']);
|
||||
$output = $unraid['notify']['plugin'];
|
||||
$builtin = ['unRAIDServer','dynamix'];
|
||||
|
||||
foreach ($builtin as $name) {
|
||||
$plg = "$name.plg";
|
||||
plugin('check',$plg);
|
||||
$file = "/tmp/plugins/$plg";
|
||||
$old = plugin('version', "/var/log/plugins/$plg");
|
||||
$new = plugin('version', $file);
|
||||
// silently suppress bad download of PLG file
|
||||
if (strcmp($new, $old) > 0) {
|
||||
$unRAID = plugin('unRAID', $file);
|
||||
if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) {
|
||||
exec("$notify -e ".escapeshellarg("System - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -x");
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
?>
|
||||
@@ -4,8 +4,8 @@ Title="Notification Settings"
|
||||
Icon="notifications.png"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, Bergware International.
|
||||
* Copyright 2012, Andrew Hamer-Adams, http://www.pixeleyes.co.nz.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -26,6 +26,7 @@ function prepareNotify(form) {
|
||||
form.normal.value = form.normal1.checked*1 + form.normal2.checked*2 + form.normal3.checked*4;
|
||||
form.warning.value = form.warning1.checked*1 + form.warning2.checked*2 + form.warning3.checked*4;
|
||||
form.alert.value = form.alert1.checked*1 + form.alert2.checked*2 + form.alert3.checked*4;
|
||||
form.unraid.value = form.unraid1.checked*1 + form.unraid2.checked*2 + form.unraid3.checked*4;
|
||||
form.plugin.value = form.plugin1.checked*1 + form.plugin2.checked*2 + form.plugin3.checked*4;
|
||||
form.docker_notify.value = form.docker_notify1.checked*1 + form.docker_notify2.checked*2 + form.docker_notify3.checked*4;
|
||||
form.report.value = form.report1.checked*1 + form.report2.checked*2 + form.report3.checked*4;
|
||||
@@ -38,6 +39,9 @@ function prepareNotify(form) {
|
||||
form.alert1.disabled = true;
|
||||
form.alert2.disabled = true;
|
||||
form.alert3.disabled = true;
|
||||
form.unraid1.disabled = true;
|
||||
form.unraid2.disabled = true;
|
||||
form.unraid3.disabled = true;
|
||||
form.plugin1.disabled = true;
|
||||
form.plugin2.disabled = true;
|
||||
form.plugin3.disabled = true;
|
||||
@@ -48,16 +52,21 @@ function prepareNotify(form) {
|
||||
form.report2.disabled = true;
|
||||
form.report3.disabled = true;
|
||||
}
|
||||
function prepareCheckbox(index) {
|
||||
function prepareSystem(index) {
|
||||
if (index==0) $('.checkbox').attr('disabled','disabled'); else $('.checkbox').removeAttr('disabled');
|
||||
}
|
||||
function prepareTitle() {
|
||||
var title = 'Available notifications:';
|
||||
$('#pluginTitle,#dockerTitle,#reportTitle').html(' ');
|
||||
$('#unraidTitle,#pluginTitle,#dockerTitle,#reportTitle').html(' ');
|
||||
if ($('.unraid').is(':visible')) { $('#unraidTitle').html(title); return; }
|
||||
if ($('.plugin').is(':visible')) { $('#pluginTitle').html(title); return; }
|
||||
if ($('.docker').is(':visible')) { $('#dockerTitle').html(title); return; }
|
||||
if ($('.report').is(':visible')) { $('#reportTitle').html(title); return; }
|
||||
}
|
||||
function prepareUnraid(value) {
|
||||
if (value=='') $('.unraid').hide(); else $('.unraid').show();
|
||||
prepareTitle();
|
||||
}
|
||||
function preparePlugin(value) {
|
||||
if (value=='') $('.plugin').hide(); else $('.plugin').show();
|
||||
prepareTitle();
|
||||
@@ -71,6 +80,7 @@ function prepareReport(value) {
|
||||
prepareTitle();
|
||||
}
|
||||
$(function(){
|
||||
prepareUnraid(document.notify_settings.unraidos.value);
|
||||
preparePlugin(document.notify_settings.version.value);
|
||||
prepareDocker(document.notify_settings.docker_update.value);
|
||||
prepareReport(document.notify_settings.status.value);
|
||||
@@ -85,6 +95,7 @@ $(function(){
|
||||
<input type="hidden" name="normal">
|
||||
<input type="hidden" name="warning">
|
||||
<input type="hidden" name="alert">
|
||||
<input type="hidden" name="unraid">
|
||||
<input type="hidden" name="plugin">
|
||||
<input type="hidden" name="docker_notify">
|
||||
<input type="hidden" name="report">
|
||||
@@ -138,7 +149,7 @@ Store notifications to flash:
|
||||
> Notifications may be stored permanently on the flash drive under folder '/boot/config/plugins/dynamix' instead.
|
||||
|
||||
System notifications:
|
||||
: <select name="system" size="1" onchange="prepareCheckbox(this.selectedIndex)">
|
||||
: <select name="system" size="1" onchange="prepareSystem(this.selectedIndex)">
|
||||
<?=mk_option($notify['system'], "", "Disabled")?>
|
||||
<?=mk_option($notify['system'], "*/1 * * * *", "Enabled")?>
|
||||
</select>
|
||||
@@ -146,6 +157,19 @@ System notifications:
|
||||
> By default the notifications system is disabled. Enable it here to start receiving notifications.
|
||||
> The following sections give more options about which and what type of notifications will be sent.
|
||||
|
||||
unRAID OS update notification:
|
||||
: <select name="unraidos" size="1" onchange="prepareUnraid(this.value)">
|
||||
<?=mk_option($notify['unraidos'], "", "Never check")?>
|
||||
<?=mk_option($notify['unraidos'], "11 */6 * * *", "Check four times a day")?>
|
||||
<?=mk_option($notify['unraidos'], "11 0,12 * * *", "Check twice a day")?>
|
||||
<?=mk_option($notify['unraidos'], "11 0 * * *", "Check once a day")?>
|
||||
<?=mk_option($notify['unraidos'], "11 0 * * 1", "Check once a week")?>
|
||||
<?=mk_option($notify['unraidos'], "11 0 1 * *", "Check once a month")?>
|
||||
</select>
|
||||
|
||||
> Start a periodic verification and notify the user when a new version of the unRAID OS system is detected.
|
||||
> Use the checkboxes below to select how notifications need to be given; by browser, by email and/or by custom agent.
|
||||
|
||||
Plugins version notification:
|
||||
: <select name="version" size="1" onchange="preparePlugin(this.value)">
|
||||
<?=mk_option($notify['version'], "", "Never check")?>
|
||||
@@ -187,41 +211,47 @@ Array status notification:
|
||||
|
||||
> Start a periodic array health check (preventive maintenance) and notify the user the result of this check.
|
||||
|
||||
<span id="unraidTitle" class="unraid" style="display:none"> </span>
|
||||
: <span class="unraid" style="display:none"><span style="display:inline-block;width:110px;font-style:italic">unRAID OS</span>
|
||||
<input type="checkbox" name="unraid1"<?=($notify['unraid'] & 1)==1 ? ' checked' : ''?>>Browser
|
||||
<input type="checkbox" name="unraid2"<?=($notify['unraid'] & 2)==2 ? ' checked' : ''?>>Email
|
||||
<input type="checkbox" name="unraid3"<?=($notify['unraid'] & 4)==4 ? ' checked' : ''?>>Agents </span>
|
||||
|
||||
<span id="pluginTitle" class="plugin" style="display:none"> </span>
|
||||
: <span class="plugin" style="display:none"><span style="display:inline-block;width:90px;font-style:italic">Plugins version</span>
|
||||
: <span class="plugin" style="display:none"><span style="display:inline-block;width:110px;font-style:italic">Plugins version</span>
|
||||
<input type="checkbox" name="plugin1"<?=($notify['plugin'] & 1)==1 ? ' checked' : ''?>>Browser
|
||||
<input type="checkbox" name="plugin2"<?=($notify['plugin'] & 2)==2 ? ' checked' : ''?>>Email
|
||||
<input type="checkbox" name="plugin3"<?=($notify['plugin'] & 4)==4 ? ' checked' : ''?>>Agents </span>
|
||||
|
||||
<span id="dockerTitle" class="docker" style="display:none"> </span>
|
||||
: <span class="docker" style="display:none"><span style="display:inline-block;width:90px;font-style:italic">Docker update</span>
|
||||
: <span class="docker" style="display:none"><span style="display:inline-block;width:110px;font-style:italic">Docker update</span>
|
||||
<input type="checkbox" name="docker_notify1"<?=($notify['docker_notify'] & 1)==1 ? ' checked' : ''?>>Browser
|
||||
<input type="checkbox" name="docker_notify2"<?=($notify['docker_notify'] & 2)==2 ? ' checked' : ''?>>Email
|
||||
<input type="checkbox" name="docker_notify3"<?=($notify['docker_notify'] & 4)==4 ? ' checked' : ''?>>Agents </span>
|
||||
|
||||
<span id="reportTitle" class="report" style="display:none"> </span>
|
||||
: <span class="report" style="display:none"><span style="display:inline-block;width:90px;font-style:italic">Array status</span>
|
||||
: <span class="report" style="display:none"><span style="display:inline-block;width:110px;font-style:italic">Array status</span>
|
||||
<input type="checkbox" name="report1"<?=($notify['report'] & 1)==1 ? ' checked' : ''?>>Browser
|
||||
<input type="checkbox" name="report2"<?=($notify['report'] & 2)==2 ? ' checked' : ''?>>Email
|
||||
<input type="checkbox" name="report3"<?=($notify['report'] & 4)==4 ? ' checked' : ''?>>Agents </span>
|
||||
|
||||
> Use the checkboxes above to select what and how notifications need to be given; by browser, by email and/or by a service.
|
||||
> <br><b>Tip:</b> you can use custom notification agents; just add them to "/boot/config/plugins/dynamix/notification/agents" directory and check 'Agents'.
|
||||
> Use the checkboxes above to select what and how notifications need to be given; by browser, by email and/or by a service.<br>
|
||||
> <b>Tip:</b> you can use custom notification agents; just add them to "/boot/config/plugins/dynamix/notification/agents" directory and check 'Agents'.
|
||||
|
||||
Notification entity:
|
||||
: <span style="display:inline-block;width:90px;font-style:italic">Notices</span>
|
||||
: <span style="display:inline-block;width:110px;font-style:italic">Notices</span>
|
||||
<input type="checkbox" class="checkbox" name="normal1"<?=($notify['normal'] & 1)==1 ? " checked $disabled" : $disabled?>>Browser
|
||||
<input type="checkbox" class="checkbox" name="normal2"<?=($notify['normal'] & 2)==2 ? " checked $disabled" : $disabled?>>Email
|
||||
<input type="checkbox" class="checkbox" name="normal3"<?=($notify['normal'] & 4)==4 ? " checked $disabled" : $disabled?>>Agents
|
||||
|
||||
|
||||
: <span style="display:inline-block;width:90px;font-style:italic">Warnings</span>
|
||||
: <span style="display:inline-block;width:110px;font-style:italic">Warnings</span>
|
||||
<input type="checkbox" class="checkbox" name="warning1"<?=($notify['warning'] & 1)==1 ? " checked $disabled" : $disabled?>>Browser
|
||||
<input type="checkbox" class="checkbox" name="warning2"<?=($notify['warning'] & 2)==2 ? " checked $disabled" : $disabled?>>Email
|
||||
<input type="checkbox" class="checkbox" name="warning3"<?=($notify['warning'] & 4)==4 ? " checked $disabled" : $disabled?>>Agents
|
||||
|
||||
|
||||
: <span style="display:inline-block;width:90px;font-style:italic">Alerts</span>
|
||||
: <span style="display:inline-block;width:110px;font-style:italic">Alerts</span>
|
||||
<input type="checkbox" class="checkbox" name="alert1"<?=($notify['alert'] & 1)==1 ? " checked $disabled" : $disabled?>>Browser
|
||||
<input type="checkbox" class="checkbox" name="alert2"<?=($notify['alert'] & 2)==2 ? " checked $disabled" : $disabled?>>Email
|
||||
<input type="checkbox" class="checkbox" name="alert3"<?=($notify['alert'] & 4)==4 ? " checked $disabled" : $disabled?>>Agents
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, Bergware International.
|
||||
* Copyright 2012, Andrew Hamer-Adams, http://www.pixeleyes.co.nz.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -139,6 +139,8 @@ case 'cron-init':
|
||||
@mkdir($archive,0755,true);
|
||||
$text = empty($notify['status']) ? "" : "# Generated array status check schedule:\n{$notify['status']} $docroot/plugins/dynamix/scripts/statuscheck &> /dev/null\n\n";
|
||||
parse_cron_cfg("dynamix", "status-check", $text);
|
||||
$text = empty($notify['unraidos']) ? "" : "# Generated unRAID OS update check schedule:\n{$notify['unraidos']} $docroot/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null\n\n";
|
||||
parse_cron_cfg("dynamix", "unraid-check", $text);
|
||||
$text = empty($notify['version']) ? "" : "# Generated plugins version check schedule:\n{$notify['version']} $docroot/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null\n\n";
|
||||
parse_cron_cfg("dynamix", "plugin-check", $text);
|
||||
$text = empty($notify['system']) ? "" : "# Generated system monitoring schedule:\n{$notify['system']} $docroot/plugins/dynamix/scripts/monitor &> /dev/null\n\n";
|
||||
|
||||
Reference in New Issue
Block a user