mirror of
https://github.com/unraid/webgui.git
synced 2026-01-13 05:00:06 -06:00
dockerMan: Redownload icon if url changesa
This commit is contained in:
@@ -85,6 +85,17 @@ if (isset($_POST['contName'])) {
|
||||
if (!is_dir($userTmplDir)) mkdir($userTmplDir, 0777, true);
|
||||
if ($Name) {
|
||||
$filename = sprintf('%s/my-%s.xml', $userTmplDir, $Name);
|
||||
if ( is_file($filename) ) {
|
||||
$oldXML = simplexml_load_file($filename);
|
||||
if ($oldXML->Icon != $_POST['contIcon']) {
|
||||
if (! strpos($Repository,":")) {
|
||||
$Repository .= ":latest";
|
||||
}
|
||||
$iconPath = $DockerTemplates->getIcon($Repository);
|
||||
@unlink("$docroot/$iconPath");
|
||||
@unlink("{$dockerManPaths['images']}/".basename($iconPath));
|
||||
}
|
||||
}
|
||||
file_put_contents($filename, $postXML);
|
||||
}
|
||||
// Run dry
|
||||
@@ -137,7 +148,15 @@ if (isset($_POST['contName'])) {
|
||||
}
|
||||
if ($startContainer) $cmd = str_replace('/docker create ', '/docker run -d ', $cmd);
|
||||
execCommand($cmd);
|
||||
echo '<div style="text-align:center"><button type="button" onclick="done()">Done</button></div><br>';
|
||||
if ( $newIcon ) {
|
||||
if (! strpos($Repository,":")) {
|
||||
$Repository .= ":latest";
|
||||
}
|
||||
$iconPath = $DockerTemplates->getIcon($Repository);
|
||||
@unlink("$docroot/$iconPath");
|
||||
@unlink("{$dockerManPaths['images']}/".basename($iconPath));
|
||||
}
|
||||
echo '<div style="text-align:center"><button type="button" onclick="done()">Done</button></div><br>';
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ $dockerManPaths = [
|
||||
'template-repos' => "/boot/config/plugins/dockerMan/template-repos",
|
||||
'templates-user' => "/boot/config/plugins/dockerMan/templates-user",
|
||||
'templates-usb' => "/boot/config/plugins/dockerMan/templates",
|
||||
'images-usb' => "/boot/config/plugins/dockerMan/images",
|
||||
'images' => "/var/lib/docker/unraid/images",
|
||||
'user-prefs' => "/boot/config/plugins/dockerMan/userprefs.cfg",
|
||||
'plugin' => "$docroot/plugins/dynamix.docker.manager",
|
||||
'images-ram' => "$docroot/state/plugins/dynamix.docker.manager/images",
|
||||
@@ -305,7 +305,7 @@ class DockerTemplates {
|
||||
$name = preg_replace("%\/|\\\%", '-', $matches[1][0]);
|
||||
$version = $matches[2][0];
|
||||
$iconRAM = sprintf('%s/%s-%s-%s.png', $dockerManPaths['images-ram'], $name, $version, 'icon');
|
||||
$iconUSB = sprintf('%s/%s-%s-%s.png', $dockerManPaths['images-usb'], $name, $version, 'icon');
|
||||
$iconUSB = sprintf('%s/%s-%s-%s.png', $dockerManPaths['images'], $name, $version, 'icon');
|
||||
if (!is_dir(dirname($iconRAM))) mkdir(dirname($iconRAM), 0755, true);
|
||||
if (!is_dir(dirname($iconUSB))) mkdir(dirname($iconUSB), 0755, true);
|
||||
if (!is_file($iconRAM)) {
|
||||
@@ -747,7 +747,7 @@ class DockerClient {
|
||||
if (isset($info[$name])) {
|
||||
if (isset($info[$name]['icon'])) {
|
||||
$iconRAM = $docroot.$info[$name]['icon'];
|
||||
$iconUSB = str_replace($dockerManPaths['images-ram'], $dockerManPaths['images-usb'], $iconRAM);
|
||||
$iconUSB = str_replace($dockerManPaths['images-ram'], $dockerManPaths['images'], $iconRAM);
|
||||
if ($cache>=1 && is_file($iconRAM)) unlink($iconRAM);
|
||||
if ($cache==2 && $code===true && is_file($iconUSB)) unlink($iconUSB);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ foreach ($containers as $ct) {
|
||||
$color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text');
|
||||
$update = $updateStatus=='false' ? 'blue-text' : '';
|
||||
$icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png';
|
||||
$image = substr($icon,-4)=='.png' ? "<img src='$icon' class='img'>" : (substr($icon,0,5)=='icon-' ? "<i class='$icon img'></i>" : "<i class='fa fa-$icon img'></i>");
|
||||
$image = substr($icon,-4)=='.png' ? "<img src='$icon?".filemtime("$docroot/{$info['icon']}")."' class='img'>" : (substr($icon,0,5)=='icon-' ? "<i class='$icon img'></i>" : "<i class='fa fa-$icon img'></i>");
|
||||
$wait = var_split($autostart[array_search($name,$names)],1);
|
||||
$ports = [];
|
||||
foreach ($ct['Ports'] as $port) {
|
||||
|
||||
Reference in New Issue
Block a user