Merge remote-tracking branch 'upstream/master'

This commit is contained in:
bergware
2023-07-25 19:35:59 +02:00
7 changed files with 3693 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
Menu="UNRAID-OS"
Title="System Drivers"
Icon="fa-sitemap"
Tag="server"
---
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
global $var ;
$theme = $display['theme'] ;
?>
<style>
table.t1{margin-top:0; border-collapse: collapse; border-spacing: 0;}
table tr td{padding:0 0 3px 0;margin:0}
table tr td.thin{line-height:8px;height:8px}
table.t1 tr>td{width: 1%; ; text-align:centre ;white-space: nowrap;}
table.t1 tr>td+td{width: 1%; white-space: nowrap; }
table.t1 tr>td+td+td{width:auto ; text-align:left;}
table.t1 tr>td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;}
table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;}
.tablesorter .filtered {
display: none;
}
<?if ($theme == "black"):?>
table.tablesorter tbody tr.alt-row {background-color:#212121;}
table.tablesorter tbody tr.normal-row {background-color:#1c1b1b;}
input.search {color:#f2f2f2;background-color:#1c1b1b;}
<?endif;?>
<?if ($theme == "white"):?>
table.tablesorter tbody tr.alt-row {background-color:#ededed;}
table.tablesorter tbody tr.normal-row {background-color:#f2f2f2;}
input.search {color:#1c1b1b;background-color:#f2f2f2;}
<?endif;?>
<?if ($theme == "gray"):?>
table.tablesorter tbody tr.alt-row {solid #0c0f0b;}
table.tablesorter tbody tr.normal-row {background-color:#1b1d1b;}
input.search {color:#606e7f;background-color:#1b1d1b;}
table.tablesorter thead th {color:#606e7f;background-color:#1b1d1b;}
div.tablesorter-header-inner {color:#606e7f;background-color:#1b1d1b;}
<?endif;?>
<?if ($theme == "azure"):?>
table.tablesorter tbody tr.alt-row {background-color:#e4e2e4; }
table.tablesorter tbody tr.normal-row {solid #f3f0f4;}
input.search {color:#606e7f;background-color:#e4e2e4;}
table.tablesorter thead th {color:#606e7f;background-color:#e4e2e4;}
div.tablesorter-header-inner {color:#606e7f;background-color:#e4e2e4;}
<?endif;?>
</style>
<script type="text/javascript" src="/webGui/javascript/jquery.tablesorter.widgets.js"></script>
<script type="text/javascript">
function showDrivers(options, init = false) {
option = options ;
if (init) {
$('#driversearch').prop('disabled', true);
$('#select').prop('disabled', true);
$('#rebuild').prop('disabled', true);
$.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){
clearTimeout(timers.refresh);
$("#t1").trigger("destroy");
$('#t1').html(data.html);
$('#t1').tablesorter({
sortList:[[0,0]],
sortAppend:[[0,0]],
widgets: ['stickyHeaders','filter', 'zebra'],
widgetOptions: {
// on black and white, offset is height of #menu
// on azure and gray, offset is height of #header
stickyHeaders_offset: ( $('#menu').height() < 50 ) ? $('#menu').height() : $('#header').height(),
filter_columnFilters: false,
zebra : [ "normal-row", "alt-row" ]
}
});
$('div.spinner.fixed').hide('slow');
$('#driversearch').prop('disabled', false);
$('#select').prop('disabled', false);
$('#rebuild').prop('disabled', data.init);
},"json");
} else {
filter = [];
filterDrivers() ;
}
}
function filterDrivers() {
var totalColumns = $('#t1')[0].config.columns;
var filter = [];
filter[2] = ($('#select').val() === "inuse") ? "Inuse|Custom|Disabled|'Kernel - Inuse'" : "";
filter[totalColumns] = $('#driversearch').val(); // this searches all columns
$('#t1').trigger('search', [ filter ]);
}
function showDriversupdate() {
$('#rebuild').prop('disabled', true);
$('#t1').html("");
$('#driversearch').prop('disabled', true);
$('#select').prop('disabled', true);
$('div.spinner.fixed').show('slow');
$.post('/webGui/include/SysDrivers.php',{table:'t1create',option:"all"},function(data){
$('#rebuild').prop('disabled', false);
showDrivers("all",true) ;
$('div.spinner.fixed').hide('slow');
}) ;
}
function textedit(module) {
var i=module ;
$('#text'+module).prop('disabled', false);
$('#save'+module).attr('hidden', false);
$('#text'+module).attr('hidden', false);
}
function textsave(module) {
var i=module ;
$('#text'+module).prop('disabled', true);
$('#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){
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)
if (data.supportpage == true) {
if (data.support == true) {
document.getElementById("link" + module).innerHTML = "<a href='" + data.supporturl + "'target='_blank'><i title='" + _("Support page")_ + "' class='fa fa-phone-square'></i></a>" ;
} else {
document.getElementById("link" + module).innerHTML = "<i title='" + _("No support page avaialable")_ + "' class='fa fa-phone-square' ></i>" ;
}
}
}
//showDriversupdate() ;
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='all' >All Drivers</option><option value='inuse' selected >Inuse Drivers</option></select>");
showDrivers("all",true) ;
</script>
<form autocomplete="off" onsubmit="return false;"><span><input class="search" id="driversearch" type="search" placeholder="Search..." onchange="filterDrivers();"></span></form>
<pre><form id="sysdrivers" class="js-confirm-leave" onsubmit="return false"><table id='t1' class="t1 disk_status tablesorter " ><tr><td><div class="spinner"></div></td></tr></table></form></pre><br>
<input type="button" value="_(Done)_" onclick="done()"><input type="button" id="rebuild" value="_(Rebuild Modules)_" onclick="showDriversupdate()">

View File

@@ -0,0 +1,3 @@
#!/bin/bash
/usr/bin/logger "Submitting SysDrivers Build"
/usr/local/emhttp/plugins/dynamix/include/SysDriversInit.php &> /dev/null &

View File

@@ -0,0 +1,103 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
$_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") ;
$kernel = trim($kernel,"\n") ;
$lsmod = shell_exec("lsmod") ;
$supportpage = true;
$modtoplgfile = "/tmp/modulestoplg.json" ;
$sysdrvfile = "/tmp/sysdrivers.json" ;
$sysdrvinit = "/tmp/sysdrivers.init" ;
if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;}
$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ;
switch ($_POST['table']) {
case 't1create':
if (is_file("/tmp/sysdrvbuild.running")) break ;
touch("/tmp/sysdrvbuild.running") ;
modtoplg() ;
createlist() ;
unlink("/tmp/sysdrvbuild.running") ;
break;
case 't1load':
$list = file_get_contents($sysdrvfile) ;
$arrModules = json_decode($list,TRUE) ;
$init = file_get_contents($sysdrvinit) ;
$html = "<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>";
$html .= "<tbody>" ;
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 ;
}
$html .= "<tr id='row$modname'>" ;
if ($supportpage) {
if ($module['support'] == false) {
$supporthtml = "" ;
} else {
$supporturl = $module['supporturl'] ;
$pluginname = $module['plugin'] ;
$supporthtml = "<span id='link$modname'><a href='$supporturl' target='_blank'><i title='"._("Support page $pluginname")."' class='fa fa-phone-square'></i></a></span>" ;
}
}
$html .= "<td>$modname$supporthtml</td>" ;
$html .= "<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"]) ;
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."')\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a><span><textarea id=\"text".$modname."\" rows=3 disabled>$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."')\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
} else $html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."')\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a><span><textarea id=\"text".$modname."\" rows=1 hidden disabled >$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."')\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
}
$html .= "</tbody>" ;
#if ($init) {unlink($sysdrvinit) ; $init = true ;}
$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 ;
}
?>

View File

@@ -0,0 +1,176 @@
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
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 ;
$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)) ;
}
?>

View File

@@ -0,0 +1,33 @@
#!/usr/bin/php
<?php
function SysDriverslog($m, $type = "NOTICE") {
if ($type == "DEBUG" ) return NULL;
$m = print_r($m,true);
$m = str_replace("\n", " ", $m);
$m = str_replace('"', "'", $m);
$cmd = "/usr/bin/logger ".'"'.$m.'"'." -tSysDrivers";
exec($cmd);
}
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
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") ;
$kernel = trim($kernel,"\n") ;
$lsmod = shell_exec("lsmod") ;
$supportpage = true;
$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") ;
?>

File diff suppressed because it is too large Load Diff

View File

@@ -340,6 +340,27 @@ file_put_contents("/$diag/unraid-".$unraid['version'].".txt",$unraid['version'].
// add bz*.sha256 values
run("tail /boot/bz*.sha256 >> ".escapeshellarg("/$diag/unraid-".$unraid['version'].".txt"));
// Get the previous version of Unraid from the previous directory on flash
$changes = '/boot/previous/changes.txt';
if (file_exists($changes)) {
exec("head -n4 $changes",$rows);
foreach ($rows as $row) {
$i = stripos($row, 'version');
if ($i !== false) {
[$version,$date] = explode(' ', trim(substr($row,$i+7)));
break;
}
}
$previous_version = "Previous Version: ".$version;
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND);
$upgraded = "Upgraded on: ".date("F d Y", filemtime($changes));
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", $upgraded."\r\n", FILE_APPEND);
} else {
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\nNo Previous Version Found\r\n", FILE_APPEND);
}
// copy ini variables
foreach (glob("$path/*.ini") as $file) {
$ini = basename($file,".ini");