From 35a42a26dab6431386b12fdd54fefaa9ea6a96d0 Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 7 Apr 2024 10:21:28 +0800 Subject: [PATCH] add wait for ipv6 logic --- root/etc/init.d/dynv6 | 10 ++++++++-- root/usr/bin/dynv6-update.sh | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/root/etc/init.d/dynv6 b/root/etc/init.d/dynv6 index af278ff..202a274 100755 --- a/root/etc/init.d/dynv6 +++ b/root/etc/init.d/dynv6 @@ -1,6 +1,11 @@ #!/bin/sh /etc/rc.common -START=31 +## specify the log path for debugging +exec > /root/dynv6.log 2>&1 + +START=299 + + stop(){ @@ -11,6 +16,7 @@ stop(){ } start(){ - /usr/bin/dynv6-update.sh + # avoid other service being blocked by the waiting ipv6 casuing deadlock + /usr/bin/dynv6-update.sh & return 0 } \ No newline at end of file diff --git a/root/usr/bin/dynv6-update.sh b/root/usr/bin/dynv6-update.sh index 9b5c2a1..57ca917 100755 --- a/root/usr/bin/dynv6-update.sh +++ b/root/usr/bin/dynv6-update.sh @@ -78,6 +78,18 @@ dynv6_update_loop() done } +wait_for_ipv6() +{ + ifstatus $1 + time=0 + while [ -z "$(ifstatus $1 | grep l3_device)" ] + do + echo "wait ${time}s" + sleep 10s + time=$((time+10)) + done +} + site_foreach() { load_site_cb(){ @@ -89,6 +101,11 @@ site_foreach() config_get token "$site" "token" config_get interface "$site" "interface" "any" config_get interval "$site" "interval" "60" + ##### wait ipv6 ####################### + echo "start to wait for getting ipv6" # + wait_for_ipv6 $interface # + echo "got ipv6" # + ##### wait ipv6 ####################### device="$(ifstatus $interface 2>/dev/null| jsonfilter -e '@.l3_device' 2>/dev/null)" [ -z $device ] && device="any" [ -n "$zone" ] && [ -n "$device" ] && [ -n "$token" ] && {