mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-11 03:28:31 +01:00
update script
This commit is contained in:
parent
0d0712100f
commit
eef23e07e0
3 changed files with 83 additions and 36 deletions
|
|
@ -10,7 +10,7 @@
|
|||
# define a 'name' command-line string flag
|
||||
DEFINE_boolean 'newline' false 'do not output the trailing newline' 'n'
|
||||
DEFINE_boolean 'value' false 'output values only' 'v'
|
||||
DEFINE_boolean 'ubus' false 'send values using ubus' 'b'
|
||||
DEFINE_boolean 'json' false 'send values using ubus' 'j'
|
||||
DEFINE_boolean 'empty' false 'output empty parameters' 'e'
|
||||
DEFINE_boolean 'last' false 'output only last line ; for parameters that tend to have huge output' 'l'
|
||||
DEFINE_boolean 'debug' false 'give debug output' 'd'
|
||||
|
|
@ -496,12 +496,7 @@ if [ "$action" = "apply_notification" -o "$action" = "apply_value" ]; then
|
|||
if [ "$__fault_count" = "0" ]; then
|
||||
# applying
|
||||
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
|
||||
if [ "$action" = "apply_value" ]; then
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 SetParameterValuesStatus '{ "status": "0" }' 2> /dev/null
|
||||
fi
|
||||
if [ "$action" = "apply_notification" ]; then
|
||||
freecwmp_fault_output "" "" "0"
|
||||
fi
|
||||
freecwmp_output "" "" "" "" "" "0"
|
||||
else
|
||||
let n=$__fault_count-1
|
||||
for i in `seq 0 $n`
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ freecwmp_output() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$FLAGS_ubus" = "${FLAGS_TRUE}" ]; then
|
||||
if [ "$FLAGS_json" = "${FLAGS_TRUE}" ]; then
|
||||
local parameter="$1"
|
||||
local value="$2"
|
||||
local permissions="$3"
|
||||
|
|
@ -44,12 +44,13 @@ freecwmp_output() {
|
|||
local status="$6"
|
||||
local instance="$7"
|
||||
|
||||
freecwmp_ubus_output "$parameter" "$value" "$permissions" "$type" "$fault_code" "$status" "$instance"
|
||||
echo `freecwmp_json_output "$parameter" "$value" "$permissions" "$type" "$fault_code" "$status" "$instance"`
|
||||
fi
|
||||
}
|
||||
|
||||
freecwmp_ubus_output() {
|
||||
freecwmp_json_output() {
|
||||
|
||||
local MSG=""
|
||||
local parameter="$1"
|
||||
local value="$2"
|
||||
local permissions="$3"
|
||||
|
|
@ -61,90 +62,139 @@ freecwmp_ubus_output() {
|
|||
if [ "$type" = "" ]; then
|
||||
type="xsd:string"
|
||||
fi
|
||||
|
||||
|
||||
case "$action" in
|
||||
get_value)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 GetParameterValues '{ "parameter": "'$parameter'", "value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'" }' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "parameter" "$parameter"
|
||||
json_add_string "value" "$value"
|
||||
json_add_string "type" "$type"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
get_name)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 GetParameterNames '{ "parameter": "'$parameter'", "writable": "'$permissions'", "fault_code": "'$fault_code'" }' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "parameter" "$parameter"
|
||||
json_add_string "writable" "$permissions"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
get_notification)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 GetParameterAttributes '{ "parameter": "'$parameter'", "notification": "'$value'", "fault_code": "'$fault_code'" }' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "parameter" "$parameter"
|
||||
json_add_string "notification" "$value"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
add_object)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 AddObject '{"instance":"'$instance'", "status":"'$status'", "fault_code":"'$fault_code'"}' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "instance" "$instance"
|
||||
json_add_string "status" "$status"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
delete_object)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 DelObject '{ "status": "'$status'", "fault_code": "'$fault_code'" }' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "status" "$status"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
apply_value|\
|
||||
apply_notification)
|
||||
json_init
|
||||
json_add_string "status" "$status"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$MSG"
|
||||
}
|
||||
|
||||
freecwmp_fault_output() {
|
||||
|
||||
local MSG=""
|
||||
local parameter="$1"
|
||||
local fault_code="$2"
|
||||
local success="$3"
|
||||
|
||||
case "$action" in
|
||||
apply_value)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 SetParameterValuesFault '{"parameter": "'$parameter'", "fault_code": "'$fault_code'"}' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "parameter" "$parameter"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
apply_notification)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 SetParameterAttributes '{"success": "'$success'", "fault_code": "'$fault_code'"}' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "success" "$success"
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
*download)
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 downloadFault '{"fault_code": "'$fault_code'"}' 2> /dev/null
|
||||
json_init
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$MSG"
|
||||
}
|
||||
|
||||
freecwmp_value_output() {
|
||||
local tmp_value=${FLAGS_value}
|
||||
FLAGS_value=${FLAGS_TRUE}
|
||||
local tmp_ubus=${FLAGS_ubus}
|
||||
FLAGS_ubus=${FLAGS_FALSE}
|
||||
local tmp_json=${FLAGS_json}
|
||||
FLAGS_json=${FLAGS_FALSE}
|
||||
|
||||
freecwmp_output "$1" "$2" "V"
|
||||
|
||||
FLAGS_value=$tmp_value
|
||||
FLAGS_ubus=$tmp_ubus
|
||||
FLAGS_json=$tmp_json
|
||||
}
|
||||
|
||||
freecwmp_notification_output() {
|
||||
local tmp_value=${FLAGS_value}
|
||||
FLAGS_value=${FLAGS_TRUE}
|
||||
local tmp_ubus=${FLAGS_ubus}
|
||||
FLAGS_ubus=${FLAGS_FALSE}
|
||||
local tmp_json=${FLAGS_json}
|
||||
FLAGS_json=${FLAGS_FALSE}
|
||||
|
||||
freecwmp_output "$1" "$2" "N"
|
||||
|
||||
FLAGS_value=$tmp_value
|
||||
FLAGS_ubus=$tmp_ubus
|
||||
FLAGS_json=$tmp_json
|
||||
}
|
||||
|
||||
freecwmp_tags_output() {
|
||||
local tmp_value=${FLAGS_value}
|
||||
FLAGS_value=${FLAGS_TRUE}
|
||||
local tmp_ubus=${FLAGS_ubus}
|
||||
FLAGS_ubus=${FLAGS_FALSE}
|
||||
local tmp_json=${FLAGS_json}
|
||||
FLAGS_json=${FLAGS_FALSE}
|
||||
|
||||
freecwmp_output "$1" "$2" "T"
|
||||
|
||||
FLAGS_value=$tmp_value
|
||||
FLAGS_ubus=$tmp_ubus
|
||||
FLAGS_json=$tmp_json
|
||||
}
|
||||
|
||||
freecwmp_not_implemented() {
|
||||
local tmp_value=${FLAGS_value}
|
||||
FLAGS_value=${FLAGS_TRUE}
|
||||
local tmp_ubus=${FLAGS_ubus}
|
||||
FLAGS_ubus=${FLAGS_FALSE}
|
||||
local tmp_json=${FLAGS_json}
|
||||
FLAGS_json=${FLAGS_FALSE}
|
||||
|
||||
freecwmp_output "$1" "NOT_IMPLEMENTED"
|
||||
|
||||
FLAGS_value=$tmp_value
|
||||
FLAGS_ubus=$tmp_ubus
|
||||
FLAGS_json=$tmp_json
|
||||
}
|
||||
|
||||
freecwmp_parse_formated_parameter() {
|
||||
|
|
|
|||
|
|
@ -25,11 +25,12 @@ freecwmp_output "$parm" "$val" "$permissions"
|
|||
|
||||
set_management_server_url() {
|
||||
local parm="InternetGatewayDevice.ManagementServer.URL"
|
||||
local type="xsd:string"
|
||||
case "$action" in
|
||||
set_value)
|
||||
local url=$1
|
||||
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.acs.url="$val"
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 notify '{ "parameter": "'$parm'", "value": "'$val'", "type": "'$type'" }' 2>&1 > dev/null &
|
||||
;;
|
||||
set_notification)
|
||||
local val=$1
|
||||
|
|
@ -123,11 +124,12 @@ freecwmp_output "$parm" "$val" "$permissions"
|
|||
|
||||
set_management_server_parameter_key() {
|
||||
local parm="InternetGatewayDevice.ManagementServer.ParameterKey"
|
||||
local type="xsd:string"
|
||||
case "$action" in
|
||||
set_value)
|
||||
local val=$1
|
||||
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.acs.ParameterKey="$val"
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": "value_change" }' &
|
||||
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 notify '{ "parameter": "'$parm'", "value": "'$val'", "type": "'$type'" }' 2>&1 > dev/null
|
||||
;;
|
||||
set_notification)
|
||||
local val=$1
|
||||
|
|
@ -209,12 +211,12 @@ case "$action" in
|
|||
if [ -z "$default_management_server_connection_request_url" ]; then
|
||||
local tmp_value=${FLAGS_value}
|
||||
FLAGS_value=${FLAGS_TRUE}
|
||||
local tmp_ubus=${FLAGS_ubus}
|
||||
FLAGS_ubus=${FLAGS_FALSE}
|
||||
local tmp_json=${FLAGS_json}
|
||||
FLAGS_json=${FLAGS_FALSE}
|
||||
local ip=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get cwmp.cpe.ip`
|
||||
local port=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.port`
|
||||
FLAGS_value=$tmp_value
|
||||
FLAGS_ubus=$tmp_ubus
|
||||
FLAGS_json=$tmp_json
|
||||
|
||||
if [ -n "$ip" -a -n "$port" ]; then
|
||||
val="http://$ip:$port/"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue