From 744bd43658dc930ce5f1f6ad72a8398e1c496ead Mon Sep 17 00:00:00 2001 From: vdutta Date: Mon, 9 May 2022 14:39:07 +0530 Subject: [PATCH] icwmp: 8.4.7 --- icwmp/Makefile | 2 +- icwmp/files/etc/icwmpd/update.sh | 21 ++++++++++++++------- icwmp/files/etc/init.d/icwmpd | 13 ++++++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/icwmp/Makefile b/icwmp/Makefile index f7c712eba..7d4575f0c 100755 --- a/icwmp/Makefile +++ b/icwmp/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=icwmp -PKG_VERSION:=8.4.6 +PKG_VERSION:=8.4.7 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git diff --git a/icwmp/files/etc/icwmpd/update.sh b/icwmp/files/etc/icwmpd/update.sh index b9a66c88f..4b5e41660 100644 --- a/icwmp/files/etc/icwmpd/update.sh +++ b/icwmp/files/etc/icwmpd/update.sh @@ -6,7 +6,9 @@ log() { handle_icwmp_update() { local defwan vendorspecinf update + local fallback_restart + fallback_restart="${1:-0}" update="0" defwan="$(uci -q get cwmp.cpe.default_wan_interface)" vendorspecinf="$(ifstatus "${defwan}" | jsonfilter -e "@.data.vendorspecinf")" @@ -76,18 +78,23 @@ handle_icwmp_update() { fi fi } + + # In case of update restart icwmp if [ "${update}" -eq "1" ]; then log "CWMP uci changes, reload cwmp with uci commit" ubus call uci commit '{"config":"cwmp"}' else - if ubus list tr069 >/dev/null 2>&1 ; then - log "Trigger out of bound inform" - ubus call tr069 inform - else - log "Restarting icwmp tr069 object not found" - /etc/init.d/icwmpd restart + status="$(ubus call tr069 status |jsonfilter -qe '@.last_session.status')" + if [ "$status" = "failure" ]; then + log "Trigger out of bound inform, since last inform status was failure" + ubus -t 10 call tr069 inform >/dev/null 2>&1 + # Handle timeout + if [ "$?" -eq 7 ]; then + log "Restarting icwmp tr069 object" + /etc/init.d/icwmpd restart + fi fi fi } -handle_icwmp_update +handle_icwmp_update $@ diff --git a/icwmp/files/etc/init.d/icwmpd b/icwmp/files/etc/init.d/icwmpd index 7f32e5f79..22dfe2862 100755 --- a/icwmp/files/etc/init.d/icwmpd +++ b/icwmp/files/etc/init.d/icwmpd @@ -102,6 +102,7 @@ validate_acs_section() 'periodic_inform_interval:uinteger' \ 'periodic_inform_time:string' \ 'url:string' \ + 'dhcp_discovery:string' \ 'dhcp_url:string' \ 'compression:or("GZIP","Deflate","Disabled")' \ 'retry_min_wait_interval:range(1, 65535)' \ @@ -168,10 +169,12 @@ start_service() { local enable_cwmp local wan_interface local dhcp_discovery + local dhcp_url config_load cwmp config_get_bool enable_cwmp cpe enable 1 - config_get dhcp_discovery acs dhcp_discovery + config_get dhcp_discovery acs dhcp_discovery "0" + config_get dhcp_url acs dhcp_url '' config_get wan_interface cpe default_wan_interface "wan" if [ "$enable_cwmp" = "0" ] || [ "$enable_cwmp" = "false" ]; then @@ -188,6 +191,13 @@ start_service() { [ -f /usr/sbin/dnsmasq ] && log "Waiting for DNS Proxy to be started ..." && ubus -t 5 wait_for dnsmasq [ -f /etc/config/dhcp ] && log "Waiting for DNS Server(s) ..." && wait_for_resolvfile 20 + if [ "${dhcp_discovery}" == "enable" ] || [ "${dhcp_discovery}" == "1" ]; then + if [ -z "${dhcp_url}" ]; then + log "Empty dhcp url, running update script" + /etc/icwmpd/update.sh + fi + fi + validate_defaults || { log "Validation of defaults failed" return 1; @@ -232,6 +242,7 @@ service_triggers() { json_add_array json_add_string "" "run_script" json_add_string "" "/etc/icwmpd/update.sh" + json_add_string "" "1" json_close_array json_close_array json_add_int "" "2000"