mirror of
https://github.com/unraid/webgui.git
synced 2026-02-23 10:49:52 -06:00
Sigle Line Update for Modprobe
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
Menu="UNRAID-OS"
|
||||
Title="System Modules/Drivers"
|
||||
Title="System Drivers"
|
||||
Icon="fa-sitemap"
|
||||
Tag="server"
|
||||
---
|
||||
@@ -46,76 +46,13 @@ table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;}
|
||||
|
||||
|
||||
|
||||
if (typeof " ".formatUnicorn !== "function")
|
||||
{
|
||||
String.prototype.formatUnicorn = String.prototype.formatUnicorn ||
|
||||
function () {
|
||||
"use strict";
|
||||
var str = this.toString();
|
||||
if (arguments.length) {
|
||||
var t = typeof arguments[0];
|
||||
var key;
|
||||
var args = ("string" === t || "number" === t) ?
|
||||
Array.prototype.slice.call(arguments)
|
||||
: arguments[0];
|
||||
|
||||
for (key in args) {
|
||||
str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), args[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
(function ($) {
|
||||
$.fn.getHiddenDimensions = function (includeMargin)
|
||||
{
|
||||
var $item = this,
|
||||
props = { position: 'absolute', visibility: 'hidden', display: 'block' },
|
||||
dim = { width: 0, height: 0, innerWidth: 0, innerHeight: 0, outerWidth: 0, outerHeight: 0 },
|
||||
$hiddenParents = $item.parents().andSelf().not(':visible'),
|
||||
includeMargin = (includeMargin == null) ? false : includeMargin;
|
||||
|
||||
var oldProps = [];
|
||||
$hiddenParents.each(function ()
|
||||
{
|
||||
var old = {};
|
||||
|
||||
for (var name in props)
|
||||
{
|
||||
old[name] = this.style[name];
|
||||
this.style[name] = props[name];
|
||||
}
|
||||
|
||||
oldProps.push(old);
|
||||
});
|
||||
|
||||
dim.width = $item.width();
|
||||
dim.outerWidth = $item.outerWidth(includeMargin);
|
||||
dim.innerWidth = $item.innerWidth();
|
||||
dim.height = $item.height();
|
||||
dim.innerHeight = $item.innerHeight();
|
||||
dim.outerHeight = $item.outerHeight(includeMargin);
|
||||
|
||||
$hiddenParents.each(function (i)
|
||||
{
|
||||
var old = oldProps[i];
|
||||
for (var name in props)
|
||||
{
|
||||
this.style[name] = old[name];
|
||||
}
|
||||
});
|
||||
|
||||
return dim;
|
||||
}
|
||||
}(jQuery));
|
||||
|
||||
|
||||
$(function(){
|
||||
$('#t1').load('/webGui/include/SysDrivers.php',{table:'t1',option:"inuse"});
|
||||
$('#t1').load('/webGui/include/SysDrivers.php',{table:'t1',option:"inuse"}).tablesorter();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function showDrivers(options) {
|
||||
option = options ;
|
||||
timers.refresh = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
|
||||
@@ -141,18 +78,21 @@ function textsave(module) {
|
||||
$('#save'+module).attr('hidden', true);
|
||||
var x = document.getElementById("text" + module).value;
|
||||
$.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){
|
||||
formHasUnsavedChanges=false;
|
||||
select = document.getElementById("select").value;
|
||||
showDrivers(select) ;
|
||||
if(data) {
|
||||
formHasUnsavedChanges=false;
|
||||
$('#text'+module).val(data.modprobe) ;
|
||||
$('#status'+module).html(data.state) ;
|
||||
if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3)
|
||||
}
|
||||
var message = "_(System Drivers)_: _(A reboot is required to apply changes)_";
|
||||
addRebootNotice(message);
|
||||
});
|
||||
},"json");
|
||||
}
|
||||
|
||||
|
||||
$('.tabs').append("<span class='status'><span class='lite label'>_(Select View)_:</span><select id='select' onchange='showDrivers(this.value)'><option value='inuse' selected>Inuse Drivers</option><option value='all' >All Drivers</option><option value='confonly'>Modprode Configs Only</option></select>");
|
||||
</script>
|
||||
|
||||
<pre><form id="sysdrivers" class="js-confirm-leave" onsubmit="return false"><table id='t1' class="disk_status wide t1 pre" ><tr><td><div class="spinner"></div></td></tr></table></form></pre><br>
|
||||
<pre><form id="sysdrivers" class="js-confirm-leave" onsubmit="return false"><table id='t1' class="tablesorter indexer disk_status wide t1 pre" ><tr><td><div class="spinner"></div></td></tr></table></form></pre><br>
|
||||
<input type="button" value="_(Done)_" onclick="done()">
|
||||
|
||||
|
||||
@@ -17,8 +17,12 @@ $_SERVER['REQUEST_URI'] = 'tools';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
function getmodules($kernel,$line) {
|
||||
global $arrModules,$lsmod ;
|
||||
$kernel = shell_exec("uname -r") ;
|
||||
$kernel = trim($kernel,"\n") ;
|
||||
$lsmod = shell_exec("lsmod") ;
|
||||
|
||||
function getmodules($line) {
|
||||
global $arrModules,$lsmod,$kernel ;
|
||||
$modprobe = "" ;
|
||||
$name = $line ;
|
||||
#echo $line ;
|
||||
@@ -64,9 +68,10 @@ function getmodules($kernel,$line) {
|
||||
}
|
||||
if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available";
|
||||
if (is_file("/boot/config/modprobe.d/$modname.conf")) {
|
||||
$modprobe = explode(PHP_EOL,file_get_contents("/boot/config/modprobe.d/$modname.conf")) ;
|
||||
$state = array_search("blacklist",$modprobe);
|
||||
if($state) {$state = "Disabled" ;}
|
||||
$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" ;
|
||||
} else if($option == "conf") return ;
|
||||
|
||||
@@ -96,30 +101,26 @@ switch ($_POST['table']) {
|
||||
case 't1':
|
||||
$option = $_POST['option'] ;
|
||||
$select = $_POST['select'] ;
|
||||
#$procmodules = file_get_contents("/proc/modules") ;
|
||||
$lsmod = shell_exec("lsmod") ;
|
||||
$kernel = shell_exec("uname -r") ;
|
||||
$kernel = trim($kernel,"\n") ;
|
||||
#$procmodules = shell_exec('find /lib/modules/$(uname -r) -type f -not -path "/lib/modules/$(uname -r)/source/*" -not -path "/lib/modules/$(uname -r)/build/*" -name "*ko*" ') ;
|
||||
$procmodules = shell_exec('find /lib/modules/$(uname -r)/kernel/drivers/ -type f -not -path "/lib/modules/$(uname -r)/source/*" -not -path "/lib/modules/$(uname -r)/build/*" -name "*ko*" ') ;
|
||||
$procmodules = explode(PHP_EOL,$procmodules) ;
|
||||
$builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ;
|
||||
$builtinmodules = explode(PHP_EOL,$builtinmodules) ;
|
||||
$procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ;
|
||||
$procmodules = explode(PHP_EOL,$procmodules) ;
|
||||
$option = $_POST['option'] ;
|
||||
$arrModules = array() ;
|
||||
|
||||
foreach($builtinmodules as $bultin)
|
||||
{
|
||||
if ($bultin == "") continue ;
|
||||
getmodules($kernel,pathinfo($bultin)["filename"]) ;
|
||||
getmodules(pathinfo($bultin)["filename"]) ;
|
||||
}
|
||||
|
||||
foreach($procmodules as $line) {
|
||||
if ($line == "") continue ;
|
||||
getmodules($kernel,$line) ;
|
||||
getmodules(pathinfo($line)["filename"]) ;
|
||||
}
|
||||
|
||||
echo "<thead><tr><td><b>"._("Module/Driver")."</td><td><b>"._("Description")."</td><td><b>"._("State")."</td><td><b>"._("Type")."</td><td><b>"._("Modeprobe.d config file")."</td></tr></thead>";
|
||||
echo "<thead><tr><th><b>"._("Module/Driver")."</th><th><b>"._("Description")."</th><th><b>"._("State")."</hd><th><b>"._("Type")."</th><th><b>"._("Modeprobe.d config file")."</th></tr></thead>";
|
||||
# echo "<tr><td>Total Number of drivers the system:".count($arrModules)."</td></tr>" ;
|
||||
echo "<tbody>" ;
|
||||
if (is_array($arrModules)) ksort($arrModules) ;
|
||||
foreach($arrModules as $modname => $module)
|
||||
@@ -139,7 +140,7 @@ foreach($procmodules as $line) {
|
||||
}
|
||||
#echo "<div class='show-disks'><table class='disk_status >" ;
|
||||
|
||||
echo "<tr><td><span onclick=\"textedit('".$modname."')\" ><a><i title='"._("Edit Modprobe config")."' id=\"icon'.$modname.'\" class='fa fa-edit' ></i></a></span> $modname</td><td>{$module['description']}</td><td>{$module['state']}</td><td>{$module['type']}</td>";
|
||||
echo "<tr><td><span onclick=\"textedit('".$modname."')\" ><a><i title='"._("Edit Modprobe config")."' id=\"icon'.$modname.'\" class='fa fa-edit' ></i></a></span> $modname</td><td>{$module['description']}</td><td id=\"status$modname\">{$module['state']}</td><td>{$module['type']}</td>";
|
||||
$text = "" ;
|
||||
if (is_array($module["modprobe"])) {
|
||||
$text = implode("\n",$module["modprobe"]) ;
|
||||
@@ -155,6 +156,10 @@ case "update":
|
||||
$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) ;
|
||||
echo $error ;
|
||||
getmodules($module) ;
|
||||
$return = $arrModules[$module] ;
|
||||
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) ;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user