mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-08 20:46:50 +03:00
Added interface up waiting
This commit is contained in:
@@ -444,9 +444,20 @@ add_set() {
|
|||||||
add_route_interface() {
|
add_route_interface() {
|
||||||
local interface="$1"
|
local interface="$1"
|
||||||
local table="$2"
|
local table="$2"
|
||||||
local retry_count=0
|
local retry_count_interface=0
|
||||||
|
local retry_count_route=0
|
||||||
local max_retries=20
|
local max_retries=20
|
||||||
|
|
||||||
|
while ! ip link show "$interface" >/dev/null 2>&1; do
|
||||||
|
if (( attempt == max_retries )); then
|
||||||
|
log "Interface "$interface" undetected after $retry_count_interface attempts. Exit"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log "Attempt $retry_count_interface: Interface "$interface" not found, retrying in 3 seconds..."
|
||||||
|
retry_count_interface=$(( retry_count_interface + 1 ))
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
if ! ip link show "$interface" >/dev/null 2>&1; then
|
if ! ip link show "$interface" >/dev/null 2>&1; then
|
||||||
log "Interface "$interface" does not exist, not possible to create a route"
|
log "Interface "$interface" does not exist, not possible to create a route"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -458,11 +469,11 @@ add_route_interface() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
log "Added route for "$interface""
|
log "Added route for "$interface""
|
||||||
while [ $retry_count -lt $max_retries ]; do
|
while [ $retry_count_route -lt $max_retries ]; do
|
||||||
if ip route add table $table default dev "$interface" 2>&1 | grep -q "Network is down"; then
|
if ip route add table $table default dev "$interface" 2>&1 | grep -q "Network is down"; then
|
||||||
log "Error: Network is down. Let's try again in 3 seconds"
|
log "Attempt $retry_count_route: Interface "$interface" is down, retrying in 3 seconds..."
|
||||||
sleep 3
|
sleep 3
|
||||||
retry_count=$((retry_count + 1))
|
retry_count_route=$((retry_count_route + 1))
|
||||||
else
|
else
|
||||||
log "Route for "$interface" added"
|
log "Route for "$interface" added"
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user