mirror of
https://github.com/unraid/webgui.git
synced 2026-01-20 16:40:17 -06:00
Merge pull request #1117 from arifer612/feat/docker-webui
Use docker label as primary source for WebUI
This commit is contained in:
@@ -268,11 +268,12 @@ class DockerTemplates {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getControlURL(&$ct, $myIP) {
|
||||
private function getControlURL(&$ct, $myIP, $WebUI) {
|
||||
global $host;
|
||||
$port = &$ct['Ports'][0];
|
||||
$myIP = $myIP ?: $this->getTemplateValue($ct['Image'], 'MyIP') ?: ($ct['NetworkMode']=='host'||$port['NAT'] ? $host : ($port['IP'] ?: DockerUtil::myIP($ct['Name'])));
|
||||
$WebUI = preg_replace("%\[IP\]%", $myIP, $this->getTemplateValue($ct['Image'], 'WebUI'));
|
||||
// Get the WebUI address from the templates as a fallback
|
||||
$WebUI = preg_replace("%\[IP\]%", $myIP, $WebUI ?: $this->getTemplateValue($ct['Image'], 'WebUI'));
|
||||
if (preg_match("%\[PORT:(\d+)\]%", $WebUI, $matches)) {
|
||||
$ConfigPort = $matches[1];
|
||||
foreach ($ct['Ports'] as $port) {
|
||||
@@ -306,13 +307,13 @@ class DockerTemplates {
|
||||
}
|
||||
if ($ct['Running']) {
|
||||
$port = &$ct['Ports'][0];
|
||||
$webui = $this->getTemplateValue($ct['Image'], 'WebUI');
|
||||
$webui = $tmp['url'] ?: $this->getTemplateValue($ct['Image'], 'WebUI');
|
||||
if (strlen($webui) > 0 && !preg_match("%\[(IP|PORT:(\d+))\]%", $webui)) {
|
||||
// non-templated webui, user specified
|
||||
$tmp['url'] = $webui;
|
||||
} else {
|
||||
$ip = ($ct['NetworkMode']=='host'||$port['NAT'] ? $host : $port['IP']);
|
||||
$tmp['url'] = $ip ? (strpos($tmp['url'],$ip)!==false ? $tmp['url'] : $this->getControlURL($ct, $ip)) : $tmp['url'];
|
||||
$tmp['url'] = $ip ? (strpos($tmp['url'],$ip)!==false ? $tmp['url'] : $this->getControlURL($ct, $ip, $tmp['url'])) : $tmp['url'];
|
||||
}
|
||||
$tmp['shell'] = $tmp['shell'] ?? $this->getTemplateValue($image, 'Shell');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user