mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-20 01:20:35 +08:00
Compare commits
1 Commits
sysmngr_co
...
ticket_827
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1449a635a2 |
@@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=icwmp
|
||||
PKG_VERSION:=8.4.21
|
||||
PKG_VERSION:=8.4.23
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git
|
||||
PKG_SOURCE_VERSION:=3ddb80f5fcb89273620ce41fb4f7b7d4b754c9eb
|
||||
PKG_SOURCE_VERSION:=179bc275edf62532ad1cad98fea74eaece9961d6
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
|
||||
@@ -1,104 +1,27 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
log() {
|
||||
echo "$@" |logger -t cwmp.update -p info
|
||||
}
|
||||
|
||||
handle_icwmp_update() {
|
||||
local defwan vendorspecinf update
|
||||
local bootup_start
|
||||
local cwmp_enable
|
||||
config_load cwmp
|
||||
|
||||
bootup_start="${1:-0}"
|
||||
update="0"
|
||||
defwan="$(uci -q get cwmp.cpe.default_wan_interface)"
|
||||
vendorspecinf="$(ifstatus "${defwan}" | jsonfilter -e "@.data.vendorspecinf")"
|
||||
|
||||
log "Handling dhcp option value [${vendorspecinf}]"
|
||||
[ -n "$vendorspecinf" ] && {
|
||||
local url old_url
|
||||
local prov_code old_prov_code
|
||||
local min_wait_interval old_min_wait_interval
|
||||
local retry_interval_multiplier old_retry_interval_multiplier
|
||||
|
||||
old_url="$(uci -q get cwmp.acs.dhcp_url)"
|
||||
old_prov_code="$(uci -q get cwmp.cpe.dhcp_provisioning_code)"
|
||||
old_min_wait_interval="$(uci -q get cwmp.acs.dhcp_retry_min_wait_interval)"
|
||||
old_retry_interval_multiplier="$(uci -q get cwmp.acs.dhcp_retry_interval_multiplier)"
|
||||
|
||||
case $vendorspecinf in
|
||||
http://*|https://*)
|
||||
url="${vendorspecinf}"
|
||||
;;
|
||||
*)
|
||||
for optval in $vendorspecinf; do
|
||||
case $optval in
|
||||
1=*)
|
||||
url="$(echo "$optval" | cut -d"=" -f2-)"
|
||||
;;
|
||||
2=*)
|
||||
prov_code="$(echo "$optval" | cut -d"=" -f2-)"
|
||||
;;
|
||||
3=*)
|
||||
min_wait_interval="$(echo "$optval" | cut -d"=" -f2-)"
|
||||
;;
|
||||
4=*)
|
||||
retry_interval_multiplier="$(echo "$optval" | cut -d"=" -f2-)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$url" ]; then
|
||||
if [ "${url}" != "${old_url}" ]; then
|
||||
log "## icwmp url[${old_url}] changed to [${url}]"
|
||||
uci -q set cwmp.acs.dhcp_url="$url"
|
||||
update=1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$prov_code" ]; then
|
||||
if [ "${prov_code}" != "${old_prov_code}" ]; then
|
||||
log "## icwmp prov_code[${old_prov_code}] changed to [${prov_code}]"
|
||||
uci -q set cwmp.cpe.dhcp_provisioning_code="$prov_code"
|
||||
update=1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$min_wait_interval" ]; then
|
||||
if [ "${min_wait_interval}" != "${old_min_wait_interval}" ]; then
|
||||
log "## icwmp min_wait_interval[${old_min_wait_interval}] changed to [${min_wait_interval}]"
|
||||
uci -q set cwmp.acs.dhcp_retry_min_wait_interval="$min_wait_interval"
|
||||
update=1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$retry_interval_multiplier" ]; then
|
||||
if [ "${retry_interval_multiplier}" != "${old_retry_interval_multiplier}" ]; then
|
||||
log "## icwmp retry_interval_multiplier[${old_retry_interval_multiplier}] changed to [${retry_interval_multiplier}]"
|
||||
uci -q set cwmp.acs.dhcp_retry_interval_multiplier="$retry_interval_multiplier"
|
||||
update=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${bootup_start}" -eq "1" ]; then
|
||||
# if called at boot up then no need to reload the service, since it will start after
|
||||
uci commit cwmp
|
||||
config_get_bool cwmp_enable cpe enable 1
|
||||
if [ "$cwmp_enable" = "0" ]; then
|
||||
return 0
|
||||
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
|
||||
status="$(ubus call tr069 status |jsonfilter -qe '@.last_session.status')"
|
||||
if [ "$status" = "failure" ] || [ "$status" = "" ]; 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 or tr069 object not found
|
||||
if [ "$?" -eq 7 ] || [ "$?" -eq 4 ]; then
|
||||
log "Restarting icwmp tr069 object"
|
||||
/etc/init.d/icwmpd restart
|
||||
fi
|
||||
status="$(ubus call tr069 status |jsonfilter -qe '@.last_session.status')"
|
||||
if [ "$status" != "running" ]; 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 or tr069 object not found
|
||||
if [ "$?" -eq 7 ] || [ "$?" -eq 4 ]; then
|
||||
log "Restarting icwmp tr069 object"
|
||||
/etc/init.d/icwmpd restart
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -198,7 +198,6 @@ boot() {
|
||||
# Set dhcp option 43 if not already configured
|
||||
config_get wan_interface cpe default_wan_interface "wan"
|
||||
enable_dhcp_option43 "${wan_interface}"
|
||||
/etc/icwmpd/update.sh 1
|
||||
fi
|
||||
|
||||
config_get ssl_capath acs ssl_capath
|
||||
@@ -212,14 +211,11 @@ boot() {
|
||||
|
||||
start_service() {
|
||||
local enable_cwmp
|
||||
local wan_interface
|
||||
|
||||
config_load cwmp
|
||||
config_get_bool enable_cwmp cpe enable 1
|
||||
config_get wan_interface cpe default_wan_interface "wan"
|
||||
|
||||
if [ "$enable_cwmp" = "0" ] || [ "$enable_cwmp" = "false" ]; then
|
||||
log "CWMP is not enabled"
|
||||
if [ "$enable_cwmp" = "0" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -252,9 +248,20 @@ service_stopped()
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
log "Reloading CWMP client"
|
||||
ubus -t 1 call tr069 command '{"command":"reload"}'
|
||||
if [ "$?" -ne "0" ]; then
|
||||
config_load cwmp
|
||||
config_get_bool enable_cwmp cpe enable 1
|
||||
|
||||
if [ "$enable_cwmp" = "0" ]; then
|
||||
stop
|
||||
return 0
|
||||
fi
|
||||
|
||||
status="$(ubus -t 1 call tr069 status |jsonfilter -qe '@.cwmp.status')"
|
||||
if [ "$status" = "up" ]; then
|
||||
ubus -t 1 call tr069 command '{"command":"reload"}'
|
||||
fi
|
||||
|
||||
if [ "$status" = "init" ] || [ "$?" -ne "0" ]; then
|
||||
log "Restarting CWMP client"
|
||||
stop
|
||||
start
|
||||
@@ -263,18 +270,5 @@ reload_service() {
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "cwmp"
|
||||
|
||||
procd_open_trigger
|
||||
json_add_array
|
||||
json_add_string "" "interface.update"
|
||||
json_add_array
|
||||
json_add_array
|
||||
json_add_string "" "run_script"
|
||||
json_add_string "" "/etc/icwmpd/update.sh"
|
||||
json_close_array
|
||||
json_close_array
|
||||
json_add_int "" "2000"
|
||||
json_close_array
|
||||
procd_close_trigger
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
# Copy defaults by the factory to the cwmp UCI user section.
|
||||
config_load cwmp
|
||||
|
||||
# Get Manufacturer OUI.
|
||||
oui=$(uci -q get cwmp.cpe.manufacturer_oui)
|
||||
config_get oui cpe manufacturer_oui ""
|
||||
if [ -z "${oui}" ]; then
|
||||
oui=$(db -q get device.deviceinfo.ManufacturerOUI)
|
||||
fi
|
||||
@@ -9,24 +13,29 @@ fi
|
||||
oui=$(echo "${oui}" | tr 'a-f' 'A-F')
|
||||
|
||||
# Get system serial number.
|
||||
serial=$(uci -q get cwmp.cpe.serial_number)
|
||||
config_get serial cpe serial_number ""
|
||||
if [ -z "${serial}" ]; then
|
||||
serial=$(db -q get device.deviceinfo.SerialNumber)
|
||||
fi
|
||||
|
||||
# Get userid values
|
||||
acs_userid=$(uci -q get cwmp.acs.userid)
|
||||
cpe_userid=$(uci -q get cwmp.cpe.userid)
|
||||
config_get acs_userid acs userid ""
|
||||
config_get cpe_userid cpe userid ""
|
||||
|
||||
# Only set if they are empty
|
||||
if [ -z "$acs_userid" ]
|
||||
then
|
||||
if [ -z "${acs_userid}" ]; then
|
||||
uci -q set cwmp.acs.userid="${oui}-${serial}"
|
||||
fi
|
||||
|
||||
if [ -z "$cpe_userid" ]
|
||||
then
|
||||
if [ -z "${cpe_userid}" ]; then
|
||||
uci -q set cwmp.cpe.userid="${oui}-${serial}"
|
||||
fi
|
||||
|
||||
# Fix the cwmp.cpe.enable parameter
|
||||
# set default to 1 if not defined
|
||||
config_get enable_cwmp cpe enable ""
|
||||
if [ -z "${enable_cwmp}" ]; then
|
||||
uci -q set cwmp.cpe.enable="1"
|
||||
fi
|
||||
|
||||
# No need for commit here, it is done by uci_apply_defaults().
|
||||
|
||||
Reference in New Issue
Block a user