procd: service_data: Support data within the service itself

Use the same approach than the service_triggers for the service_data.

Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
This commit is contained in:
Pierre Lebleu 2017-10-25 18:05:15 +02:00 committed by John Crispin
parent ff56bb0dfb
commit 832b6b8305
2 changed files with 19 additions and 0 deletions

View file

@ -88,6 +88,10 @@ service_triggers() {
return 0 return 0
} }
service_data() {
return 0
}
service_running() { service_running() {
return 0 return 0
} }

View file

@ -79,6 +79,9 @@ _procd_close_service() {
_procd_open_trigger _procd_open_trigger
service_triggers service_triggers
_procd_close_trigger _procd_close_trigger
_procd_open_data
service_data
_procd_close_data
_procd_ubus_call ${1:-set} _procd_ubus_call ${1:-set}
} }
@ -134,6 +137,18 @@ _procd_close_trigger() {
json_close_array json_close_array
} }
_procd_open_data() {
let '_procd_data_open = _procd_data_open + 1'
[ "$_procd_data_open" -gt 1 ] && return
json_add_object "data"
}
_procd_close_data() {
let '_procd_data_open = _procd_data_open - 1'
[ "$_procd_data_open" -lt 1 ] || return
json_close_object
}
_procd_open_validate() { _procd_open_validate() {
json_select .. json_select ..
json_add_array "validate" json_add_array "validate"