mirror of
https://github.com/unraid/webgui.git
synced 2026-05-02 07:49:20 -05:00
Added 'preset current configuration' with New Config utility [4]
This commit is contained in:
@@ -13,16 +13,19 @@ Title="New Config"
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<style>
|
||||
span.indent{display:inline-block;width:170px;}
|
||||
</style>
|
||||
<?if (file_exists('/var/tmp/disks.ini')):?>
|
||||
<script>
|
||||
function assign(id,value) {
|
||||
var pairs = {changeDevice:'Apply'};
|
||||
pairs['slotId.'+id] = value;
|
||||
$.post('/update.htm',pairs);
|
||||
function assign(id,disk) {
|
||||
var pair = {changeDevice:'Apply'};
|
||||
pair['slotId.'+id] = disk;
|
||||
$.post('/update.htm',pair);
|
||||
}
|
||||
<?
|
||||
$disks = parse_ini_file('/var/tmp/disks.ini',true);
|
||||
foreach ($disks as $disk) if ($disk['type']!='Flash') echo "assign('{$disk['idx']}','{$disk['id']}');";
|
||||
foreach ($disks as $disk) echo "assign('{$disk['idx']}','{$disk['id']}');";
|
||||
unlink('/var/tmp/disks.ini');
|
||||
?>
|
||||
</script>
|
||||
@@ -33,16 +36,33 @@ if it were a fresh new server.
|
||||
This is useful when you have added or removed multiple drives and wish to rebuild parity based on
|
||||
the new configuration.
|
||||
|
||||
Use the *'Preset current configuration'* selection to populate the desired slots **after** the array has been reset. By default all slots are populated.
|
||||
|
||||
**DO NOT USE THIS UTILITY THINKING IT WILL REBUILD A FAILED DRIVE** - it will have the opposite
|
||||
effect of making it ***impossible*** to rebuild an existing failed drive - you have been warned!
|
||||
|
||||
<hr>
|
||||
<?$super = file_exists('/boot/config/super.dat')?>
|
||||
<form name="newConfig" method="POST" action="/update.htm" target="progressFrame">
|
||||
<?if ($var['fsState']=="Started" || !$super):?>
|
||||
<input type="submit" name="cmdInit" value="Apply" disabled><input type="button" value="Done" onclick="done()"><?if ($super):?>Array must be <strong><big>stopped</big></strong><?else:?>Array has been <strong><big>reset</big></strong> (please configure)<?endif;?>
|
||||
<?else:?>
|
||||
<span style="display:inline-block;width:160px" class="orange-text">Preset current configuration:</span><input name="preset" type="checkbox" checked><br>
|
||||
<span style="display:inline-block;width:160px"><input type="submit" name="cmdInit" value="Apply" onclick="$.post('/webGui/include/PrepareDisks.php',{preset:preset.checked})" disabled><input type="button" value="Done" onclick="done()"></span><input type="checkbox" onClick="cmdInit.disabled=!this.checked"><small>Yes I want to do this</small>
|
||||
<span class="indent">Preset current configuration:</span>
|
||||
<select name="preset" class="narrow">
|
||||
<?=mk_option('.','Parity|Data|Cache','All')?>
|
||||
<?=mk_option('.','Parity','Parity only')?>
|
||||
<?=mk_option('.','Parity|Data','Parity + Data')?>
|
||||
<?=mk_option('.','Parity|Cache','Parity + Cache')?>
|
||||
<?=mk_option('.','','None')?>
|
||||
</select>
|
||||
<br>
|
||||
<span class="indent"><input type="submit" name="cmdInit" value="Apply" onclick="$.post('/webGui/include/PrepareDisks.php',{preset:preset.value})" disabled><input type="button" value="Done" onclick="done()"></span><input type="checkbox" onClick="cmdInit.disabled=!this.checked"><small>Yes I want to do this</small>
|
||||
<?endif;?>
|
||||
</form>
|
||||
|
||||
> *Preset current configuration*
|
||||
|
||||
> + **All** - parity, data and cache disks are populated with the current disk assignment **after** an array reset
|
||||
> + **Parity only** - only parity disk(s) are populated, data and cache disks will be unassigned
|
||||
> + **Parity + Data** - parity and data disks are populated, cache disks will be unassigned
|
||||
> + **Parity + Cache** - parity and cache disks are populated, data disks will be unassigned
|
||||
> + **None** - parity, data and cache disks will all be unassigned
|
||||
|
||||
@@ -11,7 +11,20 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
function preset($disk) {
|
||||
return strpos($_POST['preset'],$disk['type'])!==false;
|
||||
}
|
||||
|
||||
@unlink('/boot/config/smart-one.cfg');
|
||||
@unlink('/boot/config/smart-all.cfg');
|
||||
if ($_POST['preset']=='true') @copy('/var/local/emhttp/disks.ini', '/var/tmp/disks.ini');
|
||||
if ($_POST['preset']) {
|
||||
$disks = parse_ini_file('/var/local/emhttp/disks.ini',true);
|
||||
$disks = array_filter($disks,'preset');
|
||||
$text = '';
|
||||
foreach ($disks as $disk => $block) {
|
||||
$text .= "[$disk]\n";
|
||||
foreach ($block as $key => $value) $text .= "$key=\"$value\"\n";
|
||||
}
|
||||
file_put_contents('/var/tmp/disks.ini',$text);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user