09-27-2021, 11:41 PM
(This post was last modified: 09-27-2021, 11:42 PM by Tim Curtis.)
I suppose we could simply bump the number of retries. Under normal circumstances bumping it to lets say 10 it won't have any effect because Routers usually hand out an IP address almost immediately.
Anyway here's the function.
Anyway here's the function.
Code:
function waitForIpAddr($iface, $maxloops = 3, $sleeptime = 3000000) {
for ($i = 0; $i < $maxloops; $i++) {
$ipaddr = sysCmd('ip addr list ' . $iface . " | grep \"inet \" |cut -d' ' -f6|cut -d/ -f1");
if (!empty($ipaddr[0])) {
break;
}
else {
workerLog('worker: ' . $iface .' wait '. $i . ' for IP address');
usleep($sleeptime);
}
}
return $ipaddr;
}