procd: rework trigger handling
Open/close triggers array around service_triggers call to make using multiple triggers easier to deal with. The API was quite confusing, because some functions contained implicit trigger open/close calls and some didn't. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
eed30bc869
commit
8891d941e0
1 changed files with 16 additions and 8 deletions
|
@ -72,7 +72,9 @@ _procd_open_service() {
|
||||||
|
|
||||||
_procd_close_service() {
|
_procd_close_service() {
|
||||||
json_close_object
|
json_close_object
|
||||||
|
_procd_open_trigger
|
||||||
service_triggers
|
service_triggers
|
||||||
|
_procd_close_trigger
|
||||||
_procd_ubus_call set
|
_procd_ubus_call set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +119,27 @@ _procd_open_instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_open_trigger() {
|
_procd_open_trigger() {
|
||||||
|
let '_procd_trigger_open = _procd_trigger_open + 1'
|
||||||
|
[ "$_procd_trigger_open" -gt 1 ] && return
|
||||||
json_add_array "triggers"
|
json_add_array "triggers"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_procd_close_trigger() {
|
||||||
|
let '_procd_trigger_open = _procd_trigger_open - 1'
|
||||||
|
[ "$_procd_trigger_open" -lt 1 ] || return
|
||||||
|
json_close_array
|
||||||
|
}
|
||||||
|
|
||||||
_procd_open_validate() {
|
_procd_open_validate() {
|
||||||
|
json_select ..
|
||||||
json_add_array "validate"
|
json_add_array "validate"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_procd_close_validate() {
|
||||||
|
json_close_array
|
||||||
|
json_select triggers
|
||||||
|
}
|
||||||
|
|
||||||
_procd_add_jail() {
|
_procd_add_jail() {
|
||||||
json_add_object "jail"
|
json_add_object "jail"
|
||||||
json_add_string name "$1"
|
json_add_string name "$1"
|
||||||
|
@ -331,14 +347,6 @@ _procd_close_instance() {
|
||||||
json_close_object
|
json_close_object
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_close_trigger() {
|
|
||||||
json_close_array
|
|
||||||
}
|
|
||||||
|
|
||||||
_procd_close_validate() {
|
|
||||||
json_close_array
|
|
||||||
}
|
|
||||||
|
|
||||||
_procd_add_instance() {
|
_procd_add_instance() {
|
||||||
_procd_open_instance
|
_procd_open_instance
|
||||||
_procd_set_param command "$@"
|
_procd_set_param command "$@"
|
||||||
|
|
Loading…
Reference in a new issue