mirror of
https://github.com/unraid/webgui.git
synced 2026-03-13 06:19:47 -05:00
Merge branch 'master' of ssh://keys.lime-technology.com:60706/~/repositories/unraid_os
This commit is contained in:
@@ -34,6 +34,7 @@ function checkNetworkSettings() {
|
||||
form.DNS_SERVER1.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.DNS_SERVER2.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.DNS_SERVER3.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.MTU.disabled = disabled;
|
||||
}
|
||||
function checkBondingSettings() {
|
||||
var form = document.network_settings;
|
||||
@@ -86,7 +87,7 @@ Setup bridge:
|
||||
> (most consumer switches **do not**).
|
||||
>
|
||||
> Doing so will cause an "ARP broadcast storm" and can bring down your
|
||||
> entire network (unplugging all sever ethernet ports except one
|
||||
> entire network (unplugging all server ethernet ports except one
|
||||
> typically will restore your network).
|
||||
|
||||
Bridge name:
|
||||
@@ -166,6 +167,12 @@ DNS server 3:
|
||||
|
||||
> This is the DNS server to use when DNS Servers 1 and 2 are both down.
|
||||
|
||||
Desired MTU:
|
||||
: <input type="text" name="MTU" maxlength="5" value="<?=$var['MTU'];?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> This is the MTU size to use on all physical Ethernet interfaces participating in the network stack.
|
||||
> If left blank, the MTU will automatically be determined (most likely 1500).
|
||||
|
||||
|
||||
: <input type="submit" name="changeNetwork" value="Apply" <?=$disabled?>><input type="button" value="Done" onclick="done()"><?=$disabled ? "Array must be <strong>Stopped</strong> to change" : ""?>
|
||||
|
||||
|
||||
@@ -43,21 +43,21 @@ function prepareService(el, name) {
|
||||
});
|
||||
vars += $(this).attr('name')+'="'+include+"\"\n";
|
||||
});
|
||||
var cmd = (form.find('select[name=Enabled]').val()=='yes' ? 'enable' : 'disable');
|
||||
form.find('input[name=#arg\\[1\\]]').val(cmd);
|
||||
form.find('input[name=#arg\\[2\\]]').val(name+'.sh');
|
||||
form.find('input[name=text]').val(script.format(vars,'\n'));
|
||||
var cmd = (form.find('select[name="Enabled"]').val()=='yes' ? 'enable' : 'disable');
|
||||
form.find('input[name="#arg\\[1\\]"]').val(cmd);
|
||||
form.find('input[name="#arg\\[2\\]"]').val(name+'.sh');
|
||||
form.find('input[name="text"]').val(script.format(vars,'\n'));
|
||||
}
|
||||
function execCmd(cmd, name) {
|
||||
var form = $('#formExec');
|
||||
form.find('input[name=#arg\\[1\\]]').val(cmd);
|
||||
if (name) form.find('input[name=#arg\\[2\\]]').val(name+'.sh');
|
||||
form.find('input[name="#arg\\[1\\]"]').val(cmd);
|
||||
if (name) form.find('input[name="#arg\\[2\\]"]').val(name+'.sh');
|
||||
form.submit();
|
||||
}
|
||||
function testService(name) {
|
||||
var form = $('#formExec');
|
||||
form.find('input[name=#arg\\[1\\]]').val('test');
|
||||
form.find('input[name=#arg\\[2\\]]').val(name+'.sh');
|
||||
form.find('input[name="#arg\\[1\\]"]').val('test');
|
||||
form.find('input[name="#arg\\[2\\]"]').val(name+'.sh');
|
||||
form.append('<input type="hidden" name="#env[]" value="EVENT='+name+' test.">');
|
||||
form.append('<input type="hidden" name="#env[]" value="SUBJECT='+name+' test.">');
|
||||
form.append('<input type="hidden" name="#env[]" value="DESCRIPTION='+name+' test.">');
|
||||
@@ -68,13 +68,13 @@ function initDropdown() {
|
||||
if (openPage) {$("[id^='slot_']").dropdownchecklist({width:300,explicitClose:'...close'}); openPage = false;}
|
||||
}
|
||||
</script>
|
||||
<form method='POST' id="formExec" action='/update.php' target='progressFrame'>
|
||||
<input type='hidden' name='#command' value='/webGui/scripts/agent'>
|
||||
<input type='hidden' name='#arg[1]' value=''>
|
||||
<input type='hidden' name='#arg[2]' value=''>
|
||||
<form method="POST" id="formExec" action="/update.php" target="progressFrame">
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/agent">
|
||||
<input type="hidden" name="#arg[1]" value="">
|
||||
<input type="hidden" name="#arg[2]" value="">
|
||||
</form>
|
||||
<?
|
||||
$fields = array('Event','Subject','Timestamp','Description','Importance','Content');
|
||||
$fields = ['Event','Subject','Timestamp','Description','Importance','Content'];
|
||||
$xml_file = "webGui/include/NotificationAgents.xml";
|
||||
$xml = @simplexml_load_file($xml_file) or die("Failed to open $xml_file");
|
||||
foreach ($xml->Agent as $agent) {
|
||||
@@ -87,57 +87,58 @@ foreach ($xml->Agent as $agent) {
|
||||
} else {
|
||||
$file = $enabledAgent;
|
||||
}
|
||||
$values = array();
|
||||
$values = [];
|
||||
$script = "";
|
||||
if (is_file($file)) {
|
||||
preg_match("/[#]{6,100}([^#]*?)[#]{6,100}/si", file_get_contents($file), $match);
|
||||
if (isset($match[1])) {
|
||||
foreach (explode(PHP_EOL, $match[1]) as $line) {
|
||||
if (strpos($line, "=")) {
|
||||
list($k, $v) = explode("=",str_replace(array("\""), "", $line),2);
|
||||
list($k, $v) = explode("=",str_replace("\"", "", $line),2);
|
||||
$values[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (explode(PHP_EOL,(String) $agent->Script) as $line) if (trim($line)) $script .= trim($line)."{1}";
|
||||
echo "<div id='title' style='position:relative;margin:0px;top:-21px;'><span class='left'><img src='/plugins/dynamix/icons/".strtolower($name).".png' class='icon' style='height:16px;width:16px;'>$name</span><span class='status'>".(is_file($enabledAgent) ? "<span class='green'>Enabled</span>": "<span class='red'>Disabled</span>")."</span></div>";
|
||||
echo "<form method='POST' name='$name' action='/update.php' target='progressFrame'>";
|
||||
echo "<input type='hidden' name='#include' value='/webGui/include/update.file.php'>";
|
||||
echo "<input type='hidden' name='#file' value='$file'>";
|
||||
echo "<input type='hidden' name='#command' value='/webGui/scripts/agent'>";
|
||||
echo "<input type='hidden' name='#arg[1]' value=''>";
|
||||
echo "<input type='hidden' name='#arg[2]' value=''>";
|
||||
echo "<input type='hidden' name='text' value=''>";
|
||||
echo "<dl><dt>Agent function:</dt><dd><select name='Enabled' size='1'>";
|
||||
echo '<div id="title" style="position:relative;margin:0px;top:-21px;"><span class="left"><img src="/plugins/dynamix/icons/'.strtolower($name).'.png" class="icon" style="height:16px;width:16px;">'.$name.'</span><span class="status">'.(is_file($enabledAgent) ? '<span class="green">Enabled</span>' : '<span class="red">Disabled</span>').'</span></div>';
|
||||
echo '<form method="POST" name="'.$name.'" action="/update.php" target="progressFrame">';
|
||||
echo '<input type="hidden" name="#include" value="/webGui/include/update.file.php">';
|
||||
echo '<input type="hidden" name="#file" value="'.$file.'">';
|
||||
echo '<input type="hidden" name="#command" value="/webGui/scripts/agent">';
|
||||
echo '<input type="hidden" name="#arg[1]" value="">';
|
||||
echo '<input type="hidden" name="#arg[2]" value="">';
|
||||
echo '<input type="hidden" name="text" value="">';
|
||||
echo '<dl><dt>Agent function:</dt><dd><select name="Enabled" size="1">';
|
||||
echo mk_option(is_file($disabledAgent), 'no', 'Disabled');
|
||||
echo mk_option(is_file($enabledAgent), 'yes', 'Enabled');
|
||||
echo "</select></dd></dl>";
|
||||
echo "<script>scripts['$name']=".json_encode($script).";enabledAgents['$name']='$enabledAgent';disabledAgents['$name']='$disabledAgent';</script>";
|
||||
echo '</select></dd></dl>';
|
||||
echo '<script>scripts["'.$name.'"]='.json_encode($script).';enabledAgents["'.$name.'"]="'.$enabledAgent.'";disabledAgents["'.$name.'"]="'.$disabledAgent.'";</script>';
|
||||
$i = 1;
|
||||
foreach ($agent->Variables->children() as $var) {
|
||||
$vName = preg_replace('#\[([^\]]*)\]#', '<$1>', (string) $var);
|
||||
$vDesc = ucfirst(strtolower(preg_replace('#\[([^\]]*)\]#', '<$1>', (String) $var->attributes()->Desc)));
|
||||
$vDefault = preg_replace('#\[([^\]]*)\]#', '<$1>', (String) $var->attributes()->Default);
|
||||
$vHelp = preg_replace('#\[([^\]]*)\]#', '<$1>', (String) $var->attributes()->Help);
|
||||
echo "<dl><dt>${vDesc}:</dt><dd>";
|
||||
echo '<dl><dt>'.$vDesc.':</dt><dd>';
|
||||
if (preg_match('/title|message/', ${vDesc})) {
|
||||
echo "<select id=\"slot_$i\" name=\"${vName}\" size=\"1\" multiple style=\"display:none\">"; $i++;
|
||||
echo '<select id="slot_'.$i.'" name="'.$vName.'" size="1" multiple style="display:none">';
|
||||
$i++;
|
||||
$value = str_replace('\n',',',isset($values[$vName]) ? $values[$vName] : $vDefault);
|
||||
foreach ($fields as $field) echo mk_option_check($value,'$'.strtoupper($field),$field);
|
||||
echo "</select>";
|
||||
echo '</select>';
|
||||
} else {
|
||||
echo "<input type=\"text\" name=\"${vName}\" class=\"variable\" required value=\"".( isset($values[$vName]) ? $values[$vName] : $vDefault )."\">";
|
||||
echo '<input type="text" name="'.$vName.'" class="variable" required value="'.( isset($values[$vName]) ? $values[$vName] : $vDefault ).'">';
|
||||
}
|
||||
echo "</dd></dl>";
|
||||
if ($vHelp) echo "<blockquote class='inline_help'>$vHelp</blockquote>";
|
||||
echo '</dd></dl>';
|
||||
if ($vHelp) echo '<blockquote class="inline_help">'.$vHelp.'</blockquote>';
|
||||
}
|
||||
echo "<dl><dt> </dt><dd><input type='submit' value='Apply' onclick='prepareService(this, \"$name\")'>";
|
||||
echo "<input type='button' value='Done' onclick='done()'>";
|
||||
echo '<dl><dt> </dt><dd><input type="submit" value="Apply" onclick="prepareService(this, \''.$name.'\')">';
|
||||
echo '<input type="button" value="Done" onclick="done()">';
|
||||
if (is_file($file)) {
|
||||
echo "<input type='button' value='Delete' onclick='execCmd(\"delete\",\"$name\")'>";
|
||||
echo "<input type='button' value='Test' onclick='testService(\"$name\")'".($file==$enabledAgent ? ">" : " disabled>");
|
||||
echo '<input type="button" value="Delete" onclick="execCmd(\'delete\',\''.$name.'\')">';
|
||||
echo '<input type="button" value="Test" onclick="testService(\''.$name.'\')"'.($file==$enabledAgent ? '>' : ' disabled>');
|
||||
}
|
||||
echo "</dd></dl></form><div style='min-height:50px;'></div>";
|
||||
echo '</dd></dl></form><div style="min-height:50px;"></div>';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -160,14 +160,15 @@ case 'port':
|
||||
case 'main':
|
||||
$ports = explode(',',$_POST['ports']); $i = 0;
|
||||
foreach ($ports as $port) {
|
||||
unset($info);
|
||||
$mtu = file_get_contents("/sys/class/net/$port/mtu");
|
||||
if ($port=='bond0') {
|
||||
$ports[$i++] = exec("grep -Pom1 '^Bonding Mode: \K.+' /proc/net/bonding/bond0");
|
||||
$ports[$i++] = exec("grep -Pom1 '^Bonding Mode: \K.+' /proc/net/bonding/bond0").", mtu $mtu";
|
||||
} else if ($port=='lo') {
|
||||
$ports[$i++] = str_replace('yes','loopback',exec("ethtool lo|grep -Pom1 '^\s+Link detected: \K.+'"));
|
||||
} else {
|
||||
exec("ethtool $port|grep -Po '^\s+(Speed|Duplex): \K[^U\\n]+'",$info);
|
||||
$ports[$i++] = $info[0] ? "{$info[0]} - ".strtolower($info[1])." duplex" : "not connected";
|
||||
unset($info);
|
||||
exec("ethtool $port|grep -Po '^\s+(Speed|Duplex|Link\sdetected): \K[^U\\n]+'",$info);
|
||||
$ports[$i++] = (array_pop($info)=='yes' && $info[0]) ? "{$info[0]}, ".strtolower($info[1])." duplex, mtu $mtu" : "not connected";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -64,14 +64,14 @@ function resumeEvents(){
|
||||
});
|
||||
}
|
||||
function plus(value, label, last) {
|
||||
return value>0 ? (value+' '+label+(value!=1?'s':'')+(last?'':', ')) : '';
|
||||
return value>0 ? (value+label+(label.length>1&&value!=1?'s':'')+(last?'':', ')) : '';
|
||||
}
|
||||
function updateTime() {
|
||||
var now = new Date();
|
||||
days = parseInt(uptime/86400);
|
||||
hour = parseInt(uptime/3600%24);
|
||||
mins = parseInt(uptime/60%60);
|
||||
$('#uptime').html(((days|hour|mins)?plus(days,'day',(hour|mins)==0)+plus(hour,'hour',mins==0)+plus(mins,'minute',true):'less than a minute'));
|
||||
$('#uptime').html(((days|hour|mins)?plus(days,' day',(hour|mins)==0)+plus(hour,' hour',mins==0)+plus(mins,' minute',true):'less than a minute'));
|
||||
uptime += Math.round((now.getTime() - before.getTime())/1000);
|
||||
before = now;
|
||||
if (expiretime > 0) {
|
||||
@@ -82,7 +82,7 @@ function updateTime() {
|
||||
days = parseInt(remainingtime/86400);
|
||||
hour = parseInt(remainingtime/3600%24);
|
||||
mins = parseInt(remainingtime/60%60);
|
||||
$('#licenseexpire').html(' - '+((days|hour|mins)?plus(days,'day',(hour|mins)==0)+plus(hour,'hour',mins==0)+plus(mins,'minute',true):'less than a minute')+' remaining');
|
||||
$('#licenseexpire').html(' - '+((days|hour|mins)?plus(days,'d',(hour|mins)==0)+plus(hour,'h',mins==0)+plus(mins,'m',true):'less than a minute')+' remaining');
|
||||
}
|
||||
}
|
||||
setTimeout(updateTime,1000);
|
||||
|
||||
@@ -35,6 +35,7 @@ function in_parity_log($log,$timestamp) {
|
||||
function device_info(&$disk) {
|
||||
global $path, $var;
|
||||
$name = $disk['name'];
|
||||
$fancyname = $disk['type']=='New' ? $name : my_disk($name);
|
||||
$type = $disk['type']=='Flash' || $disk['type']=='New' ? $disk['type'] : 'Device';
|
||||
$action = strpos($disk['color'],'blink')===false ? 'down' : 'up';
|
||||
if ($var['fsState']=='Started' && $type!='Flash') {
|
||||
@@ -54,7 +55,7 @@ function device_info(&$disk) {
|
||||
case 'grey-off': $help = 'Device not present'; break;
|
||||
}
|
||||
$status = "$ctrl<a class='info nohand' onclick='return false'><img src='/webGui/images/{$disk['color']}.png' class='icon'><span>$help</span></a>";
|
||||
$link = strpos($disk['status'], 'DISK_NP')===false ? "<a href='$path/$type?name=$name' title='".my_disk($name)." Settings'>".my_disk($name)."</a>" : my_disk($name);
|
||||
$link = strpos($disk['status'], 'DISK_NP')===false ? "<a href='$path/$type?name=$name' title='".$fancyname." Settings'>".$fancyname."</a>" : $fancyname;
|
||||
return $status.$link;
|
||||
}
|
||||
function device_browse(&$disk) {
|
||||
@@ -236,13 +237,12 @@ function array_slots() {
|
||||
global $var;
|
||||
$min = max($var['sbNumDisks'], 3);
|
||||
$max = $var['MAX_ARRAYSZ'];
|
||||
$noparity2 = ($var['regTy']=='Pro')?0:1;
|
||||
$out = "<form method='POST' action='/update.htm' target='progressFrame'>";
|
||||
$out .= "<input type='hidden' name='changeSlots' value='Apply'>";
|
||||
$out .= "<select style='min-width:auto' name='SYS_ARRAY_SLOTS' onChange='this.form.submit()'>";
|
||||
for ($n=$min; $n<=$max; $n++) {
|
||||
$selected = ($n == $var['SYS_ARRAY_SLOTS'])? ' selected' : '';
|
||||
$out .= "<option value='$n'{$selected}>".($n-$noparity2)."</option>";
|
||||
$out .= "<option value='$n'{$selected}>$n</option>";
|
||||
}
|
||||
$out .= "</select></form>";
|
||||
return $out;
|
||||
|
||||
@@ -157,13 +157,14 @@ echo "$memory_installed MB (max. installable capacity $memory_maximum GB)".$sta
|
||||
exec("ifconfig -s|grep -Po '^(bond|eth)\d+'",$sPorts);
|
||||
$i = 0;
|
||||
foreach ($sPorts as $port) {
|
||||
$mtu = file_get_contents("/sys/class/net/$port/mtu");
|
||||
if ($i++) echo "<br><span style='width:94px; display:inline-block'> </span>";
|
||||
if ($port=='bond0') {
|
||||
echo "$port: ".exec("grep -Pom1 '^Bonding Mode: \K.+' /proc/net/bonding/bond0");
|
||||
echo "$port: ".exec("grep -Pom1 '^Bonding Mode: \K.+' /proc/net/bonding/bond0").", mtu $mtu";
|
||||
} else {
|
||||
unset($info);
|
||||
exec("ethtool $port|grep -Po '^\s+(Speed|Duplex): \K[^U\\n]+'",$info);
|
||||
echo $info[0] ? "$port: {$info[0]} - {$info[1]} Duplex" : "$port: not connected";
|
||||
exec("ethtool $port|grep -Po '^\s+(Speed|Duplex|Link\sdetected): \K[^U\\n]+'",$info);
|
||||
echo (array_pop($info)=='yes' && $info[0]) ? "$port: {$info[0]}, {$info[1]} Duplex, mtu $mtu" : "$port: not connected";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user