From 1739c5373ec03a7143c92309e106a0af4eba7fa4 Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Sat, 23 Nov 2024 13:07:44 +0100 Subject: [PATCH 1/3] check if watchping exists before using it --- .../files/etc/udhcpc.user.d/50-client-wwan-watchping | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping index 7349ae62d..afd1206bb 100644 --- a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping +++ b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping @@ -8,7 +8,7 @@ setup_hotspot_watchping() { uci set system.hotspot_watchping.pinghosts=$gw uci set system.hotspot_watchping.pinginterval=20s uci commit system - /etc/init.d/watchping restart + [ -e /etc/init.d/watchping ] && /etc/init.d/watchping restart fi } From be5c7b696642fcb6ac657a961c24bffc45298ebc Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Sat, 23 Nov 2024 13:21:04 +0100 Subject: [PATCH 2/3] fix if check for non-empty variable --- .../files/etc/udhcpc.user.d/50-client-wwan-watchping | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping index afd1206bb..61dd23811 100644 --- a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping +++ b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping @@ -1,7 +1,7 @@ setup_hotspot_watchping() { ifname="client-wwan" gw=$(ip r show default dev $ifname | while read default via ip rest; do [[ $via == "via" ]] && echo $ip && break; done) - if [ -n gw ]; then + if [ -n "$gw" ]; then uci set system.hotspot_watchping=watchping uci set system.hotspot_watchping.interface=$ifname uci set system.hotspot_watchping.timeout=2m From af3301629081e1632712142b2ef0bc27045abf12 Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Sat, 23 Nov 2024 13:30:37 +0100 Subject: [PATCH 3/3] check if client-wwan interface exists before using it --- .../udhcpc.user.d/50-client-wwan-watchping | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping index 61dd23811..49b029776 100644 --- a/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping +++ b/packages/ubus-lime-utils/files/etc/udhcpc.user.d/50-client-wwan-watchping @@ -1,14 +1,17 @@ setup_hotspot_watchping() { ifname="client-wwan" - gw=$(ip r show default dev $ifname | while read default via ip rest; do [[ $via == "via" ]] && echo $ip && break; done) - if [ -n "$gw" ]; then - uci set system.hotspot_watchping=watchping - uci set system.hotspot_watchping.interface=$ifname - uci set system.hotspot_watchping.timeout=2m - uci set system.hotspot_watchping.pinghosts=$gw - uci set system.hotspot_watchping.pinginterval=20s - uci commit system - [ -e /etc/init.d/watchping ] && /etc/init.d/watchping restart + # check if interface exists before running the ip command on it + if [ -e /sys/class/net/$ifname/type ]; then + gw=$(ip r show default dev $ifname | while read default via ip rest; do [[ $via == "via" ]] && echo $ip && break; done) + if [ -n "$gw" ]; then + uci set system.hotspot_watchping=watchping + uci set system.hotspot_watchping.interface=$ifname + uci set system.hotspot_watchping.timeout=2m + uci set system.hotspot_watchping.pinghosts=$gw + uci set system.hotspot_watchping.pinginterval=20s + uci commit system + [ -e /etc/init.d/watchping ] && /etc/init.d/watchping restart + fi fi }