rename var name
This commit is contained in:
parent
1f22bbe21f
commit
2e13501753
20
api.php
20
api.php
|
@ -12,7 +12,7 @@
|
||||||
{
|
{
|
||||||
$dockerClient = new Docker();
|
$dockerClient = new Docker();
|
||||||
$allContainers = $dockerClient->getAllContainers();
|
$allContainers = $dockerClient->getAllContainers();
|
||||||
$container = NULL;
|
$currentContainer = NULL;
|
||||||
|
|
||||||
foreach($allContainers as $thisContainer)
|
foreach($allContainers as $thisContainer)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
{
|
{
|
||||||
if(trim($thisContainer['Labels']['remotepass']) == trim($_REQUEST['KEY']))
|
if(trim($thisContainer['Labels']['remotepass']) == trim($_REQUEST['KEY']))
|
||||||
{
|
{
|
||||||
$container = $thisContainer;
|
$currentContainer = $thisContainer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($container == NULL)
|
if($currentContainer == NULL)
|
||||||
die("access denied!");
|
die("access denied!");
|
||||||
|
|
||||||
if(isset($_REQUEST['METODE']))
|
if(isset($_REQUEST['METODE']))
|
||||||
|
@ -39,26 +39,26 @@
|
||||||
{
|
{
|
||||||
if(strtoupper($_REQUEST['METODE']) == "START")
|
if(strtoupper($_REQUEST['METODE']) == "START")
|
||||||
{
|
{
|
||||||
$dockerClient->startContainer($container['Id']);
|
$dockerClient->startContainer($currentContainer['Id']);
|
||||||
echo "DONE";
|
echo "DONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtoupper($_REQUEST['METODE']) == "STOP")
|
if(strtoupper($_REQUEST['METODE']) == "STOP")
|
||||||
{
|
{
|
||||||
$dockerClient->stopContainer($container['Id']);
|
$dockerClient->stopContainer($currentContainer['Id']);
|
||||||
echo "DONE";
|
echo "DONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtoupper($_REQUEST['METODE']) == "KILL")
|
if(strtoupper($_REQUEST['METODE']) == "KILL")
|
||||||
{
|
{
|
||||||
$dockerClient->killContainer($container['Id']);
|
$dockerClient->killContainer($currentContainer['Id']);
|
||||||
echo "DONE";
|
echo "DONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtoupper($_REQUEST['METODE']) == "RESTART")
|
if(strtoupper($_REQUEST['METODE']) == "RESTART")
|
||||||
{
|
{
|
||||||
$dockerClient->killContainer($container['Id']);
|
$dockerClient->killContainer($currentContainer['Id']);
|
||||||
$dockerClient->startContainer($container['Id']);
|
$dockerClient->startContainer($currentContainer['Id']);
|
||||||
echo "DONE";
|
echo "DONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
if(strtoupper($_REQUEST['METODE']) == "LOG")
|
if(strtoupper($_REQUEST['METODE']) == "LOG")
|
||||||
{
|
{
|
||||||
$logOutput = $dockerClient->getContainerLogs($container['Id']);
|
$logOutput = $dockerClient->getContainerLogs($currentContainer['Id']);
|
||||||
echo clean($logOutput);
|
echo clean($logOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
file_put_contents($filename, $command."\n");
|
file_put_contents($filename, $command."\n");
|
||||||
|
|
||||||
system('cat '.$filename.' | socat EXEC:"docker attach '.$container['Id'].'",pty STDIN');
|
system('cat '.$filename.' | socat EXEC:"docker attach '.$currentContainer['Id'].'",pty STDIN');
|
||||||
unlink($filename);
|
unlink($filename);
|
||||||
echo "DONE";
|
echo "DONE";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue