Skip to content
Snippets Groups Projects
Verified Commit 834ffcbc authored by David Beniamine's avatar David Beniamine
Browse files

New version using ajax

parent a818feb3
Branches
No related tags found
No related merge requests found
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1) IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1)
subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3) subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3)
echo "Demande de démarrage pour l'adresse mac : $1"
echo "$1" | netcat $subnet.52 9999 echo "$1" | netcat $subnet.52 9999
echo "Démarrage en cours, attente de l'IP"
retip=`netcat -l $IP 9999` retip=`netcat -l $IP 9999`
echo "Vous pouvez désormais lancer XRDP et vous connecter à l'adresse : $retip" echo "IP : $retip"
...@@ -23,21 +23,10 @@ ...@@ -23,21 +23,10 @@
echo "<p>Adresse MAC invalide : ".$args."</p>"; echo "<p>Adresse MAC invalide : ".$args."</p>";
}else{ }else{
$cmd = "../scripts/sendmac.sh"; $cmd = "../scripts/sendmac.sh";
echo "<p> Demarrage de la machine ".$args."</p>"; echo "<p> Démarrage de la machine ".$args." terminé</p>";
echo "<pre><code>"; echo "<pre><code>";
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
flush();
$process = proc_open("$cmd $args", $descriptorspec, $pipes, realpath('./'), array()); $process = proc_open("$cmd $args", $descriptorspec, $pipes, realpath('./'), array());
echo "<pre>"; echo "<pre>";
if (is_resource($process)) { shell_exec("$cmd $args");
while ($s = fgets($pipes[1])) {
print $s;
flush();
}
}
echo "</code></pre>"; echo "</code></pre>";
} }
...@@ -20,13 +20,15 @@ ...@@ -20,13 +20,15 @@
extract($_POST); extract($_POST);
switch($action){ switch($action){
case "wake" : case "wake" :
echo "<div id='result'></div>"; echo "<div id='result'><p>Démarrage demandé pour la machine $mac, veuillez patienter</p<div>";
?> ?>
<script language="javascript"> <script language="javascript">
var source = new EventSource(<?php echo "'boot.php?mac=$mac'"?>); $.ajax({
source.onmessage = function(event) { url: '<?php echo "'boot.php?mac=$mac'"?>',
success: function(response) {
document.getElementById("result").innerHTML += event.data + "<br>"; document.getElementById("result").innerHTML += event.data + "<br>";
}; }
});
</script> </script>
<?php <?php
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment