add state to api

This commit is contained in:
Christopher 2020-10-24 16:37:43 +02:00
parent b1d4b7a718
commit 2626c5a40a
1 changed files with 10 additions and 0 deletions

10
api.php
View File

@ -40,22 +40,31 @@
if(strtoupper($_REQUEST['METODE']) == "START")
{
$dockerClient->startContainer($container['Id']);
echo "DONE";
}
if(strtoupper($_REQUEST['METODE']) == "STOP")
{
$dockerClient->stopContainer($container['Id']);
echo "DONE";
}
if(strtoupper($_REQUEST['METODE']) == "KILL")
{
$dockerClient->killContainer($container['Id']);
echo "DONE";
}
if(strtoupper($_REQUEST['METODE']) == "RESTART")
{
$dockerClient->killContainer($container['Id']);
$dockerClient->startContainer($container['Id']);
echo "DONE";
}
if(strtoupper($_REQUEST['METODE']) == "STATE")
{
echo $container['Status'];
}
if(strtoupper($_REQUEST['METODE']) == "COMMAND")
@ -71,6 +80,7 @@
system('cat '.$filename.' | socat EXEC:"docker attach '.$container['Id'].'",pty STDIN');
unlink($filename);
echo "DONE";
}
}
}