mirror of
https://github.com/unraid/webgui.git
synced 2026-03-11 21:38:50 -05:00
Merge upstream webgui changes from Ronald
This commit is contained in:
@@ -1,3 +1,29 @@
|
||||
#!/bin/bash
|
||||
# Just a wrapper.
|
||||
exec /usr/bin/docker "$@"
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2015-2016, Bergware International.
|
||||
* Copyright 2015-2016, Lime Technology
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
echo "<p style='text-align:center'><span class='error label'>Error</span><span class='warn label'>Warning</span><span class='system label'>System</span><span class='array label'>Array</span><span class='login label'>Login</span></p>\n";
|
||||
|
||||
require_once '/usr/local/emhttp/webGui/include/ColorCoding.php';
|
||||
|
||||
unset($argv[0]);
|
||||
$handle = popen('/usr/bin/docker '.implode(' ',$argv),'r');
|
||||
while (!feof($handle)) {
|
||||
$line = fgets($handle);
|
||||
$span = "span";
|
||||
foreach ($match as $type) foreach ($type['text'] as $text) if (preg_match("/$text/i",$line)) {$span = "span class='{$type['class']}'"; break 2;}
|
||||
echo "<$span>".htmlentities($line)."</span>";
|
||||
flush();
|
||||
}
|
||||
pclose($handle);
|
||||
?>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
?>
|
||||
<?
|
||||
// Invoke the plugin command with indicated method
|
||||
function plugin($method, $arg) {
|
||||
function plugin($method, $arg = '') {
|
||||
exec("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin $method $arg", $output, $retval);
|
||||
if ($retval != 0) return false;
|
||||
return implode("\n", $output);
|
||||
|
||||
@@ -50,9 +50,9 @@ foreach (glob("/var/log/plugins/*.plg", GLOB_NOSORT) as $plugin_link) {
|
||||
$filename = "/tmp/plugins/".basename($URL);
|
||||
if (file_exists($filename)) {
|
||||
$latest = plugin("version", $filename);
|
||||
if ($latest && strcmp($latest, $version) > 0) {
|
||||
if (strcmp($latest, $version) > 0) {
|
||||
$unRAID = plugin("unRAID", $filename);
|
||||
if (empty($unRAID) || strcmp($current['version'], $unRAID) >= 0) {
|
||||
if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) {
|
||||
$version_info .= "<br><span class='red-text'>{$latest}</span>";
|
||||
$status_info = make_link("update", basename($plugin_file));
|
||||
$changes_file = $filename;
|
||||
|
||||
@@ -13,29 +13,26 @@
|
||||
?>
|
||||
<?
|
||||
require_once '/usr/local/emhttp/webGui/include/Wrappers.php';
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -lbnPi4 -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K[\d]+')/update.htm?cmdStatus=apply");
|
||||
require_once '/usr/local/emhttp/plugins/dynamix.plugin.manager/include/PluginHelpers.php';
|
||||
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -iTCP -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K\d+')/update.htm?cmdStatus=apply");
|
||||
|
||||
$current = parse_ini_file('/etc/unraid-version');
|
||||
$notify = "/usr/local/emhttp/webGui/scripts/notify";
|
||||
$plugin = "/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin";
|
||||
$var = parse_ini_file("/var/local/emhttp/var.ini");
|
||||
$unraid = parse_plugin_cfg("dynamix",true);
|
||||
$server = strtoupper($var['NAME']);
|
||||
$output = $unraid['notify']['plugin'];
|
||||
$var = parse_ini_file('/var/local/emhttp/var.ini');
|
||||
$unraid = parse_plugin_cfg('dynamix', true);
|
||||
$notify = '/usr/local/emhttp/webGui/scripts/notify';
|
||||
$server = strtoupper($var['NAME']);
|
||||
$output = $unraid['notify']['plugin'];
|
||||
|
||||
exec("$plugin checkall >/dev/null");
|
||||
plugin("checkall");
|
||||
foreach (glob("/tmp/plugins/*.plg", GLOB_NOSORT) as $file) {
|
||||
$plg = basename($file);
|
||||
$old = exec("$plugin version '/var/log/plugins/$plg'");
|
||||
unset($new);
|
||||
exec("$plugin version '$file'", $new, $error);
|
||||
$old = plugin('version', "/var/log/plugins/$plg");
|
||||
$new = plugin('version', $file);
|
||||
// silently suppress bad download of PLG file
|
||||
if ($error) continue;
|
||||
$new = $new[0];
|
||||
if (strcmp($new, $old) > 0) {
|
||||
exec("$plugin unRAID '$file'", $unRAID);
|
||||
$unRAID = $unRAID[0];
|
||||
if (empty($unRAID) || strcmp($current['version'], $unRAID) >= 0) {
|
||||
$unRAID = plugin('unRAID', $file);
|
||||
if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) {
|
||||
$name = basename($file, '.plg');
|
||||
exec("$notify -e 'Plugin - $name [$new]' -s 'Notice [$server] - Version update $new' -d 'A new version of $name is available' -i 'normal $output' -x");
|
||||
}
|
||||
|
||||
@@ -145,3 +145,4 @@ $disk_order=($column=='disk'?$order:'A');
|
||||
<td colspan=<?=$show_disk?4:3?>><span><?=$objtext?>: <?=$dirtext?>, <?=$filetext?> <?=$totaltext?></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="button" value="Done" onclick="done('Browse')">
|
||||
|
||||
@@ -116,10 +116,10 @@ function settab(tab) {
|
||||
$.cookie(($.cookie('one')==null?'tab':'one'),tab,{path:'/'});
|
||||
<?endswitch;?>
|
||||
}
|
||||
function done(r) {
|
||||
var path = location.pathname;
|
||||
var x = path.indexOf("/",1);
|
||||
if (x!=-1) path = path.substring(0,x);
|
||||
function done(key) {
|
||||
var url = location.pathname.split('/');
|
||||
var path = '/'+url[1];
|
||||
if (key) for (var i=2; i<url.length; i++) if (url[i]==key) break; else path += '/'+url[i];
|
||||
$.removeCookie('one',{path:'/'});
|
||||
location.replace(path);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -lbnPi4 -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K[\d]+')/update.htm?cmdStatus=apply");
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -iTCP -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K\d+')/update.htm?cmdStatus=apply");
|
||||
|
||||
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
|
||||
$var = parse_ini_file("/var/local/emhttp/var.ini");
|
||||
@@ -329,13 +329,13 @@ if ($retval===0) {
|
||||
$item = 'system';
|
||||
$name = 'docker';
|
||||
$last = isset($saved[$item][$name]) ? $saved[$item][$name] : '';
|
||||
$warn = str_replace("%", "", exec("df /var/lib/docker|grep -Pom1 '\d+%'"));
|
||||
if (file_exists("/boot/config/docker.cfg")) {
|
||||
$cfg = parse_ini_file("/boot/config/docker.cfg");
|
||||
$info = "Docker utilization of image file {$cfg['DOCKER_IMAGE_FILE']}";
|
||||
} else
|
||||
$info = "Docker image file not specified";
|
||||
|
||||
$warn = exec("df /var/lib/docker|awk '/^\//{print $5*1}'");
|
||||
if ($warn>=$high1 && $high1>0) {
|
||||
if ($warn>$last) {
|
||||
exec("$notify -e \"Docker critical image disk utilization\" -s \"Alert [$server] - Docker image disk utilization of ${warn}%\" -d \"$info\" -i \"alert\"");
|
||||
|
||||
@@ -53,7 +53,7 @@ function generate_email($event, $subject, $description, $importance, $message) {
|
||||
|
||||
$subj = "{$ssmtp['Subject']}$subject";
|
||||
|
||||
$headers = array();
|
||||
$headers = [];
|
||||
$headers[] = "MIME-Version: 1.0";
|
||||
$headers[] = "X-Mailer: PHP/".phpversion();
|
||||
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
|
||||
@@ -65,7 +65,7 @@ function generate_email($event, $subject, $description, $importance, $message) {
|
||||
}
|
||||
$headers[] = "";
|
||||
|
||||
$body = array();
|
||||
$body = [];
|
||||
$body[] = "Event: $event";
|
||||
$body[] = "Subject: $subject";
|
||||
$body[] = "Description: $description";
|
||||
@@ -81,7 +81,7 @@ function generate_email($event, $subject, $description, $importance, $message) {
|
||||
}
|
||||
|
||||
function safe_filename($string) {
|
||||
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}");
|
||||
$special_chars = ["?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}"];
|
||||
$string = trim(str_replace($special_chars, "", $string));
|
||||
$string = preg_replace('~[^0-9a-z -_]~i', '', $string);
|
||||
$string = preg_replace('~[- ]~i', '_', $string);
|
||||
@@ -96,8 +96,8 @@ $unread = "{$notify['path']}/unread";
|
||||
$archive = "{$notify['path']}/archive";
|
||||
$agents_dir = "/boot/config/plugins/dynamix/notifications/agents";
|
||||
if (is_dir($agents_dir)) {
|
||||
$agents = array();
|
||||
foreach (array_diff(scandir($agents_dir), array('.','..')) as $p) {
|
||||
$agents = [];
|
||||
foreach (array_diff(scandir($agents_dir), ['.','..']) as $p) {
|
||||
if (is_executable("${agents_dir}/${p}")) $agents[] = "${agents_dir}/${p}";
|
||||
}
|
||||
} else {
|
||||
@@ -113,7 +113,7 @@ case 'init':
|
||||
case 'smtp-init':
|
||||
@mkdir($unread,0755,true);
|
||||
@mkdir($archive,0755,true);
|
||||
$conf = $array;
|
||||
$conf = [];
|
||||
$conf[] = "# Generated";
|
||||
$conf[] = "Root={$ssmtp['root']}";
|
||||
$domain = strtok($ssmtp['root'],'@');
|
||||
@@ -194,8 +194,8 @@ case 'add':
|
||||
break;
|
||||
|
||||
case 'get':
|
||||
$output = array();
|
||||
$json = array();
|
||||
$output = [];
|
||||
$json = [];
|
||||
$files = glob("$unread/*.notify", GLOB_NOSORT);
|
||||
usort($files, create_function('$a,$b', 'return filemtime($a)-filemtime($b);'));
|
||||
$i = 0;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
?>
|
||||
<?
|
||||
require_once '/usr/local/emhttp/webGui/include/Wrappers.php';
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -lbnPi4 -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K[\d]+')/update.htm?cmdStatus=apply");
|
||||
exec("wget -qO /dev/null 127.0.0.1:$(lsof -iTCP -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K\d+')/update.htm?cmdStatus=apply");
|
||||
|
||||
$notify = "/usr/local/emhttp/webGui/scripts/notify";
|
||||
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
|
||||
|
||||
Reference in New Issue
Block a user