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

Multiple fix by removing timeouts as much as possible

parent a43d0cbf
Branches
No related tags found
No related merge requests found
......@@ -24,27 +24,17 @@ getip(){
IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1)
broadcast=$(ip a | awk '/inet.*eth1/ {print $4}' | cut -d / -f 1)
subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3)
LIMIT=20
while true
do
MAC=`netcat -l $IP 9999`
echo "$MAC"
if [ $(echo "$MAC" | egrep -c "^([0-9a-f]{2}:?){6}$") -eq 1 ]
then
wakeonlan -i $broadcast "$MAC"
bootedip=""
timeout=0
sleep 25
while [ -z "$bootedip" ]
do
bootedip=`getip $MAC`
sleep 5
timeout=$(($timeout +1))
if [ $timeout -ge $LIMIT ]
then
$bootedip="ERROR"
break
fi
done
bootedip=`getip $MAC`
echo "Sending ip"
echo "$bootedip" | netcat $subnet.51 9999
echo "Done"
fi
done
......@@ -23,13 +23,18 @@
echo "<p>Adresse MAC invalide : ".$args."</p>";
}else{
$cmd = "../scripts/sendmac.sh";
$ip=shell_exec("$cmd $args");
if(!empty(trim($ip))){
echo "<p> Démarrage de la machine ".$args." terminé !</p>";
echo "<p>Pour vous y connecter, téléchargez ";
system("cp www/config.rdp.sample www/config.rdp");
system("echo \"full address:s:\"".$_SERVER["HTTP_HOST"]." >> config.rdp");
echo '<a href="config.rdp';
echo '">ce fichier</a> et lancez le.<br />';
echo "Cela ouvrira XRDP, il vous suffira alors d'indiquer l'adresse IP <span style='color:blue;font-weight:bold'>".shell_exec("$cmd $args")."</span>";
echo "Cela ouvrira XRDP, il vous suffira alors d'indiquer l'adresse IP <span style='color:blue;font-weight:bold'>".$ip."</span>";
echo "et le mot de passe adéquat";
echo "</p>";
}else{
header('HTTP/1.1 500 Internal Server Error');
}
}
......@@ -41,10 +41,13 @@
type: "POST",
data: '<?php echo "mac=$mac"?>',
url: 'boot.php',
timeout: 60000,
timeout: 30000,
error: function(reponse){
if(retry > 0){
$("#result").html("Veuillez patienter encore un peu (max "+retry*4+" sec)") ;
sendpost(retry-1);
}else{
$("#result").html("Erreur : IP non trouvée après 120 secondes") ;
}
},
success: function(response) {
......@@ -52,7 +55,7 @@
}
});
}
sendpost(1);
sendpost(24);
</script>
<?php
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment