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