Skip to content

Commit

Permalink
Merge pull request #3 from EvilDragonFly/main
Browse files Browse the repository at this point in the history
add wait for ipv6 logic
  • Loading branch information
luochongjun authored Apr 7, 2024
2 parents 910e1f4 + 35a42a2 commit f76d6bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions root/etc/init.d/dynv6
Original file line number Diff line number Diff line change
@@ -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(){
Expand All @@ -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
}
17 changes: 17 additions & 0 deletions root/usr/bin/dynv6-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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" ] && {
Expand Down

0 comments on commit f76d6bc

Please sign in to comment.