diff --git a/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php b/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php index 69ed7c9f8..0c8a7e56f 100644 --- a/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php +++ b/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php @@ -12,7 +12,8 @@ */ ?> getAllInfo(); $docker = []; $null = '0.0.0.0'; -$autostart = @file($autostart_file,FILE_IGNORE_NEW_LINES) ?: []; +$autostart = (array)@file($autostart_file,FILE_IGNORE_NEW_LINES); $names = array_map('var_split',$autostart); function my_lang_time($text) { diff --git a/emhttp/plugins/dynamix.docker.manager/include/DockerUpdate.php b/emhttp/plugins/dynamix.docker.manager/include/DockerUpdate.php index 3b4647624..ee0233318 100644 --- a/emhttp/plugins/dynamix.docker.manager/include/DockerUpdate.php +++ b/emhttp/plugins/dynamix.docker.manager/include/DockerUpdate.php @@ -1,7 +1,7 @@ &1|grep -o 'OK'")=='OK'; diff --git a/emhttp/plugins/dynamix.docker.manager/include/Events.php b/emhttp/plugins/dynamix.docker.manager/include/Events.php index 1ac064cbd..a16c1d418 100644 --- a/emhttp/plugins/dynamix.docker.manager/include/Events.php +++ b/emhttp/plugins/dynamix.docker.manager/include/Events.php @@ -1,7 +1,7 @@ getAllInfo(true); diff --git a/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container b/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container index 533670ee8..55bc7205c 100755 --- a/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container +++ b/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container @@ -12,7 +12,7 @@ */ ?> diff --git a/emhttp/plugins/dynamix.plugin.manager/include/Downgrade.php b/emhttp/plugins/dynamix.plugin.manager/include/Downgrade.php index a3a92ba2a..9742e7bbc 100644 --- a/emhttp/plugins/dynamix.plugin.manager/include/Downgrade.php +++ b/emhttp/plugins/dynamix.plugin.manager/include/Downgrade.php @@ -11,8 +11,7 @@ */ ?> false]); break; } - exec("mkdir -p /tmp/plugins"); @unlink("/tmp/plugins/$plugin"); $url = plugin("pluginURL","/boot/config/plugins/$plugin"); download_url($url,"/tmp/plugins/$plugin"); - $changes = plugin("changes","/tmp/plugins/$plugin"); $alerts = plugin("alert","/tmp/plugins/$plugin"); $version = plugin("version","/tmp/plugins/$plugin"); @@ -69,7 +66,6 @@ switch ($_POST['action']) { } else { @unlink('/tmp/plugins/my_alerts.txt'); } - $update = false; if ( strcmp($version,$installedVersion) > 0 ) { $unraid = parse_ini_file("/etc/unraid-version"); @@ -77,17 +73,14 @@ switch ($_POST['action']) { } $updateMessage = sprintf(_("%s: An update is available."),$name); $linkMessage = sprintf(_("Click here to install version %s"),$version); - echo json_encode(["updateAvailable"=>$update, "version"=>$version, "min"=>$min, "alert"=>$alerts, "changes"=>$changes, "installedVersion"=>$installedVersion, "updateMessage"=>$updateMessage, "linkMessage"=>$linkMessage]); break; case 'addRebootNotice': $message = htmlspecialchars(trim($_POST['message'])); - if ( ! $message ) break; - - $existing = @file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: []; + if (!$message) break; + $existing = (array)@file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $existing[] = $message; - file_put_contents("/tmp/reboot_notifications",implode("\n",array_unique($existing))); break; diff --git a/emhttp/plugins/dynamix.plugin.manager/scripts/checkall b/emhttp/plugins/dynamix.plugin.manager/scripts/checkall index eee96871d..7c46a8ed5 100755 --- a/emhttp/plugins/dynamix.plugin.manager/scripts/checkall +++ b/emhttp/plugins/dynamix.plugin.manager/scripts/checkall @@ -12,8 +12,7 @@ */ ?> 3 ? '' : share; - box.find('#target').val(path+auto).change(); + box.find('#target').val(path).change(); }); box.find('#target2').attr('value',file2).fileTreeAttach(null,null,function(path){ - var bits = path.substr(1).split('/'); - var auto = bits.length>3 ? '' : share; - box.find('#target2').val(path+auto).change(); + box.find('#target2').val(path).change(); }); box.dialog({ title: "_(Select ISOs for CDROMs)_", @@ -183,9 +179,7 @@ function getisoimage(uuid,dev,bus,file){ var box = $("#dialogWindow"); box.html($("#templateISO").html()); box.find('#target').attr('value',file).fileTreeAttach(null,null,function(path){ - var bits = path.substr(1).split('/'); - var auto = bits.length>3 ? '' : share; - box.find('#target').val(path+auto).change(); + box.find('#target').val(path).change(); }); box.dialog({ title: "_(Select ISO)_", @@ -217,6 +211,7 @@ function VMClone(uuid, name){ document.getElementById("Overwrite").checked = true; box.dialog({ title: "_(VM Clone)_", + height: 'auto', width: 600, resizable: false, modal: true, @@ -263,6 +258,7 @@ function selectsnapshot(uuid, name ,snaps, opt, getlist,state){ document.getElementById("targetsnapfspc").checked = true; box.dialog({ title: optiontext, + height: 'auto', width: 600, resizable: false, modal: true, @@ -335,6 +331,7 @@ function selectblock(uuid, name, snaps, opt, getlist, state){ } box.dialog({ title: optiontext, + height: 'auto', width: 600, resizable: false, modal: true, diff --git a/emhttp/plugins/dynamix.vm.manager/VMTemplates.page b/emhttp/plugins/dynamix.vm.manager/VMTemplates.page index 96b2d3819..c9d610bac 100644 --- a/emhttp/plugins/dynamix.vm.manager/VMTemplates.page +++ b/emhttp/plugins/dynamix.vm.manager/VMTemplates.page @@ -5,7 +5,8 @@ Markdown="false" --- $arrTemplate): diff --git a/emhttp/plugins/dynamix.vm.manager/include/Fedora-virtio-isos.php b/emhttp/plugins/dynamix.vm.manager/include/Fedora-virtio-isos.php index 7aaddf74d..cf53cb6ed 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/Fedora-virtio-isos.php +++ b/emhttp/plugins/dynamix.vm.manager/include/Fedora-virtio-isos.php @@ -1,7 +1,7 @@ "; + $cdstr = $cdromcount." / 2"; echo ""; echo "$image$vm
"._($status)." $snapshotstcount
"; echo "$desc"; @@ -248,7 +248,7 @@ foreach ($vms as $vm) { $title = _('Insert CD'); $changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\",\"--select\")"; $disk = _("No CD image inserted in to drive"); - echo "$disk$bus$capacity$allocation$boot"; + echo "$disk$bus$capacity$allocation$boot"; } } echo ""; diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMManager.php b/emhttp/plugins/dynamix.vm.manager/include/VMManager.php index a56278de2..435e537f2 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMManager.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMManager.php @@ -1,7 +1,7 @@ saveXML(); - */ +**/ + class Array2XML { private static $xml = null; private static $encoding = 'UTF-8'; @@ -160,8 +161,7 @@ private static $encoding = 'UTF-8'; } } - - $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; + $docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'); require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt.php"; require_once "$docroot/webGui/include/Custom.php"; @@ -756,13 +756,13 @@ private static $encoding = 'UTF-8'; $arrWhitelistGPUClassIDregex = '/^(0001|03)/'; $arrWhitelistAudioClassIDregex = '/^(0403)/'; - # "System peripheral [0880]" "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" -pff "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" + # "System peripheral [0880]" "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" -pff "Global unichip corp. [1ac1]" "Coral Edge Tpu [089a]" # typeid productid # file is csv typeid:productid # if (is_file("/boot/config/VMPCIOverride.cfg")) { $arrWhiteListOverride = str_getcsv(file_get_contents("/boot/config/VMPCIOverride.cfg")) ; - } + } $arrWhiteListOverride[] = "0880:089a" ; $arrValidPCIDevices = []; @@ -1498,7 +1498,7 @@ private static $encoding = 'UTF-8'; */ $uuid = $lv->domain_get_uuid($clone) ; write("addLog\0".htmlspecialchars(_("Checking if clone exists"))); - if ($uuid) { $arrResponse = ['error' => _("Clone VM name already inuse")]; return false ;} + if ($uuid) { $arrResponse = ['error' => _("Clone VM name already inuse")]; return false ;} #VM must be shutdown. $res = $lv->get_domain_by_name($vm); $dom = $lv->domain_get_info($res); @@ -1518,18 +1518,18 @@ private static $encoding = 'UTF-8'; $pathinfo = pathinfo($file) ; $capacity = $capacity + $disk["capacity"] ; } - + #Check free space. write("addLog\0".htmlspecialchars("Checking for free space")); $dirfree = disk_free_space($pathinfo["dirname"]) ; - $sourcedir = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($pathinfo["dirname"])." 2>/dev/null")); + $sourcedir = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($pathinfo["dirname"])." 2>/dev/null")); $repdir = str_replace('/mnt/user/', "/mnt/$sourcedir/", $pathinfo["dirname"]); $repdirfree = disk_free_space($repdir) ; $reflink = true ; $capacity *= 1 ; if ($free == "yes" && $repdirfree < $capacity) { $reflink = false ;} - if ($free == "yes" && $dirfree < $capacity) { write("addLog\0".htmlspecialchars(_("Insufficent storage for clone"))); return false ;} + if ($free == "yes" && $dirfree < $capacity) { write("addLog\0".htmlspecialchars(_("Insufficent storage for clone"))); return false ;} #Clone XML $uuid = $lv->domain_get_uuid($vm) ; @@ -1567,17 +1567,17 @@ private static $encoding = 'UTF-8'; chgrp($clonedir, 'users'); } write("addLog\0".htmlspecialchars("Checking for image files")); - if ($file_exists && $overwrite != "yes") { write("addLog\0".htmlspecialchars(_("New image file names exist and Overwrite is not allowed"))); return( false) ; } + if ($file_exists && $overwrite != "yes") { write("addLog\0".htmlspecialchars(_("New image file names exist and Overwrite is not allowed"))); return( false) ; } #Create duplicate files. foreach($file_clone as $diskid => $disk) { $target = $disk['target'] ; - $source = $disk['source'] ; - if ($target == $source) { write("addLog\0".htmlspecialchars(_("New image file is same as old"))); return( false) ; } - $sourcerealdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($source)." 2>/dev/null")); + $source = $disk['source'] ; + if ($target == $source) { write("addLog\0".htmlspecialchars(_("New image file is same as old"))); return( false) ; } + $sourcerealdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($source)." 2>/dev/null")); $reptgt = str_replace('/mnt/user/', "/mnt/$sourcerealdisk/", $target); $repsrc = str_replace('/mnt/user/', "/mnt/$sourcerealdisk/", $source); - + $cmdstr = "cp --reflink=always '$repsrc' '$reptgt'" ; if ($reflink == true) { $refcmd = $cmdstr ; } else {$refcmd = false; } $cmdstr = "rsync -ahPIXS --out-format=%f --info=flist0,misc0,stats0,name1,progress2 '$source' '$target'" ; @@ -1592,23 +1592,23 @@ private static $encoding = 'UTF-8'; file_put_contents("/tmp/clonexml" ,$xml) ; $rtn = $lv->domain_define($xml) ; return($rtn) ; - + } - + function compare_creationtime($a, $b) { return strnatcmp($a['creationtime'], $b['creationtime']); - } + } function compare_creationtimelt($a, $b) { return $a['creationtime'] < $b['creationtime']; - } + } function getvmsnapshots($vm) { $snaps=array() ; $dbpath = "/etc/libvirt/qemu/snapshot/$vm" ; $snaps_json = file_get_contents($dbpath."/snapshots.db") ; - $snaps = json_decode($snaps_json,true) ; + $snaps = json_decode($snaps_json,true) ; if (is_array($snaps)) uasort($snaps,'compare_creationtime') ; return $snaps ; } @@ -1618,7 +1618,7 @@ private static $encoding = 'UTF-8'; $dbpath = "/etc/libvirt/qemu/snapshot/$vm" ; if (!is_dir($dbpath)) mkdir($dbpath) ; $snaps_json = file_get_contents($dbpath."/snapshots.db") ; - $snaps = json_decode($snaps_json,true) ; + $snaps = json_decode($snaps_json,true) ; $snapshot_res=$lv->domain_snapshot_lookup_by_name($vm,$name) ; $snapshot_xml=$lv->domain_snapshot_get_xml($snapshot_res) ; $a = simplexml_load_string($snapshot_xml) ; @@ -1639,10 +1639,10 @@ private static $encoding = 'UTF-8'; exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ; foreach($output as $key => $line) { $line=str_replace("image: ","",$line) ; - $output[$key] = $line ; + $output[$key] = $line ; } - $snaps[$vmsnap]['backing'][$disk["device"]] = $output ; + $snaps[$vmsnap]['backing'][$disk["device"]] = $output ; $rev = "r".$disk["device"] ; $reversed = array_reverse($output) ; $snaps[$vmsnap]['backing'][$rev] = $reversed ; @@ -1655,7 +1655,7 @@ private static $encoding = 'UTF-8'; if (array_key_exists(0 , $b["disks"]["disk"])) $snaps[$vmsnap]["disks"]= $b["disks"]["disk"]; else $snaps[$vmsnap]["disks"][0]= $b["disks"]["disk"]; - + $value = json_encode($snaps,JSON_PRETTY_PRINT) ; file_put_contents($dbpath."/snapshots.db",$value) ; } @@ -1665,7 +1665,7 @@ private static $encoding = 'UTF-8'; $dbpath = "/etc/libvirt/qemu/snapshot/$vm" ; if (!is_dir($dbpath)) mkdir($dbpath) ; $snaps_json = file_get_contents($dbpath."/snapshots.db") ; - $snaps = json_decode($snaps_json,true) ; + $snaps = json_decode($snaps_json,true) ; foreach($snaps as $vmsnap=>$snap) $disks =$lv->get_disk_stats($vm) ; @@ -1675,10 +1675,10 @@ private static $encoding = 'UTF-8'; exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ; foreach($output as $key => $line) { $line=str_replace("image: ","",$line) ; - $output[$key] = $line ; + $output[$key] = $line ; } - - $snaps[$vmsnap]['backing'][$disk["device"]] = $output ; + + $snaps[$vmsnap]['backing'][$disk["device"]] = $output ; $rev = "r".$disk["device"] ; $reversed = array_reverse($output) ; $snaps[$vmsnap]['backing'][$rev] = $reversed ; @@ -1688,7 +1688,7 @@ private static $encoding = 'UTF-8'; $snaps[$vmsnap]["parent"]= $parendfileinfo["extension"]; $snaps[$vmsnap]["parent"] = str_replace("qcow2",'',$snaps[$vmsnap]["parent"]) ; if (isset($parentfind[1]) && !isset($parentfind[2])) $snaps[$vmsnap]["parent"]="Base" ; - + $value = json_encode($snaps,JSON_PRETTY_PRINT) ; $res = $lv->get_domain_by_name($vm); #if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_create_snapshot($lv->domain_get_uuid($vm),$name) ; @@ -1697,12 +1697,12 @@ private static $encoding = 'UTF-8'; #Remove any NVRAMs that are no longer valid. # Get uuid $vmuuid = $lv->domain_get_uuid($vm) ; - #Get list of files - #$filepath = "/etc/libvirt/qemu/nvram/'.$uuid*" ; #$snapshotname" - $filepath = "/etc/libvirt/qemu/nvram/$vmuuid*" ; #$snapshotname" + #Get list of files + #$filepath = "/etc/libvirt/qemu/nvram/'.$uuid*" ; #$snapshotname" + $filepath = "/etc/libvirt/qemu/nvram/$vmuuid*" ; #$snapshotname" $nvram_files=glob($filepath) ; foreach($nvram_files as $key => $nvram_file) { - if ($nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi.fd" || $nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi-tpm.fd" ) unset($nvram_files[$key]) ; + if ($nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi.fd" || $nvram_file == "/etc/libvirt/qemu/nvram/$vmuuid"."_VARS-pure-efi-tpm.fd" ) unset($nvram_files[$key]) ; foreach ($snaps as $snapshotname => $snap) { $tpmfilename = "/etc/libvirt/qemu/nvram/".$vmuuid.$snapshotname."_VARS-pure-efi-tpm.fd" ; $nontpmfilename = "/etc/libvirt/qemu/nvram/".$vmuuid.$snapshotname."_VARS-pure-efi.fd" ; @@ -1712,7 +1712,7 @@ private static $encoding = 'UTF-8'; } foreach ($nvram_files as $nvram_file) unlink($nvram_file) ; - + file_put_contents($dbpath."/snapshots.db",$value) ; } @@ -1720,7 +1720,7 @@ private static $encoding = 'UTF-8'; global $lv ; $dbpath = "/etc/libvirt/qemu/snapshot/$vm" ; $snaps_json = file_get_contents($dbpath."/snapshots.db") ; - $snaps = json_decode($snaps_json,true) ; + $snaps = json_decode($snaps_json,true) ; unset($snaps[$name]) ; $value = json_encode($snaps,JSON_PRETTY_PRINT) ; file_put_contents($dbpath."/snapshots.db",$value) ; @@ -1730,19 +1730,19 @@ private static $encoding = 'UTF-8'; function vm_snapshot($vm,$snapshotname, $snapshotdesc, $free = "yes", $memorysnap = "yes") { global $lv ; - + #Get State $res = $lv->get_domain_by_name($vm); $dom = $lv->domain_get_info($res); $state = $lv->domain_state_translate($dom['state']); - - #Get disks for --diskspec + + #Get disks for --diskspec $disks =$lv->get_disk_stats($vm) ; $diskspec = "" ; $capacity = 0 ; if ($snapshotname == "--generate") $name= "S" . date("YmdHis") ; else $name=$snapshotname ; if ($snapshotdesc != "") $snapshotdesc = " --description '$snapshotdesc'" ; - + foreach($disks as $disk) { $file = $disk["file"] ; $pathinfo = pathinfo($file) ; @@ -1754,38 +1754,38 @@ private static $encoding = 'UTF-8'; #get memory $mem = $lv->domain_get_memory_stats($vm) ; $memory = $mem[6] ; - + if ($memorysnap = "yes") $memspec = ' --memspec "'.$pathinfo["dirname"].'/memory'.$name.'.mem",snapshot=external' ; else $memspec = "" ; $cmdstr = "virsh snapshot-create-as '$vm' --name '$name' $snapshotdesc --atomic" ; - - + + if ($state == "running") { $cmdstr .= " --live ".$memspec.$diskspec ; $capacity = $capacity + $memory ; - + } else { - $cmdstr .= " --disk-only ".$diskspec ; + $cmdstr .= " --disk-only ".$diskspec ; } - + #Check free space. $dirfree = disk_free_space($pathinfo["dirname"]) ; - + $capacity *= 1 ; - - if ($free == "yes" && $dirfree < $capacity) { $arrResponse = ['error' => _("Insufficent Storage for Snapshot")]; return $arrResponse ;} - + + if ($free == "yes" && $dirfree < $capacity) { $arrResponse = ['error' => _("Insufficent Storage for Snapshot")]; return $arrResponse ;} + #Copy nvram if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_create_snapshot($lv->domain_get_uuid($vm),$name) ; $xmlfile = $pathinfo["dirname"]."/".$name.".running" ; file_put_contents("/tmp/xmltst", "$xmlfile" ) ; if ($state == "running") exec("virsh dumpxml '$vm' > ".escapeshellarg($xmlfile),$outxml,$rtnxml) ; - + $output= [] ; $test = false ; if ($test) exec($cmdstr." --print-xml 2>&1",$output,$return) ; else exec($cmdstr." 2>&1",$output,$return) ; - if (strpos(" ".$output[0],"error") ) { + if (strpos(" ".$output[0],"error") ) { $arrResponse = ['error' => substr($output[0],6) ] ; } else { $arrResponse = ['success' => true] ; @@ -1803,8 +1803,8 @@ private static $encoding = 'UTF-8'; $disks =$lv->get_disk_stats($vm) ; switch ($snapslist[$snap]['state']) { - case "shutoff": - case "running": + case "shutoff": + case "running": #VM must be shutdown. $res = $lv->get_domain_by_name($vm); $dom = $lv->domain_get_info($res); @@ -1817,7 +1817,7 @@ private static $encoding = 'UTF-8'; $xmlobj = custom::createArray('domain',$strXML) ; # Process disks and update path. - $disks=($snapslist[$snap]['disks']) ; + $disks=($snapslist[$snap]['disks']) ; foreach ($disks as $disk) { $diskname = $disk["@attributes"]["name"] ; if ($diskname == "hda" || $diskname == "hdb") continue ; @@ -1859,7 +1859,7 @@ private static $encoding = 'UTF-8'; $item++ ; } } - + uasort($snapslist,'compare_creationtimelt') ; foreach($snapslist as $s) { $name = $s['name'] ; @@ -1877,13 +1877,13 @@ private static $encoding = 'UTF-8'; # Restore Memory. $makerun = true ; - if ($makerun == true) exec("virsh restore ".escapeshellarg($memoryfile)) ; - #exec("virsh restore $memoryfile") ; - } + if ($makerun == true) exec("virsh restore ".escapeshellarg($memoryfile)) ; + #exec("virsh restore $memoryfile") ; + } #Delete Metadata only. - if ($actionmeta == "yes") { + if ($actionmeta == "yes") { $ret = delete_snapshots_database("$vm","$name") ; - } + } if (is_file($memoryfile) && $action == "yes") unlink($memoryfile) ; if (is_file($xmlfile) && $action == "yes") unlink($xmlfile) ; if ($s['name'] == $snap) break ; @@ -1891,11 +1891,11 @@ private static $encoding = 'UTF-8'; #if VM was started restart. if ($state == 'running' && $snapslist[$snap]['state'] != "running") { $arrResponse = $lv->domain_start($vm) ; - } - + } + if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_revert_snapshot($lv->domain_get_uuid($vm),$name) ; break ; - + } $arrResponse = ['success' => true] ; return($arrResponse) ; @@ -1914,9 +1914,9 @@ private static $encoding = 'UTF-8'; exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ; foreach($output as $key => $line) { $line=str_replace("image: ","",$line) ; - $output[$key] = $line ; + $output[$key] = $line ; } - $snaps[$vm][$disk["device"]] = $output ; + $snaps[$vm][$disk["device"]] = $output ; $rev = "r".$disk["device"] ; $reversed = array_reverse($output) ; $snaps[$vm][$rev] = $reversed ; @@ -1927,7 +1927,7 @@ private static $encoding = 'UTF-8'; } $snapdisks= $snapslist[$snap]['disks'] ; - + foreach ($snapdisks as $diskkey => $snapdisk) { $diskname = $snapdisk["@attributes"]["name"] ; if ($diskname == "hda" || $diskname == "hdb") continue ; @@ -1940,7 +1940,7 @@ private static $encoding = 'UTF-8'; { if (!isset($snaps[$vm]["r".$diskname][$item])) break ; $newpath = $snaps[$vm]["r".$diskname][$item] ; - if (is_file($path)) $data .= "$newpath
" ; + if (is_file($path)) $data .= "$newpath
" ; $item++ ; } @@ -1958,7 +1958,7 @@ private static $encoding = 'UTF-8'; } return($data) ; } - + function vm_snapremove($vm, $snap) { global $lv ; @@ -1973,10 +1973,10 @@ private static $encoding = 'UTF-8'; exec("qemu-img info --backing-chain -U $file | grep image:",$output) ; foreach($output as $key => $line) { $line=str_replace("image: ","",$line) ; - $output[$key] = $line ; + $output[$key] = $line ; } - $snaps[$vm][$disk["device"]] = $output ; + $snaps[$vm][$disk["device"]] = $output ; $rev = "r".$disk["device"] ; $reversed = array_reverse($output) ; $snaps[$vm][$rev] = $reversed ; @@ -1988,7 +1988,7 @@ private static $encoding = 'UTF-8'; $xmlobj = custom::createArray('domain',$strXML) ; # Process disks. - $disks=($snapslist[$snap]['disks']) ; + $disks=($snapslist[$snap]['disks']) ; foreach ($disks as $disk) { $diskname = $disk["@attributes"]["name"] ; if ($diskname == "hda" || $diskname == "hdb") continue ; @@ -1999,30 +1999,30 @@ private static $encoding = 'UTF-8'; return ($data) ; } } - + $disks=($snapslist[$snap]['disks']) ; foreach ($disks as $disk) { $diskname = $disk["@attributes"]["name"] ; if ($diskname == "hda" || $diskname == "hdb") continue ; $path = $disk["source"]["@attributes"]["file"] ; if (is_file($path)) { - if(!unlink("$path")) { + if(!unlink("$path")) { $data = ["error" => "Unable to remove image file $path"] ; return ($data) ; - } + } } } - # Delete NVRAM + # Delete NVRAM if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_delete_snapshot($lv->domain_get_uuid($vm),$snap) ; $ret = delete_snapshots_database("$vm","$snap") ; - + if(!$ret) $data = ["error" => "Unable to remove snap metadata $snap"] ; else $data = ["success => 'true"] ; - + return($data) ; } @@ -2059,7 +2059,7 @@ OPTIONS blockcommit Debian --path /mnt/user/domains/Debian/vdisk1.S20230513120410qcow2 --verbose --pivot --delete */ # Error if VM Not running. - + $snapslist= getvmsnapshots($vm) ; $disks =$lv->get_disk_stats($vm) ; @@ -2069,7 +2069,7 @@ OPTIONS if ($pivot == "yes") $cmdstr .= " --pivot " ; if ($action == "yes") $cmdstr .= " --delete " ; # Process disks and update path. - $snapdisks=($snapslist[$snap]['disks']) ; + $snapdisks=($snapslist[$snap]['disks']) ; if ($base != "--base" && $base != "") { #get file name from snapshot. $snapdisks=($snapslist[$base]['disks']) ; @@ -2094,15 +2094,15 @@ OPTIONS } $error = execCommand_nchan($cmdstr,$path) ; - if (!$error) { + if (!$error) { $arrResponse = ['error' => "Process Failed"] ; return($arrResponse) ; } else { $arrResponse = ['success' => true] ; } - + } - # Delete NVRAM + # Delete NVRAM #if (!empty($lv->domain_get_ovmf($res))) $nvram = $lv->nvram_delete_snapshot($lv->domain_get_uuid($vm),$snap) ; refresh_snapshots_database($vm) ; @@ -2149,9 +2149,9 @@ OPTIONS exec("qemu-img info --backing-chain -U '$file' | grep image:",$output) ; foreach($output as $key => $line) { $line=str_replace("image: ","",$line) ; - $output[$key] = $line ; + $output[$key] = $line ; } - $snaps[$vm][$disk["device"]] = $output ; + $snaps[$vm][$disk["device"]] = $output ; $rev = "r".$disk["device"] ; $reversed = array_reverse($output) ; $snaps[$vm][$rev] = $reversed ; @@ -2166,7 +2166,7 @@ OPTIONS $cmdstr = "virsh blockpull '$vm' --path '$path' --verbose --pivot --delete" ; $cmdstr = "virsh blockpull '$vm' --path '$path' --verbose --wait " ; # Process disks and update path. - $snapdisks=($snapslist[$snap]['disks']) ; + $snapdisks=($snapslist[$snap]['disks']) ; if ($base != "--base" && $base != "") { #get file name from snapshot. $snapdisks=($snapslist[$base]['disks']) ; @@ -2183,8 +2183,8 @@ OPTIONS $error = execCommand_nchan($cmdstr,$path) ; - - if (!$error) { + + if (!$error) { $arrResponse = ['error' => "Process Failed" ] ; return($arrResponse) ; } else { @@ -2195,7 +2195,7 @@ OPTIONS } refresh_snapshots_database($vm) ; - $ret = $ret = delete_snapshots_database("$vm","$snap") ; + $ret = $ret = delete_snapshots_database("$vm","$snap") ; if($ret) $data = ["error" => "Unable to remove snap metadata $snap"] ; else @@ -2241,6 +2241,6 @@ OPTIONS */ } - + ?> diff --git a/emhttp/plugins/dynamix.vm.manager/scripts/VMAjaxCall.php b/emhttp/plugins/dynamix.vm.manager/scripts/VMAjaxCall.php index 73c4fef67..a5659426d 100755 --- a/emhttp/plugins/dynamix.vm.manager/scripts/VMAjaxCall.php +++ b/emhttp/plugins/dynamix.vm.manager/scripts/VMAjaxCall.php @@ -1,6 +1,7 @@ #!/usr/bin/php -q 'http://localhost/pub/vmaction?buffer_length=1', - CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket', - CURLOPT_POST => 1, - CURLOPT_RETURNTRANSFER => true - ]); - foreach ($messages as $message) { - curl_setopt($com, CURLOPT_POSTFIELDS, $message); - curl_exec($com); - } - curl_close($com); + $com = curl_init(); + curl_setopt_array($com,[ + CURLOPT_URL => 'http://localhost/pub/vmaction?buffer_length=1', + CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket', + CURLOPT_POST => 1, + CURLOPT_RETURNTRANSFER => true + ]); + foreach ($messages as $message) { + curl_setopt($com, CURLOPT_POSTFIELDS, $message); + curl_exec($com); + } + curl_close($com); } function execCommand_nchan($command,$idx) { - $waitID = mt_rand(); - [$cmd,$args] = explode(' ',$command,2); - write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); - write("addLog\0
") ; - #write("addToID\0$idx\0 $action") ; - $proc = popen("$command 2>&1",'r'); - while ($out = fgets($proc)) { - $out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out); - if (substr($out,0,1) == "B") { ; - write("progress\0$idx\0".htmlspecialchars(substr($out,strrpos($out,"Block Pull")))) ; - } else echo write("addToID\0$idx\0 ".htmlspecialchars($out)); - } - $retval = pclose($proc); - $out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!'; - write("stop_Wait\0$waitID","addLog\0
$out"); - return $retval===0; + $waitID = mt_rand(); + [$cmd,$args] = explode(' ',$command,2); + write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); + write("addLog\0
") ; + #write("addToID\0$idx\0 $action") ; + $proc = popen("$command 2>&1",'r'); + while ($out = fgets($proc)) { + $out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out); + if (substr($out,0,1) == "B") { ; + write("progress\0$idx\0".htmlspecialchars(substr($out,strrpos($out,"Block Pull")))) ; + } else echo write("addToID\0$idx\0 ".htmlspecialchars($out)); + } + $retval = pclose($proc); + $out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!'; + write("stop_Wait\0$waitID","addLog\0
$out"); + return $retval===0; } #{action:"snap-", uuid:uuid , snapshotname:target , remove:remove, free:free ,removemeta:removemeta ,keep:keep, desc:desc} @@ -65,10 +66,10 @@ $style[] = "legend{font-size:1.1rem!important;font-weight:bold}"; $style[] = ""; foreach (explode('&', $url) as $chunk) { - $param = explode("=", $chunk); - if ($param) { - ${urldecode($param[0])} = urldecode($param[1]) ; - } + $param = explode("=", $chunk); + if ($param) { + ${urldecode($param[0])} = urldecode($param[1]) ; + } } $id = 1 ; write(implode($style)."

"); @@ -78,24 +79,23 @@ write("addLog\0".htmlspecialchars("VMName $name ")); write("addLog\0".htmlspecialchars("SNAP $snapshotname ")); write("addLog\0".htmlspecialchars("Base $targetbase ")); if ($action == "commit") { - write("addLog\0".htmlspecialchars("Top $targettop ")); - write("addLog\0".htmlspecialchars("Pivot $targetpivot ")); - write("addLog\0".htmlspecialchars("Delete $targetdelete ")); + write("addLog\0".htmlspecialchars("Top $targettop ")); + write("addLog\0".htmlspecialchars("Pivot $targetpivot ")); + write("addLog\0".htmlspecialchars("Delete $targetdelete ")); } switch ($action) { - case "commit": - vm_blockcommit($name,$snapshotname,$path,$targetbase,$targettop,$targetpivot,$targetdelete) ; - break ; - case "copy": - vm_blockcopy($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ; - break; - case "pull": - vm_blockpull($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ; - break ; - - } +case "commit": + vm_blockcommit($name,$snapshotname,$path,$targetbase,$targettop,$targetpivot,$targetdelete) ; + break ; +case "copy": + vm_blockcopy($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ; + break; +case "pull": + vm_blockpull($name,$snapshotname,$path,$targetbase,$targettop,$pivot,' ') ; + break ; +} #execCommand_nchan("ls /") ; write("stop_Wait\0$waitID") ; write('_DONE_',''); -?> \ No newline at end of file +?> diff --git a/emhttp/plugins/dynamix.vm.manager/scripts/VMClone.php b/emhttp/plugins/dynamix.vm.manager/scripts/VMClone.php index 2c33227f7..2cdd7a319 100755 --- a/emhttp/plugins/dynamix.vm.manager/scripts/VMClone.php +++ b/emhttp/plugins/dynamix.vm.manager/scripts/VMClone.php @@ -1,6 +1,7 @@ #!/usr/bin/php -q 'http://localhost/pub/vmaction?buffer_length=1', - CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket', - CURLOPT_POST => 1, - CURLOPT_RETURNTRANSFER => true - ]); - foreach ($messages as $message) { - curl_setopt($com, CURLOPT_POSTFIELDS, $message); - curl_exec($com); - } - curl_close($com); - } - function execCommand_nchan_clone($command,$idx,$refcmd=false) { - $waitID = mt_rand(); - if ($refcmd) { - [$cmd,$args] = explode(' ',$refcmd,2); - write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); - $rtn = exec("$refcmd 2>&1", $output,$return) ; - if ($return == 0) $reflinkok = true ; else { - $reflinkok = false ; - write("addLog\0
{$output[0]}"); - } - $out = $return ? _('The command failed revert to rsync')."." : _('The command finished successfully').'!'; - write("stop_Wait\0$waitID","addLog\0
$out"); - } - if ($reflinkok) { - return true ; - } else { - $waitID = mt_rand(); - [$cmd,$args] = explode(' ',$command,2); - write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); - - write("addToID\0$idx\0Cloning VM: ") ; - $proc = popen("$command 2>&1 &",'r'); - while ($out = fread($proc,100)) { - $out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out); - $out = trim($out) ; - $values = explode(' ',$out) ; - $string = _("Data copied: ").$values[0].' '._(" Percentage: ").$values[1].' '._(" Transfer Rate: ").$values[2].' '._(" Time remaining: ").$values[4].$values[5] ; - write("progress\0$idx\0".htmlspecialchars($string)) ; - if ($out) $stringsave=$string ; - } - $retval = pclose($proc); - write("progress\0$idx\0".htmlspecialchars($stringsave)) ; - $out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!'; - write("stop_Wait\0$waitID","addLog\0
$out"); - return $retval===0; +function write(...$messages) { + $com = curl_init(); + curl_setopt_array($com,[ + CURLOPT_URL => 'http://localhost/pub/vmaction?buffer_length=1', + CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket', + CURLOPT_POST => 1, + CURLOPT_RETURNTRANSFER => true + ]); + foreach ($messages as $message) { + curl_setopt($com, CURLOPT_POSTFIELDS, $message); + curl_exec($com); + } + curl_close($com); +} + +function execCommand_nchan_clone($command,$idx,$refcmd=false) { + $waitID = mt_rand(); + if ($refcmd) { + [$cmd,$args] = explode(' ',$refcmd,2); + write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); + $rtn = exec("$refcmd 2>&1", $output,$return) ; + if ($return == 0) $reflinkok = true ; else { + $reflinkok = false ; + write("addLog\0
{$output[0]}"); + } + $out = $return ? _('The command failed revert to rsync')."." : _('The command finished successfully').'!'; + write("stop_Wait\0$waitID","addLog\0
$out"); + } + if ($reflinkok) { + return true ; + } else { + $waitID = mt_rand(); + [$cmd,$args] = explode(' ',$command,2); + write("

","addLog\0
"._('Command execution')."".basename($cmd).' '.str_replace(" -","
  -",htmlspecialchars($args))."
"._('Please wait')."

","show_Wait\0$waitID"); + write("addToID\0$idx\0Cloning VM: ") ; + $proc = popen("$command 2>&1 &",'r'); + while ($out = fread($proc,100)) { + $out = preg_replace("%[\t\n\x0B\f\r]+%", '',$out); + $out = trim($out); + $values = explode(' ',$out); + $string = _("Data copied: ").$values[0].' '._(" Percentage: ").$values[1].' '._(" Transfer Rate: ").$values[2].' '._(" Time remaining: ").$values[4].$values[5]; + write("progress\0$idx\0".htmlspecialchars($string)); + if ($out) $stringsave=$string; + } + $retval = pclose($proc); + write("progress\0$idx\0".htmlspecialchars($stringsave)); + $out = $retval ? _('The command failed').'.' : _('The command finished successfully').'!'; + write("stop_Wait\0$waitID","addLog\0
$out"); + return $retval===0; } } @@ -86,10 +85,10 @@ $style[] = "legend{font-size:1.1rem!important;font-weight:bold}"; $style[] = ""; foreach (explode('&', $url) as $chunk) { - $param = explode("=", $chunk); - if ($param) { - ${urldecode($param[0])} = urldecode($param[1]) ; - } + $param = explode("=", $chunk); + if ($param) { + ${urldecode($param[0])} = urldecode($param[1]) ; + } } $id = 1 ; write(implode($style)."

"); @@ -99,10 +98,10 @@ write("

","addLog\0
"._("O write("addLog\0".htmlspecialchars("Cloning $name to $clone")); switch ($action) { - case "clone": - $rtn = vm_clone($name,$clone,$overwrite,$start,$edit,$free,$waitID) ; - break ; - } +case "clone": + $rtn = vm_clone($name,$clone,$overwrite,$start,$edit,$free,$waitID) ; + break ; +} write("stop_Wait\0$waitID") ; if ($rtn) write('_DONE_',''); else write('_ERROR_',''); -?> \ No newline at end of file +?> diff --git a/emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css b/emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css index 0eec953a3..705cc8381 100644 --- a/emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css +++ b/emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css @@ -15,7 +15,7 @@ table.domdisk tbody tr:nth-child(even){background-color:transparent!important} table.domdisk tbody tr:nth-child(4n-1){background-color:transparent!important} table.snapshot{margin-top:0} i.mover{margin-right:8px;display:none} -i.fa-bullseye{padding-left:12px} +i.fa-floppy-o{padding-left:12px} #resetsort{margin-left:12px;display:inline-block;width:32px} .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset button[disabled]{cursor:default;color:#808080;background:-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 0 no-repeat,-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#404040),to(#404040)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#808080),to(#808080)) 100% 100% no-repeat;background:linear-gradient(90deg,#404040 0,#808080) 0 0 no-repeat,linear-gradient(90deg,#404040 0,#808080) 0 100% no-repeat,linear-gradient(0deg,#404040 0,#404040) 0 100% no-repeat,linear-gradient(0deg,#808080 0,#808080) 100% 100% no-repeat;background-size:100% 2px,100% 2px,2px 100%,2px 100%} .dropdown-menu{z-index:10001} diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 939d352ed..256b831f6 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1,7 +1,7 @@ - - >_(Enable USB boot)_: - + - + _(Boot Order)_: @@ -868,7 +869,7 @@ _(Unraid Share)_: - + - - _(Unraid Source Path)_: + + _(Unraid Source Path)_: id="shares[][source]" name="shares[][source]" autocomplete="off" data-pickfolders="true" data-pickfilter="NO_FILES_FILTER" data-pickroot="/mnt/" value="" placeholder="_(e.g.)_ /mnt/user/..." title="_(path of Unraid share)_" /> @@ -903,7 +904,7 @@ Used to create a VirtFS mapping to a Linux-based guest. Specify the mode you want to use either 9p or Virtiofs.

- +

Unraid Share
Set tag and path to match the selected Unraid share. @@ -918,8 +919,8 @@ Unraid Mount tag
Specify the mount tag that you will use for mounting the VirtFS share inside the VM. See this page for how to do this on a Linux-based guest: http://wiki.qemu.org/Documentation/9psetup

-

- For Windows additional software needs to be installed: https://virtio-fs.gitlab.io/howto-windows.html +

+ For Windows additional software needs to be installed: https://virtio-fs.gitlab.io/howto-windows.html

Additional devices can be added/removed by clicking the symbols to the left.

@@ -939,12 +940,12 @@ _(Unraid Share)_: - + - + _(Unraid Source Path)_: @@ -975,7 +976,7 @@ if ($i == 0) { // Only the first video card can be VNC or SPICE echo mk_option($arrGPU['id'], 'virtual', _('Virtual')); - + } else { echo mk_option($arrGPU['id'], '', _('None')); } @@ -985,11 +986,11 @@ } ?> - _(Multifunction)_: - + - + >_(VM Console Port)_: - + > - + >_(VM Console WS Port)_: - + > @@ -1082,7 +1083,7 @@

Virtual video protocol VNC/SPICE
- If you wish to assign a protocol type, specify one here. + If you wish to assign a protocol type, specify one here.

@@ -1092,7 +1093,7 @@

Virtual auto port
- Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set. + Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.

@@ -1196,13 +1197,13 @@ $domain_bridge, 'mac' => "", 'model' => 'virtio-net' ] ; - } + } foreach ($arrConfig['nic'] as $i => $arrNic) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; @@ -1326,7 +1327,7 @@ - + - + @@ -1373,14 +1374,14 @@ if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ; - + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } $intAvailableOtherPCIDevices++; ?> - - \n"; // XML encoding declaratio echo mk_option($arrGPU['autoport'], 'no', _('No')); ?> - + >_(VM Console Port)_: - + > - + >_(VM Console WS Port)_: - + > @@ -800,19 +801,19 @@ $hdrXML = "\n"; // XML encoding declaratio virtual video protocol VDA/SPICE
If you wish to assign a protocol type, specify one here.

- + Graphics Card
If you wish to assign a graphics card to the VM, select it from this list, otherwise leave it set to virtual.

virtual video protocol VDC/SPICE
- If you wish to assign a protocol type, specify one here. + If you wish to assign a protocol type, specify one here.

virtual auto port
- Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set. + Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.

@@ -898,15 +899,15 @@ $hdrXML = "\n"; // XML encoding declaratio
_(Select)_  _(Optional)_  _(Boot Order)_
_(Select)_  _(Optional)_  _(Boot Order)_
_(USB Devices)_: @@ -1336,7 +1337,7 @@ foreach($arrVMUSBs as $i => $arrDev) { ?>
_(Select)_  _(Boot Order)_
_(Select)_  _(Boot Order)_
_(Other PCI Devices)_:
- $domain_bridge, 'mac' => "", 'model' => 'virtio-net' ] ; - } + } foreach ($arrConfig['nic'] as $i => $arrNic) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; @@ -951,7 +952,7 @@ $hdrXML = "\n"; // XML encoding declaratio style="width: 50px;" name="nic[][boot]" title="_(Boot order)_" value="" > - +

@@ -1025,7 +1026,7 @@ $hdrXML = "\n"; // XML encoding declaratio - + @@ -1057,7 +1058,7 @@ $hdrXML = "\n"; // XML encoding declaratio
_(Select)_  _(Optional)_  _(Boot Order)_
_(Select)_  _(Optional)_  _(Boot Order)_
_(USB Devices)_:
- + @@ -1073,14 +1074,14 @@ $hdrXML = "\n"; // XML encoding declaratio if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ; - + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } $intAvailableOtherPCIDevices++; ?> - - +
_(Select)_  _(Boot Order)_
_(Select)_  _(Boot Order)_
_(Other PCI Devices)_: style="width: 50px;" name="nic[][boot]" title="_(Boot order)_" value="" >
@@ -1018,7 +1019,7 @@ $hdrXML = "\n"; // XML encoding declaratio - + @@ -1029,7 +1030,7 @@ $hdrXML = "\n"; // XML encoding declaratio foreach($arrVMUSBs as $i => $arrDev) { ?>
\n"; // XML encoding declaratio
_(Select)_  _(Optional)_  _(Boot Order)_
_(Select)_  _(Optional)_  _(Boot Order)_
_(USB Devices)_:
- + @@ -1066,14 +1067,14 @@ $hdrXML = "\n"; // XML encoding declaratio if (count($pcidevice=array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; foreach ($pcidevice as $pcikey => $pcidev) $pciboot = $pcidev["boot"]; ; - + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } $intAvailableOtherPCIDevices++; ?> - "; } @@ -218,7 +218,7 @@ case 't3': exec('lsusb|sort',$lsusb); foreach ($lsusb as $line) { [$bus,$id] = my_explode(':',$line); - $usbport = usb_physical_port($line) ; + $usbport = usb_physical_port($line); echo ""; } break; diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index f6ad7cf34..251e6e240 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -11,112 +11,106 @@ */ ?> "; - $html .= "" ; - - if (is_array($arrModules)) ksort($arrModules) ; - foreach($arrModules as $modname => $module) { - if ($modname == "") continue ; +case 't1load': + $list = file_get_contents($sysdrvfile); + $arrModules = json_decode($list,TRUE); + $init = false; + if (is_file($sysdrvinit)) $init = file_get_contents($sysdrvinit); + $html = ""; + $html .= ""; + if (is_array($arrModules)) ksort($arrModules); + foreach($arrModules as $modname => $module) { + if ($modname == "") continue; + if (is_file("/boot/config/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf"); + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe); + if($state !== false) {$state = "Disabled";} else $state="Custom"; + $module['state'] = $state; + $module['modprobe'] = $modprobe; + } else { + if (is_file("/etc/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/etc/modprobe.d/$modname.conf"); + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe); + if($state !== false) {$state = "Disabled";} else $state="System"; + $module['state'] = $state; + $module['modprobe'] = $modprobe; + } + } + $html .= ""; + if ($supportpage) { + if ($module['support'] == false) { + $supporthtml = ""; + } else { + $supporturl = $module['supporturl']; + $pluginname = $module['plugin']; + $supporthtml = ""; + } + } + if (isset($module["version"])) $version = " (".$module["version"].")"; else $version = ""; + $html .= ""; + $html .= ""; + $text = ""; + if (is_array($module["modprobe"])) { + $text = implode("\n",$module["modprobe"]); + $html .= ""; + } else { + $html .= ""; + } + } + $html .= ""; + $rtn = array(); + $rtn['html'] = $html; + if ($init !== false) {$init = true; unlink($sysdrvinit);} + $rtn['init'] = $init; + echo json_encode($rtn); + break; - if (is_file("/boot/config/modprobe.d/$modname.conf")) { - $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; - $state = strpos($modprobe, "blacklist"); - $modprobe = explode(PHP_EOL,$modprobe) ; - if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; - $module['state'] = $state ; - $module['modprobe'] = $modprobe ; - } else { - if (is_file("/etc/modprobe.d/$modname.conf")) { - $modprobe = file_get_contents("/etc/modprobe.d/$modname.conf") ; - $state = strpos($modprobe, "blacklist"); - $modprobe = explode(PHP_EOL,$modprobe) ; - if($state !== false) {$state = "Disabled" ;} else $state="System" ; - $module['state'] = $state ; - $module['modprobe'] = $modprobe ; - } - } - - $html .= "" ; - if ($supportpage) { - if ($module['support'] == false) { - $supporthtml = "" ; - } else { - $supporturl = $module['supporturl'] ; - $pluginname = $module['plugin'] ; - $supporthtml = "" ; - } - } - if (isset($module["version"])) $version = " (".$module["version"].")" ; else $version = "" ; - - $html .= "" ; - $html .= ""; - - $text = "" ; - if (is_array($module["modprobe"])) { - $text = implode("\n",$module["modprobe"]) ; - $html .= ""; - } else { - $html .= ""; - } - - } - $html .= "" ; - $rtn = array() ; - $rtn['html'] = $html ; - if ($init !== false) {$init = true ; unlink($sysdrvinit) ;} - $rtn['init'] = $init ; - echo json_encode($rtn) ; - break; - case "update": - $conf = $_POST['conf'] ; - $module = $_POST['module'] ; - if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ; - getmodules($module) ; - $return = $arrModules[$module] ; - $return['supportpage'] = $supportpage ; - if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]) ; - if ($error !== false) $return["error"] = false ; else $return["error"] = true ; - echo json_encode($return) ; - break ; -} + $conf = $_POST['conf']; + $module = $_POST['module']; + if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf"); else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf); + getmodules($module); + $return = $arrModules[$module]; + $return['supportpage'] = $supportpage; + if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]); + if ($error !== false) $return["error"] = false; else $return["error"] = true; + echo json_encode($return); + break; +} ?> diff --git a/emhttp/plugins/dynamix/include/SysDriversInit.php b/emhttp/plugins/dynamix/include/SysDriversInit.php index f9a5c3971..1beae8711 100755 --- a/emhttp/plugins/dynamix/include/SysDriversInit.php +++ b/emhttp/plugins/dynamix/include/SysDriversInit.php @@ -1,5 +1,5 @@ #!/usr/bin/php - \ No newline at end of file +$modtoplgfile = "/tmp/modulestoplg.json"; +$sysdrvfile = "/tmp/sysdrivers.json"; +$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE); +file_put_contents("/tmp/sysdrivers.init","1"); + +SysDriverslog("SysDrivers Build Starting"); +modtoplg(); +createlist(); +SysDriverslog("SysDrivers Build Complete"); +?> diff --git a/emhttp/plugins/dynamix/include/Syslog.php b/emhttp/plugins/dynamix/include/Syslog.php index 72fcaf814..32b7f3a5a 100644 --- a/emhttp/plugins/dynamix/include/Syslog.php +++ b/emhttp/plugins/dynamix/include/Syslog.php @@ -1,6 +1,6 @@ 1) && $argv[1] == "-v") { if ($cli && ($argc > 1) && $argv[1] == "-vv") { $verbose = true; } -$var = @parse_ini_file('/var/local/emhttp/var.ini') ?: []; -$nginx = @parse_ini_file('/var/local/emhttp/nginx.ini') ?: []; +$var = (array)@parse_ini_file('/var/local/emhttp/var.ini'); +$nginx = (array)@parse_ini_file('/var/local/emhttp/nginx.ini'); $is69 = version_compare(_var($var,'version'),"6.9.9","<"); $reloadNginx = false; $dnserr = false; @@ -189,7 +189,7 @@ $icon_warn = "⚠️ "; $icon_ok = "✅ "; $myservers_flash_cfg_path='/boot/config/plugins/dynamix.my.servers/myservers.cfg'; -$myservers = file_exists($myservers_flash_cfg_path) ? @parse_ini_file($myservers_flash_cfg_path,true) : []; +$myservers = (array)@parse_ini_file($myservers_flash_cfg_path,true); // ensure some vars are defined here so we don't have to test them later if (empty($myservers['remote']['apikey'])) { $myservers['remote']['apikey'] = ""; diff --git a/emhttp/plugins/dynamix/include/UpdateOne.php b/emhttp/plugins/dynamix/include/UpdateOne.php index d44a45b03..ebfe8539c 100644 --- a/emhttp/plugins/dynamix/include/UpdateOne.php +++ b/emhttp/plugins/dynamix/include/UpdateOne.php @@ -1,6 +1,6 @@
_(Select)_  _(Boot Order)_
_(Select)_  _(Boot Order)_
_(Other PCI Devices)_:
$bus Port $usbport".trim($id)."
$bus Port $usbport ".trim($id)."
"._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file")."
"._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file")."
$modname$version$supporthtml{$module['description']}{$module['state']}{$module['type']}"; + $hidden = ""; + if ($module['state'] == "System") $hidden = "hidden"; + $html .= " "; + $html .= "
"; + $html .= " "; + $html .= "
$modname$version$supporthtml{$module['description']}{$module['state']}{$module['type']}" ; - $hidden = "" ; - if ($module['state'] == "System") $hidden = "hidden" ; - $html .= " " ; - $html .= "
" ; - $html .= " " ; - $html .= "