projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix invoking shell protocol handler scripts
[project/netifd.git]
/
proto
/
netifd-proto.sh
diff --git
a/proto/netifd-proto.sh
b/proto/netifd-proto.sh
index
f850216
..
b91863f
100755
(executable)
--- a/
proto/netifd-proto.sh
+++ b/
proto/netifd-proto.sh
@@
-1,15
+1,22
@@
. /usr/share/libubox/jshn.sh
. /usr/share/libubox/jshn.sh
+proto_config_add_generic() {
+ json_add_array ""
+ json_add_string "" "$1"
+ json_add_int "" "$2"
+ json_close_array
+}
+
proto_config_add_int() {
proto_config_add_int() {
-
json_add_int
"$1" 5
+
proto_config_add_generic
"$1" 5
}
proto_config_add_string() {
}
proto_config_add_string() {
-
json_add_int
"$1" 3
+
proto_config_add_generic
"$1" 3
}
proto_config_add_boolean() {
}
proto_config_add_boolean() {
-
json_add_int
"$1" 7
+
proto_config_add_generic
"$1" 7
}
add_default_handler() {
}
add_default_handler() {
@@
-19,7
+26,11
@@
add_default_handler() {
esac
}
esac
}
-case "$1" in
+proto="$1"
+cmd="$2"
+data="$3"
+
+case "$cmd" in
dump)
add_protocol() {
immediate=0
dump)
add_protocol() {
immediate=0
@@
-30,15
+41,21
@@
case "$1" in
json_add_string "name" "$1"
eval "$1_init"
json_add_boolean immediate "$immediate"
json_add_string "name" "$1"
eval "$1_init"
json_add_boolean immediate "$immediate"
- json_add_
object
"config"
+ json_add_
array
"config"
eval "$1_init_config"
eval "$1_init_config"
- json_close_
object
+ json_close_
array
json_dump
}
;;
*)
add_protocol() {
json_dump
}
;;
*)
add_protocol() {
- return;
+ [[ "$proto" == "$1" ]] || return 0
+
+ case "$cmd" in
+ setup) eval "$1_setup \"\$data\"" ;;
+ teardown) eval "$1_teardown \"\$data\"" ;;
+ *) return 1 ;;
+ esac
}
;;
esac
}
;;
esac