mirror of
https://github.com/unraid/webgui.git
synced 2026-02-26 12:18:56 -06:00
Update initial build process
This commit is contained in:
@@ -16,6 +16,7 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$_SERVER['REQUEST_URI'] = 'tools';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/SysDriversHelpers.php";
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
$kernel = shell_exec("uname -r") ;
|
||||
@@ -27,210 +28,17 @@ $sysdrvfile = "/tmp/sysdrivers.json" ;
|
||||
if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;}
|
||||
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ;
|
||||
|
||||
function getplugin($in) {
|
||||
$plugins = "/var/log/plugins/";
|
||||
$plugin_link = $plugins.$in ;
|
||||
$plugin_file = @readlink($plugin_link);
|
||||
$support = plugin('support',$plugin_file) ?: "";
|
||||
return($support) ;
|
||||
}
|
||||
|
||||
function getmodules($line) {
|
||||
global $arrModules,$lsmod,$kernel,$arrModtoPlg,$modplugins ;
|
||||
$modprobe = "" ;
|
||||
$desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = $state = null ;
|
||||
$name = $line ;
|
||||
#echo $line ;
|
||||
$modname = shell_exec("modinfo $name > /dev/null") ;
|
||||
if ($modname != null) $modname = trim($modname,"\n") ;
|
||||
$output=null ;
|
||||
exec("modinfo $name",$output,$error) ;
|
||||
$parms = array() ;
|
||||
foreach($output as $outline) {
|
||||
$data = explode(":",$outline) ;
|
||||
$support = false ; $supporturl = null ;
|
||||
switch ($data[0])
|
||||
{
|
||||
case "name":
|
||||
$modname = trim($data[1]) ;
|
||||
break ;
|
||||
case "depends":
|
||||
$depends = trim($data[1]) ;
|
||||
break ;
|
||||
case "filename":
|
||||
$filename = trim($data[1]) ;
|
||||
break ;
|
||||
case "description":
|
||||
$desc = trim($data[1]) ;
|
||||
break ;
|
||||
case "parm":
|
||||
$parms[] = trim(str_replace("parm:","",$outline)) ;
|
||||
break ;
|
||||
case "file":
|
||||
$file = trim(str_replace("file:","",$outline)) ;
|
||||
break ;
|
||||
case "alias":
|
||||
case "author":
|
||||
case "firmware":
|
||||
case "intree":
|
||||
case "vermagic":
|
||||
case "retpoline":
|
||||
case "import_ns":
|
||||
case "license":
|
||||
break ;
|
||||
default:
|
||||
$parms[] = trim($outline) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ($modname != null) {
|
||||
if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available";
|
||||
if (isset($arrModtoPlg[$modname])) { $support = true ; $supporturl = plugin("support", $modplugins[$arrModtoPlg[$modname]]) ; $pluginfile = "Plugin name: {$arrModtoPlg[$modname]}" ; } else { $support = false ; $supporturl = null ; }
|
||||
}
|
||||
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" ;
|
||||
}
|
||||
|
||||
if ($filename != "(builtin)") {
|
||||
if ($filename != null) {
|
||||
$type = pathinfo($filename) ;
|
||||
$dir = $type['dirname'] ;
|
||||
|
||||
$dir = str_replace("/lib/modules/$kernel/kernel/drivers/", "" ,$dir) ;
|
||||
$dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ;
|
||||
}
|
||||
} else {
|
||||
$dir = $file ;
|
||||
$dir = str_replace("drivers/", "" ,$dir) ;
|
||||
if ($state == "Inuse") $state= "Kernel - Inuse"; else $state="Kernel" ;
|
||||
}
|
||||
if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ;
|
||||
$arrModules[$modname] = [
|
||||
'modname' => $modname,
|
||||
'dependacy' => $depends,
|
||||
'parms' => $parms,
|
||||
'file' => $file,
|
||||
'modprobe' => $modprobe,
|
||||
'plugin' => $pluginfile ,
|
||||
'state' => $state,
|
||||
'type' => $dir,
|
||||
'support' => $support,
|
||||
'supporturl' => $supporturl,
|
||||
'description' => $description ,
|
||||
] ;
|
||||
}
|
||||
|
||||
function modtoplg() {
|
||||
global $modtoplgfile ;
|
||||
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins'));
|
||||
$files = array();
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($rii as $file) {
|
||||
if ($file->isDir()){
|
||||
continue;
|
||||
}
|
||||
if ($file->getExtension() != "tgz" && $file->getExtension() != "txz") continue ;
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
|
||||
$list = array() ;
|
||||
foreach ($files as $f) {
|
||||
$plugin = str_replace("/boot/config/plugins/", "", $f) ;
|
||||
$plugin = substr($plugin,0,strpos($plugin,'/') ) ;
|
||||
$tar = [] ;
|
||||
exec("tar -tf $f | grep -E '.ko.xz|.ko' ",$tar) ;
|
||||
foreach ($tar as $t) {
|
||||
$p = pathinfo($t) ;
|
||||
$filename = str_replace(".ko","",$p["filename"]) ;
|
||||
$list[$filename] = $plugin ;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($modtoplgfile,json_encode($list,JSON_PRETTY_PRINT)) ;
|
||||
|
||||
}
|
||||
|
||||
function createlist() {
|
||||
global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins ;
|
||||
$arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ;
|
||||
$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) ;
|
||||
$arrModules = array() ;
|
||||
|
||||
$list = scandir('/var/log/plugins/') ;
|
||||
foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ;
|
||||
|
||||
foreach($builtinmodules as $bultin)
|
||||
{
|
||||
if ($bultin == "") continue ;
|
||||
getmodules(pathinfo($bultin)["filename"]) ;
|
||||
}
|
||||
|
||||
foreach($procmodules as $line) {
|
||||
if ($line == "") continue ;
|
||||
getmodules(pathinfo($line)["filename"]) ;
|
||||
}
|
||||
|
||||
$lsmod2 = explode(PHP_EOL,$lsmod) ;
|
||||
foreach($lsmod2 as $line) {
|
||||
if ($line == "") continue ;
|
||||
$line2 = explode(" ",$line) ;
|
||||
getmodules($line2['0']) ;
|
||||
}
|
||||
|
||||
unset($arrModules['null']);
|
||||
file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ;
|
||||
}
|
||||
|
||||
switch ($_POST['table']) {
|
||||
|
||||
case 't1create':
|
||||
modtoplg() ;
|
||||
createlist() ;
|
||||
/*$arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ;
|
||||
$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) ;
|
||||
$arrModules = array() ;
|
||||
|
||||
$list = scandir('/var/log/plugins/') ;
|
||||
foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ;
|
||||
|
||||
foreach($builtinmodules as $bultin)
|
||||
{
|
||||
if ($bultin == "") continue ;
|
||||
getmodules(pathinfo($bultin)["filename"]) ;
|
||||
}
|
||||
|
||||
foreach($procmodules as $line) {
|
||||
if ($line == "") continue ;
|
||||
getmodules(pathinfo($line)["filename"]) ;
|
||||
}
|
||||
|
||||
$lsmod2 = explode(PHP_EOL,$lsmod) ;
|
||||
foreach($lsmod2 as $line) {
|
||||
if ($line == "") continue ;
|
||||
$line2 = explode(" ",$line) ;
|
||||
getmodules($line2['0']) ;
|
||||
}
|
||||
|
||||
unset($arrModules['null']);
|
||||
file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; */
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 't1load':
|
||||
$list = file_get_contents($sysdrvfile) ;
|
||||
$arrModules = json_decode($list,TRUE) ;
|
||||
#echo "<thead><tr><th><b>"._("Actions")."</th><th><b>"._("Driver")."</th><th><b>"._("Description")."</th><th data-value='Inuse|Custom|Disabled'><b>"._("State")."</th><th><b>"._("Type")."</th><th><b>"._("Modeprobe.d config file")."</th></tr></thead>";
|
||||
echo "<thead><tr><th><b>"._("Driver")."</th><th><b>"._("Description")."</th><th data-value='Inuse|Custom|Disabled|\"Kernel - Inuse\"'><b>"._("State")."</th><th><b>"._("Type")."</th><th><b>"._("Modprobe.d config file")."</th></tr></thead>";
|
||||
echo "<tbody>" ;
|
||||
|
||||
@@ -248,10 +56,8 @@ switch ($_POST['table']) {
|
||||
}
|
||||
|
||||
echo "<tr id='row$modname'>" ;
|
||||
#echo "<td></td>" ;
|
||||
if ($supportpage) {
|
||||
if ($module['support'] == false) {
|
||||
#$supporthtml = "<span id='link$modname'><i title='"._("No support page avaialable")."' class='fa fa-phone-square'></i></span>" ;
|
||||
$supporthtml = "" ;
|
||||
} else {
|
||||
$supporturl = $module['supporturl'] ;
|
||||
|
||||
Reference in New Issue
Block a user