Fixes for ZFS subpools

This commit is contained in:
bergware
2023-11-02 04:31:07 +01:00
parent 6bea55b8d2
commit af3a468654
3 changed files with 5 additions and 16 deletions
+3 -14
View File
@@ -12,26 +12,15 @@
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/webGui/include/Helpers.php";
$device = $_POST['device']??'';
$name = $_POST['name']??'';
$action = $_POST['action']??'';
$state = $_POST['state']??'';
$csrf = $_POST['csrf']??'';
function prefix($key) {
return preg_replace('/\d+$/','',$key);
}
function emhttpd($cmd) {
global $state, $csrf;
$ch = curl_init("http://127.0.0.1/update");
$options = [CURLOPT_UNIX_SOCKET_PATH => '/var/run/emhttpd.socket', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => "$cmd&startState=$state&csrf_token=$csrf"];
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
exec("emcmd $cmd");
}
switch ($device) {
case 'New':
emhttpd("cmdSpin{$action}={$name}");
@@ -57,7 +46,7 @@ default:
foreach ($disks as $disk) {
if (_var($disk,'status') != 'DISK_OK') continue;
$array = ($name=='array' && in_array(_var($disk,'type'),['Parity','Data']));
if ($array || prefix(_var($disk,'name'))==$name) emhttpd("cmdSpin{$action}="._var($disk,'name'));
if ($array || explode($tilde,prefix(_var($disk,'name')))[0]==$name) emhttpd("cmdSpin{$action}="._var($disk,'name'));
}
break;
}