Merge pull request #889 from bergware/master

Bug fixes
This commit is contained in:
tom mortensen
2021-07-04 11:25:09 -07:00
committed by GitHub
5 changed files with 65 additions and 71 deletions

View File

@@ -19,6 +19,8 @@ require_once "$docroot/webGui/include/Preselect.php";
$unassigned = array_key_exists($name, $devs);
$disks = array_merge_recursive($disks, $devs);
$disk = &$disks[$name];
$dev = $disk['device'];
$id = $disk['id'];
$events = explode('|',$disk['smEvents'] ?? $var['smEvents'] ?? $numbers);
$bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c';
$yes = _('Yes');
@@ -52,8 +54,9 @@ $text = in_array($name,$pools) ? _('This will ERASE content of ALL devices in th
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-{$display['theme']}.css")?>">
<style>
input.option{display:none;width:40px}
span.devtext{display:none;font-weight:bold}
span.helptext{display:none;font-style:italic}
select.option{display:none}
span#devtext{display:none;font-weight:bold}
span#helptext{display:none;font-style:italic}
span.code{display:inline-block;width:186px}
</style>
<script>
@@ -61,19 +64,6 @@ if ($.cookie('deletepool')!=null) {
$.removeCookie('deletepool');
done();
}
function doDispatch(form) {
var fields = {};
<?if ($display['unit']=='F'):?>
var hottemp = $(form).find('input[name="<?=$disk['id']?>_hotTemp"]');
var maxtemp = $(form).find('input[name="<?=$disk['id']?>_maxTemp"]');
if (hottemp.val()>0) hottemp.val(Math.round((hottemp.val()-32)*5/9));
if (maxtemp.val()>0) maxtemp.val(Math.round((maxtemp.val()-32)*5/9));
<?endif;?>
fields['#cfg'] = "/boot/config/smart-one.cfg";
fields['#cleanup'] = true;
$(form).find('input[name^="<?=$disk['id']?>_"]').each(function(){fields[$(this).attr('name').replace(/\./g,'%3E')] = $(this).val(); $(this).prop('disabled',true);});
$.post('/webGui/include/Dispatcher.php',fields);
}
function prepareDeviceInfo(form) {
var events = [];
for (var i=0; i < <?=count($preselect)?>; i++) {
@@ -84,8 +74,12 @@ function prepareDeviceInfo(form) {
custom = custom.length ? custom.split(',') : [];
for (var i=0; i < custom.length; i++) events.push(custom[i].trim());
form.smEvents.value = events.join('|');
if (form.smEvents.value == '<?=implode('|',$events)?>') form.smEvents.value = '';
if (form.smEvents.value == '<?=$numbers?>') form.smEvents.value = '';
if (form.smLevel.value == 1.00) form.smLevel.value = '';
<?if ($display['unit']=='F'):?>
if (form.hotTemp.value>0) form.hotTemp.value = Math.round((form.hotTemp.value-32)*5/9);
if (form.maxTemp.value>0) form.maxTemp.value = Math.round((form.maxTemp.value-32)*5/9);
<?endif;?>
}
function setGlue(form,reset) {
var data =
@@ -95,7 +89,7 @@ function setGlue(form,reset) {
{glue:',',more:2,dev:0,type:'select',min11:'',min12:'auto',min21:'',min22:12,min23:16}, // sat
{glue:'' ,more:0,dev:0,type:''}, // scsi
{glue:',',more:1,dev:1,type:'',min1:0,max1:127}, // 3ware
{glue:',',more:3,dev:1,type:'',min1:0,max1:15,min2:0,max2:7,min3:0,max3:7}, // adaptec
{glue:',',more:3,dev:1,type:'',min1:0,max1:15,min2:0,max2:7,min3:0,max3:15}, // adaptec
{glue:'/',more:2,dev:1,type:'',min1:1,max1:128,min2:1,max2:8}, // areca
{glue:'/',more:3,dev:1,type:'',min1:1,max1:4,min2:1,max2:128,min3:1,max3:4}, // highpoint
{glue:'' ,more:1,dev:1,type:'',min1:0,max1:15}, // hp cciss
@@ -293,9 +287,9 @@ function freeSpace(val) {
}
$(function() {
<?if (count($sheets)>1):?>
var ctrl = "<span class='status <?=$tabbed?'vhshift':'vshift'?>'><span class='waitmsg fa fa-circle-o-notch fa-span fa-fw' style='display:none;margin-right:8px'></span><a href='/Main/Device?name=<?=$prev?>' title='previous device'>";
var ctrl = "<span class='status <?=$tabbed?'vhshift':'vshift'?>'><span class='waitmsg fa fa-circle-o-notch fa-span fa-fw' style='display:none;margin-right:8px'></span><a href='/Main/Device?name=<?=$prev?>' title='_(previous device)_'>";
ctrl += "<button type='button' style='margin-right:4px' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-left fa-fw'></i></button></a>";
ctrl += "<a href='/Main/Device?name=<?=$next?>' title='next device'><button type='button' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-right fa-fw'></i></button></a></span>";
ctrl += "<a href='/Main/Device?name=<?=$next?>' title='_(next device)_'><button type='button' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-right fa-fw'></i></button></a></span>";
<?if ($tabbed):?>
$('.tabs').append(ctrl);
<?else:?>
@@ -354,7 +348,7 @@ _(Identification)_:
<?else:?>
_(Identification)_:
: <?=my_id($disk['id'])?>&nbsp;(<?=$disk['device']?>)
: <?=my_id($id)?>&nbsp;(<?=$dev?>)
<?endif;?>
<?if (!$unassigned):?>
@@ -421,7 +415,6 @@ _(File system type)_:
</select>
<?endif;?>
<?if (in_array($name,$pools)):?>
<?$disabled = $var['fsState']!="Stopped" ? "disabled" : ""?>
_(Enable user share assignment)_:
: <select id="shareEnabled" name="diskShareEnabled.<?=$disk['idx']?>" onchange="freeSpace(this.value)" <?=$disabled?>>
@@ -436,7 +429,6 @@ _(Minimum free space)_:
:info_free_space_help:
<?endif;?>
_(Warning disk utilization threshold)_ (%):
: <input type="number" min="0" max="100" name="diskWarning.<?=$disk['idx']?>" class="narrow" value="<?=strlen($disk['warning'])?$disk['warning']:''?>" placeholder="<?=$display['warning']?>">
@@ -570,9 +562,9 @@ _(btrfs scrub status)_:
<?endif?>
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>_(Check Filesystem Status)_</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'btrfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$disk['id']?>')">
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'btrfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$id?>')">
<?if (maintenance_mode()):?>
<?exec("$docroot/webGui/scripts/btrfs_check status /dev/{$disk['deviceSb']} {$disk['id']}", $check_status, $retval)?>
<?exec("$docroot/webGui/scripts/btrfs_check status /dev/{$disk['deviceSb']} {$id}", $check_status, $retval)?>
_(btrfs check status)_:
: <?echo "<pre id='btrfs-check'>".implode("\n", $check_status)."</pre>"?>
@@ -581,7 +573,7 @@ _(btrfs check status)_:
<input type="hidden" name="#command" value="/webGui/scripts/btrfs_check">
<input type="hidden" name="#arg[1]" value="start">
<input type="hidden" name="#arg[2]" value="/dev/<?=$disk['deviceSb']?>">
<input type="hidden" name="#arg[3]" value="<?=$disk['id']?>">
<input type="hidden" name="#arg[3]" value="<?=$id?>">
&nbsp;
: <input type="submit" value="_(Check)_"><input type="text" name="#arg[4]" class="narrow" maxlength="256" value="--readonly"> _(Options (see Help))_
@@ -592,7 +584,7 @@ _(btrfs check status)_:
<input type="hidden" name="#command" value="/webGui/scripts/btrfs_check">
<input type="hidden" name="#arg[1]" value="cancel">
<input type="hidden" name="#arg[2]" value="/dev/<?=$disk['deviceSb']?>">
<input type="hidden" name="#arg[3]" value="<?=$disk['id']?>">
<input type="hidden" name="#arg[3]" value="<?=$id?>">
&nbsp;
: <input type="submit" value="_(Cancel)_"> *_(Running)_*
@@ -616,9 +608,9 @@ _(btrfs check status)_:
<?endif;?>
<?if (strpos($disk['fsType'],"reiserfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>_(Check Filesystem Status)_</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'rfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$disk['id']?>')">
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'rfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$id?>')">
<?if (maintenance_mode()):?>
<?exec("$docroot/webGui/scripts/reiserfs_check status /dev/{$disk['deviceSb']} {$disk['id']}", $check_status, $retval)?>
<?exec("$docroot/webGui/scripts/reiserfs_check status /dev/{$disk['deviceSb']} {$id}", $check_status, $retval)?>
_(reiserfsck status)_:
: <?echo "<pre id='rfs-check'>".implode("\n", $check_status)."</pre>"?>
@@ -627,7 +619,7 @@ _(reiserfsck status)_:
<input type="hidden" name="#command" value="/webGui/scripts/reiserfs_check">
<input type="hidden" name="#arg[1]" value="start">
<input type="hidden" name="#arg[2]" value="/dev/<?=$disk['deviceSb']?>">
<input type="hidden" name="#arg[3]" value="<?=$disk['id']?>">
<input type="hidden" name="#arg[3]" value="<?=$id?>">
&nbsp;
: <input type="submit" value="_(Check)_"><input type="text" name="#arg[4]" class="narrow" maxlength="256" value=""> _(Options (see Help))_
@@ -638,7 +630,7 @@ _(reiserfsck status)_:
<input type="hidden" name="#command" value="/webGui/scripts/reiserfs_check">
<input type="hidden" name="#arg[1]" value="cancel">
<input type="hidden" name="#arg[2]" value="/dev/<?=$disk['deviceSb']?>">
<input type="hidden" name="#arg[3]" value="<?=$disk['id']?>">
<input type="hidden" name="#arg[3]" value="<?=$id?>">
&nbsp;
: <input type="submit" value="_(Cancel)_"> *_(Running)_*
@@ -656,9 +648,9 @@ _(reiserfsck status)_:
<?endif;?>
<?if (strpos($disk['fsType'],"xfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>_(Check Filesystem Status)_</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'xfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$disk['id']?>')">
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'xfs-check-<?=$tag?>','/dev/<?=$disk['deviceSb']?> <?=$id?>')">
<?if (maintenance_mode()):?>
<?exec("$docroot/webGui/scripts/xfs_check status /dev/{$disk['deviceSb']} {$disk['id']}", $check_status, $retval)?>
<?exec("$docroot/webGui/scripts/xfs_check status /dev/{$disk['deviceSb']} {$id}", $check_status, $retval)?>
_(xfs_repair status)_:
: <?echo "<pre id='xfs-check'>".implode("\n", $check_status)."</pre>"?>
@@ -667,7 +659,7 @@ _(xfs_repair status)_:
<input type="hidden" name="#command" value="/webGui/scripts/xfs_check">
<input type="hidden" name="#arg[1]" value="start">
<input type="hidden" name="#arg[2]" value="/dev/<?=$disk['deviceSb']?>">
<input type="hidden" name="#arg[3]" value="<?=$disk['id']?>">
<input type="hidden" name="#arg[3]" value="<?=$id?>">
&nbsp;
: <input type="submit" value="_(Check)_"><input type="text" name="#arg[4]" class="narrow" maxlength="256" value="-n"> _(Options (see Help))_
@@ -697,20 +689,20 @@ _(xfs_repair status)_:
<?if (strpos($disks[$name]['status'],'_NP')===false):?>
<div id="title"><span class="left"><i class="title fa fa-plus-square"></i>_(SMART Settings)_</span></div>
<form markdown="1" name="smart_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="doDispatch(this);prepareDeviceInfo(this)">
<input type="hidden" name="#file" value="/boot/config/smart-one.cfg">
<form markdown="1" name="smart_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareDeviceInfo(this)">
<input type="hidden" name="#file" value="/boot/config/smart-one.cfg">
<input type="hidden" name="#include" value="webGui/include/update.smart.php">
<input type="hidden" name="#section" value="<?=$disk['id']?>">
<input type="hidden" name="#section" value="<?=$id?>">
<input type="hidden" name="#cleanup" value="true">
<input type="hidden" name="smEvents" value="">
<input type="hidden" name="smGlue" value="<?=$var['smGlue']?>">
<input type="hidden" name="smGlue" value="<?=$var['smGlue']?>">
_(Warning disk temperature threshold)_ (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="<?=$disk['id']?>_hotTemp" class="narrow" value="<?=strlen($disk['hotTemp'])?displayTemp($disk['hotTemp']):''?>" placeholder="<?=displayTemp($display['hot'])?>">
: <input type="number" min="0" max="300" name="hotTemp" class="narrow" value="<?=strlen($disk['hotTemp'])?displayTemp($disk['hotTemp']):''?>" placeholder="<?=displayTemp($display['hot'])?>">
:info_warning_temp_help:
_(Critical disk temperature threshold)_ (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="<?=$disk['id']?>_maxTemp" class="narrow" value="<?=strlen($disk['maxTemp'])?displayTemp($disk['maxTemp']):''?>" placeholder="<?=displayTemp($display['max'])?>">
: <input type="number" min="0" max="300" name="maxTemp" class="narrow" value="<?=strlen($disk['maxTemp'])?displayTemp($disk['maxTemp']):''?>" placeholder="<?=displayTemp($display['max'])?>">
:info_critical_temp_help:
@@ -753,10 +745,10 @@ _(SMART controller type)_:
<?=mk_option($disk['smType'], "-d marvell", "Marvell")?>
<?=mk_option($disk['smType'], "-d megaraid", "MegaRAID")?>
</select>
<input type="text" name="smPort1" value="<?=$disk['smPort1']?>" class="option"><select name="smPort1" class="narrow" style="display:none" disabled></select>
<input type="text" name="smPort2" value="<?=$disk['smPort2']?>" class="option"><select name="smPort2" class="narrow" style="display:none" disabled></select>
<input type="text" name="smPort3" value="<?=$disk['smPort3']?>" class="option"><select name="smPort3" class="narrow" style="display:none" disabled></select><span id="devtext" class="devtext">/dev/</span>
<input type="text" name="smDevice" value="<?=$disk['smDevice']??''?>" class="option" placeholder="<?=htmlspecialchars($disk['device'])?>"><span id="helptext" class="helptext">enter disk index and device name as applicable to your controller</span>
<input type="text" name="smPort1" value="<?=$disk['smPort1']?>" class="option"><select name="smPort1" class="narrow option" disabled></select>
<input type="text" name="smPort2" value="<?=$disk['smPort2']?>" class="option"><select name="smPort2" class="narrow option" disabled></select>
<input type="text" name="smPort3" value="<?=$disk['smPort3']?>" class="option"><select name="smPort3" class="narrow option" disabled></select><span id="devtext">/dev/</span>
<input type="text" name="smDevice" value="<?=$disk['smDevice']?>" class="option" placeholder="<?=$dev?>"><span id="helptext">_(enter disk index and device name as applicable to your controller)_</span>
:info_controller_type_help:

View File

@@ -38,30 +38,32 @@ function find_tasks() {
sort($tasks);
return $tasks;
}
$tasks = find_tasks();
$internalip = $eth0['IPADDR:0'];
$keyfile = @file_get_contents($var['regFILE']);
$tasks = find_tasks();
$internalip = $eth0['IPADDR:0'];
$rebindip = "192.168.42.42";
$keyfile = @file_get_contents($var['regFILE']);
if ($keyfile !== false) $keyfile = base64_encode($keyfile);
$certFile = "/boot/config/ssl/certs/certificate_bundle.pem";
$certFile = "/boot/config/ssl/certs/certificate_bundle.pem";
$certPresent = file_exists("$certFile");
$certSubject="";
if ($certPresent) $certSubject = exec("/usr/bin/openssl x509 -noout -subject -nameopt multiline -in $certFile | /usr/bin/sed -n 's/ *commonName *= //p'");
$isLEcert = $certPresent && preg_match('/.*\.unraid\.net$/', $certSubject);
$certSubject = $certPresent ? exec("openssl x509 -noout -subject -nameopt multiline -in $certFile 2>/dev/null|sed -n 's/ *commonName *= //p'") : "";
$isLEcert = $certPresent && preg_match('/.*\.unraid\.net$/', $certSubject);
if ($isLEcert) {
exec("/usr/bin/openssl x509 -checkend 2592000 -noout -in $certFile",$arrout,$retval_expired);
$rebindtest_ip = exec("/usr/bin/host -4 rebindtest.unraid.net |sed -n 's/.*has address //p'");
$dnsRebindingProtection = ($rebindtest_ip != "192.168.42.42");
exec("openssl x509 -checkend 2592000 -noout -in $certFile 2>/dev/null", $arrout,$retval_expired);
$rebindtest_ip = exec("host -4 rebindtest.unraid.net 2>/dev/null|sed -n 's/.*has address //p'");
$dnsRebindingProtection = ($rebindtest_ip != $rebindip);
if (!$dnsRebindingProtection) {
$certtest_ip = exec("/usr/bin/host -4 $certSubject |sed -n 's/.*has address //p'");
$certtest_ip = exec("host -4 $certSubject 2>/dev/null|sed -n 's/.*has address //p'");
$dnsValid = ($certtest_ip == $internalip);
}
// more: similar test for "www.$certSubject" dns valid goes here
}
$provisionlabel = $isLEcert ? _('Renew') : _('Provision');
$provisionlabel = $isLEcert ? _('Renew') : _('Provision');
$disabled_provision = $keyfile===false || ($isLEcert && $retval_expired===0) ? 'disabled' : '';
$disabled_updatedns = $keyfile!==false && $isLEcert ? '' : 'disabled';
$disabled_delete = $certPresent && $var['USE_SSL']!='auto' ? '' : 'disabled';
$disabled_auto = $isLEcert && !$dnsRebindingProtection && $dnsValid ? '' : 'disabled';
$disabled_delete = $certPresent && $var['USE_SSL']!='auto' ? '' : 'disabled';
$disabled_auto = $isLEcert && !$dnsRebindingProtection && $dnsValid ? '' : 'disabled';
// Get ports in use
$portsInUse = [];
@@ -139,10 +141,10 @@ function checkPorts(form,provision) {
swal({title:'_(Port out of range)_',text:sprintf('_(Port %s is out of range (minimum 1 maximum 65535))_',range.join(', ')),type:'error',showCancelButton:false,confirmButtonText:"_(OK)_"});
return false;
}
// if ( list.length > 0 ) {
// swal({title:'_(Port already in use)_',text:sprintf('_(Port %s is already in use by other services)_',list.join(', ')),type:'error',showCancelButton:false,confirmButtonText:"_(OK)_"});
// return false;
// }
if ( list.length > 0 ) {
swal({title:'_(Port already in use)_',text:sprintf('_(Port %s is already in use by other services)_',list.join(', ')),type:'error',showCancelButton:false,confirmButtonText:"_(OK)_"});
return false;
}
if ( duplicates.length > 0 ) {
swal({title:'_(Duplicate port entered)_',text:sprintf('_(Port %s is duplicated)_',duplicates.join(', ')),type:'error',showCancelButton:false,confirmButtonText:"_(OK)_"});
return false;

View File

@@ -118,16 +118,16 @@ _(Mover logging)_:
:mover_logging_help:
<?endif;?>
<? if ($setup == true):?>
&nbsp;
: <input type="submit" name="changeMover" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
<? endif; ?>
<?if ($setup):?>
<?if ($pool_devices):?>
&nbsp;
<?if (file_exists("/var/run/mover.pid")):?>
: <input type="submit" name="cmdStartMover" value="_(Move now)_" disabled> _(Mover is running)_.
<?if (file_exists('/var/run/mover.pid')):?>
<input type="submit" name="cmdStartMover" value="_(Move now)_" disabled> _(Mover is running)_
<?else:?>
: <input type="submit" name="cmdStartMover" value="_(Move now)_"> _(Click to invoke the Mover)_.
<input type="submit" name="cmdStartMover" value="_(Move now)_"> _(Click to invoke the Mover)_
<?endif;?>
<?else:?>
&nbsp;
<?endif;?>
: <input type="submit" name="changeMover" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
<?endif;?>
</form>

View File

@@ -19,7 +19,7 @@ Cond="file_exists('/boot/config/network-rules.cfg')"
$cfg = '/boot/config/network-rules.cfg';
function strip($item) {
[$key,$val] = my_explode('"',$item);
[$key,$val] = explode('"',$item);
return $val;
}

View File

@@ -63,7 +63,7 @@ while (true) {
$echo[] = "$port\0$rx_speed\0$tx_speed\0$rxd\0$txd";
// interface general information
$mtu = port_get_contents("$net/$port/mtu");
$link = true; //port_get_contents("$net/$port/carrier")==1;
$link = port_get_contents("$net/$port/carrier")==1;
if (substr($port,0,4)=='bond') {
if ($link) {
$bond_mode = file_exists("$bond/$port") ? str_replace('Bonding Mode: ','',@file("$bond/$port",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)[1]) : '---';