mirror of
https://github.com/unraid/webgui.git
synced 2026-04-24 02:58:57 -05:00
Merge pull request #415 from bergware/master
Apply syslinux changes to all menus except safe mode
This commit is contained in:
@@ -3,8 +3,8 @@ Title="Array Operation"
|
||||
Tag="snowflake-o"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, Bergware International.
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2012-2018, 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,
|
||||
@@ -65,6 +65,12 @@ function status_indicator() {
|
||||
}
|
||||
echo "<a class='info nohand' onclick='return false'><img src='/webGui/images/{$var['mdColor']}.png' class='icon'><span>$help</span></a>";
|
||||
}
|
||||
function missing_cache() {
|
||||
global $disks;
|
||||
$missing = false;
|
||||
foreach ($disks as $disk) if ($disk['type']=='Cache') $missing |= (strpos($disk['status'],'_MISSING')!==false);
|
||||
return $missing;
|
||||
}
|
||||
?>
|
||||
<style>
|
||||
tr#copy,tr#file{display:none}
|
||||
@@ -353,6 +359,10 @@ $(function(){
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Unclean shutdown detected.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will bring the array on-line and start <strong>Parity-Check</strong>.
|
||||
<br><input type="checkbox" name="optionCorrect" value="correct" checked><small>Write corrections to parity</small></td></tr>
|
||||
<? elseif (missing_cache()):?>
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Missing Cache disk.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will remove the missing cache disk and then bring the array on-line.
|
||||
<br><input type="checkbox" name="confirmStart" value="OFF" onclick="$('#cmdStart').prop('disabled',!arrayOps.confirmStart.checked)"><small>Yes I want to do this</small></td></tr>
|
||||
<? else:?>
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will bring the array on-line.</td></tr>
|
||||
@@ -375,22 +385,22 @@ $(function(){
|
||||
check_encryption();
|
||||
break;
|
||||
case "DISABLE_DISK":?>
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Missing disk.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will disable the missing disk and then bring the array on-line.
|
||||
<br>Install a replacement disk as soon as possible.
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Missing disk.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)" disabled></td>
|
||||
<td><strong>Start</strong> will disable the missing disk and then bring the array on-line. Install a replacement disk as soon as possible.
|
||||
<br><input type="checkbox" name="confirmStart" value="OFF" onclick="$('#cmdStart').prop('disabled',!arrayOps.confirmStart.checked)"><small>Yes I want to do this</small></td></tr>
|
||||
<? maintenance_mode();
|
||||
check_encryption();
|
||||
break;
|
||||
case "RECON_DISK":?>
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Replacement disk installed.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.
|
||||
<td><strong>Start</strong> will start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.</td></tr>
|
||||
<? maintenance_mode();
|
||||
check_encryption();
|
||||
break;
|
||||
case "SWAP_DSBL":
|
||||
if ($var['fsCopyPrcnt']=="100"):?>
|
||||
<tr><td><?status_indicator()?><span class="strong big">Stopped</span>. Upgrading disk/swapping parity.</td><td><input type="button" id="cmdStart" value="Start" onclick="prepareInput(this.form)"></td>
|
||||
<td><strong>Start</strong> will expand the file system of the data disk (if possible); then bring the array on-line and start Data-Rebuild.
|
||||
<td><strong>Start</strong> will expand the file system of the data disk (if possible); then bring the array on-line and start Data-Rebuild.</td></tr>
|
||||
<? maintenance_mode();
|
||||
check_encryption();
|
||||
else:?>
|
||||
|
||||
@@ -32,7 +32,7 @@ $pages['Vars']['text'] = '...';
|
||||
$text = '...';
|
||||
ksort($site);
|
||||
ksort($GLOBALS);
|
||||
if (isset($GLOBALS[_SERVER][PHP_AUTH_PW])) $GLOBALS[_SERVER][PHP_AUTH_PW]="***";
|
||||
if (isset($GLOBALS['_SERVER']['PHP_AUTH_PW'])) $GLOBALS['_SERVER']['PHP_AUTH_PW'] = "***";
|
||||
echo ($display['resize'] ? "<pre class='up' style='display:none'>" : "<pre class='up'>").htmlspecialchars(print_r($GLOBALS,true))."</pre>";
|
||||
?>
|
||||
<input type="button" value="Done" onclick="done()">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 149 B |
@@ -280,7 +280,7 @@ function read_disk($name, $part) {
|
||||
function show_totals($text) {
|
||||
global $var, $display, $sum;
|
||||
echo "<tr class='tr_last'>";
|
||||
echo "<td><img src='/webGui/images/sum.png' class='icon'>Total</td>";
|
||||
echo "<td></td>";
|
||||
echo "<td>$text</td>";
|
||||
echo "<td>".($sum['count']>0 ? my_temp(round($sum['temp']/$sum['count'],1)) : '*')."</td>";
|
||||
echo "<td><span class='diskio'>".my_diskio($sum['ioReads'])."</span><span class='number'>".my_number($sum['numReads'])."</span></td>";
|
||||
@@ -321,16 +321,17 @@ function array_slots() {
|
||||
$out .= "</select></form>";
|
||||
return $out;
|
||||
}
|
||||
function cache_slots() {
|
||||
function cache_slots($disabled) {
|
||||
global $var;
|
||||
$off = $disabled ? ' disabled' : '';
|
||||
$min = $var['cacheSbNumDisks'];
|
||||
$max = $var['MAX_CACHESZ'];
|
||||
$out = "<form method='POST' action='/update.htm' target='progressFrame'>";
|
||||
$out .= "<input type='hidden' name='csrf_token' value='{$var['csrf_token']}'>";
|
||||
$out .= "<input type='hidden' name='changeSlots' value='apply'>";
|
||||
$out .= "<select class='narrow' name='SYS_CACHE_SLOTS' onChange='this.form.submit()'>";
|
||||
$out .= "<select class='narrow' name='SYS_CACHE_SLOTS' onChange='this.form.submit()'{$off}>";
|
||||
for ($n=$min; $n<=$max; $n++) {
|
||||
$option = $n ? $n : 'none';
|
||||
$option = $n ?: 'none';
|
||||
$selected = ($n == $var['SYS_CACHE_SLOTS'])? ' selected' : '';
|
||||
$out .= "<option value='$n'{$selected}>$option</option>";
|
||||
}
|
||||
@@ -373,12 +374,21 @@ case 'flash':
|
||||
break;
|
||||
case 'cache':
|
||||
$cache = array_filter($disks,'cache_only');
|
||||
$tmp = '/var/tmp/cache_log.tmp';
|
||||
foreach ($cache as $disk) $crypto |= $disk['luksState']!=0 || vfs_luks($disk['fsType']);
|
||||
if ($var['fsState']=='Stopped') {
|
||||
foreach ($cache as $disk) array_offline($disk);
|
||||
echo "<tr class='tr_last'><td><img src='/webGui/images/sum.png' class='icon'>Slots:</td><td colspan='9'>".cache_slots()."</td><td></td></tr>";
|
||||
$log = file_exists($tmp) ? parse_ini_file($tmp) : [];
|
||||
$off = false;
|
||||
foreach ($cache as $disk) {
|
||||
array_offline($disk);
|
||||
if (isset($log[$disk['name']])) $off |= ($log[$disk['name']]!=$disk['id']); else $log[$disk['name']] = $disk['id'];
|
||||
}
|
||||
$data = []; foreach ($log as $key => $value) $data[] = "$key=\"$value\"";
|
||||
file_put_contents($tmp,implode("\n",$data));
|
||||
echo "<tr class='tr_last'><td><img src='/webGui/images/sum.png' class='icon'>Slots:</td><td colspan='9'>".cache_slots($off)."</td><td></td></tr>";
|
||||
} else {
|
||||
foreach ($cache as $disk) array_online($disk);
|
||||
@unlink($tmp);
|
||||
if ($display['total'] && $var['cacheSbNumDisks']>1) show_totals('Pool of '.my_word($var['cacheNumDevices']).' devices');
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
function scan($area, $text) {
|
||||
return strpos($area,$text)!==false;
|
||||
function scan($line, $text) {
|
||||
return stripos($line,$text)!==false;
|
||||
}
|
||||
|
||||
$name = urldecode($_POST['name']);
|
||||
@@ -127,52 +127,50 @@ case 'is':
|
||||
$cfg = '/boot/syslinux/syslinux.cfg';
|
||||
$syslinux = file($cfg, FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($syslinux);
|
||||
$menu = $i = 0;
|
||||
$cmd = [];
|
||||
// find the default section
|
||||
$make = false;
|
||||
$file = "/var/tmp/$name.tmp";
|
||||
$isolcpus = file_get_contents($file);
|
||||
if ($isolcpus != '') {
|
||||
$numbers = explode(',',$isolcpus);
|
||||
sort($numbers,SORT_NUMERIC);
|
||||
$isolcpus = $previous = array_shift($numbers);
|
||||
$range = false;
|
||||
// convert sequential numbers to a range
|
||||
foreach ($numbers as $number) {
|
||||
if ($number == $previous+1) {
|
||||
$range = true;
|
||||
} else {
|
||||
if ($range) {$isolcpus .= '-'.$previous; $range = false;}
|
||||
$isolcpus .= ','.$number;
|
||||
}
|
||||
$previous = $number;
|
||||
}
|
||||
if ($range) $isolcpus .= '-'.$previous;
|
||||
$isolcpus = "isolcpus=$isolcpus";
|
||||
}
|
||||
unlink($file);
|
||||
$i = 0;
|
||||
while ($i < $size) {
|
||||
if (scan($syslinux[$i],'label ')) {
|
||||
// find sections and exclude safemode
|
||||
if (scan($syslinux[$i],'label ') && !scan($syslinux[$i],'safe mode') && !scan($syslinux[$i],'safemode')) {
|
||||
$n = $i + 1;
|
||||
// find the current requested setting
|
||||
while (!scan($syslinux[$n],'label ') && $n < $size) {
|
||||
if (scan($syslinux[$n],'menu default')) $menu = 1;
|
||||
// find the current command
|
||||
if (scan($syslinux[$n],'append')) {$cmd = preg_split('/\s+/',trim($syslinux[$n])); break;}
|
||||
if (scan($syslinux[$n],'append ')) {
|
||||
$cmd = preg_split('/\s+/',trim($syslinux[$n]));
|
||||
// replace an existing setting
|
||||
for ($c = 1; $c < count($cmd); $c++) if (scan($cmd[$c],'isolcpus')) {$make |= ($cmd[$c]!=$isolcpus); $cmd[$c] = $isolcpus; break;}
|
||||
// or insert a new setting
|
||||
if ($c==count($cmd) && $isolcpus) {array_splice($cmd,-1,0,$isolcpus); $make = true;}
|
||||
$syslinux[$n] = ' '.str_replace(' ',' ',implode(' ',$cmd));
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
if ($menu) break; else $i = $n - 1;
|
||||
$i = $n - 1;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($cmd) {
|
||||
// modify the current command
|
||||
$file = "/var/tmp/$name.tmp";
|
||||
// read new isolcpus assignments
|
||||
$isolcpus = file_get_contents($file); unlink($file);
|
||||
if ($isolcpus != '') {
|
||||
$numbers = explode(',',$isolcpus);
|
||||
sort($numbers,SORT_NUMERIC);
|
||||
$isolcpus = $previous = array_shift($numbers);
|
||||
$range = false;
|
||||
// convert sequential numbers to a range
|
||||
foreach ($numbers as $number) {
|
||||
if ($number == $previous+1) {
|
||||
$range = true;
|
||||
} else {
|
||||
if ($range) {$isolcpus .= '-'.$previous; $range = false;}
|
||||
$isolcpus .= ','.$number;
|
||||
}
|
||||
$previous = $number;
|
||||
}
|
||||
if ($range) $isolcpus .= '-'.$previous;
|
||||
$isolcpus = "isolcpus=$isolcpus";
|
||||
}
|
||||
// replace an existing setting
|
||||
for ($c = 0; $c < count($cmd); $c++) if (scan($cmd[$c],'isolcpus')) {$cmd[$c] = $isolcpus; break;}
|
||||
// or insert a new setting
|
||||
if ($c == count($cmd) && $isolcpus) array_splice($cmd,-1,0,$isolcpus);
|
||||
$syslinux[$n] = ' '.str_replace(' ',' ',implode(' ',$cmd));
|
||||
file_put_contents($cfg, implode("\n",$syslinux)."\n");
|
||||
}
|
||||
if ($make) file_put_contents($cfg, implode("\n",$syslinux)."\n");
|
||||
$reply = ['success' => $name];
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user