global $lv;
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/SysDriversHelpers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt.php";
function macbyte($val) {
if ($val < 16)
return '0'.dechex($val);
return dechex($val);
}
$arrEntries = [];
$vms = $lv->get_domains() ?:[];
sort($vms,SORT_NATURAL);
foreach($vms as $vm){
$arrEntries['VM'][$vm]['interfaces'] = $lv->get_nic_info($vm);
$arrEntries['VM'][$vm]['name'] = $vm;
}
$DockerClient = new DockerClient();
$containers = $DockerClient->getDockerJSON("/containers/json?all=1");
foreach($containers as $ct)
$arrEntries['Docker'][substr($ct["Names"][0],1)] = [
'interfaces' => ['0 '=> ['mac' => isset($ct["NetworkSettings"]["Networks"]["bridge"]["MacAddress"]) ? $ct["NetworkSettings"]["Networks"]["bridge"]["MacAddress"] : ""]],
'name' => substr($ct["Names"][0],1),
];
$lxc = explode("\n",shell_exec("lxc-ls -1")) ;
$lxcpath = trim(shell_exec("lxc-config lxc.lxcpath"));
foreach ($lxc as $lxcname) {
if ($lxcname == "") continue;
$value = explode("=",shell_exec("cat $lxcpath/$lxcname/config | grep 'hwaddr'"));
$arrEntries['LXC'][$lxcname]['interfaces'][0]['mac'] = trim($value[1]);
$arrEntries['LXC'][$lxcname]['name'] = $lxcname;
}
if (is_file("/boot/config/wol.json")) $user_mac = json_decode(file_get_contents("/boot/config/wol.json"),true); else $user_mac = [];
foreach($arrEntries as $key => $data) {
$type=$key;
foreach($data as $data2){
$name=$data2['name'];
if (isset($user_mac[$type][$name])) {
$name=$name;
$arrEntries[$type][$name]['enable'] = $user_mac[$type][$name]['enable'];
$arrEntries[$type][$name]['user_mac'] = strtolower($user_mac[$type][$name]['user_mac']);
} else {
$arrEntries[$type][$name]['enable'] = 'enable';
$arrEntries[$type][$name]['user_mac'] = 'None Defined';
}
}
}
switch ($_POST['table']) {
case 't1load':
$arrMacs = $arrEntries;
$html = " ";
$html .= ""._('Service')." "._('Name')." "._('Mac Address')." "._('Enabled')." "._('User Mac Address')."