mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Switch client on: wait for connection w/ timeout
add new switchClientState.sh to be used in hilink service (calls the php getClients code)
This commit is contained in:
@@ -190,6 +190,15 @@ function findCurrentClientIndex($clients) {
|
||||
return $devid;
|
||||
}
|
||||
|
||||
function waitClientConnected($dev, $timeout=10) {
|
||||
do {
|
||||
exec('ifconfig -a | grep -i '.$dev.' -A 1 | grep -oP "(?<=inet )([0-9]{1,3}\.){3}[0-9]{1,3}"',$res);
|
||||
$connected= !empty($res);
|
||||
if(!$connected) sleep(1);
|
||||
} while(!$connected && --$timeout > 0);
|
||||
return $connected;
|
||||
}
|
||||
|
||||
function setClientState($state) {
|
||||
$clients=getClients();
|
||||
if ( ($idx = findCurrentClientIndex($clients)) >= 0) {
|
||||
@@ -218,6 +227,7 @@ function setClientState($state) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if($state=="up") waitClientConnected($dev["name"],15);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user