-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watchcat: Add support for custom ping timeout #25174
base: master
Are you sure you want to change the base?
Conversation
I think this PR and openwrt/luci#7337 are ready for review. Thanks 🙏 |
utils/watchcat/files/watchcat.sh
Outdated
get_ping_timeout() { | ||
timeout=$1 | ||
case "$timeout" in | ||
''|*[!0-9]*) | ||
# Fallback to default value if not an integer | ||
timeout=10 | ||
;; | ||
esac | ||
|
||
echo $timeout | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid this altogether by supplying a default if timeout is empty or unsupplied.
${parameter:-[word]}
. Param is empty? Fill with default [word]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I've done first but then changed my mind. The code here also defaults to the default in case someone pass it a non-integer or negative value. If we don't care about this case then yes, shell default value syntax will be simpler 🙂. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@systemcrash I pushed a new commit to change that part. But honestly I'm not convinced.
That will silently fail with such case
# use of "A" / "-1" / ""1.5" as last param is not a positive integer and will silently fail the test
sh -x /usr/bin/watchcat.sh restart_iface 30 1.1.5.5 3 small wwan0 free 0 ipv4 A
# would translate to
ping -4 -I wwan0 -s 1 -c 1 -W A 1.1.5.5
# previous implementation would have set the default value
ping -4 -I wwan0 -s 1 -c 10 -W 10 1.1.5.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Neustradamus
@systemcrash @Neustradamus Regarding comments above. We still need to decide on ab35bd7 (xref #25174 (comment)). I would prefer to remove it and keep previous implementation. But final word is yours :)
Then we have openwrt/luci#7337 to check. (It's now having merge conflicts but I will resolve them lately)
Thanks
Signed-off-by: Mathieu A <[email protected]>
Signed-off-by: Mathieu A <[email protected]>
@kumy: Nice PR, thanks! |
Maintainer: me / @neheb, @jtkohl
Compile tested: ATH79 - generic - tag v23.05.5
Run tested: ath79/generic OpenWrt 23.05.4 r24012-d8dd03c46f / LuCI openwrt-23.05 branch git-24.086.45142-09d5a38
Closes #25173
Description:
Allow custom ping timeout
Notes:
luci-app-watchcat
side -> luci-app-watchcat: Add support for ping timeout luci#7337-W
to theping
command