diff options
Diffstat (limited to 'applications/luci-app-olsr-services/root/usr/libexec')
-rwxr-xr-x | applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services b/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services new file mode 100755 index 0000000000..20cf496e76 --- /dev/null +++ b/applications/luci-app-olsr-services/root/usr/libexec/rpcd/olsr-services @@ -0,0 +1,50 @@ +#!/bin/sh + +. /usr/share/libubox/jshn.sh +. /lib/functions.sh + +SERVICESFILE="-1" + +find_service_config() { + local cfg="$1" + + config_get library "$cfg" library + if [ "$library" != "olsrd_nameservice" ]; then + return 1 + fi + config_get services_file "$cfg" services_file + SERVICESFILE=$services_file +} + +load_services() { + local olsrd="$1" + config_load $olsrd + config_foreach find_service_config LoadPlugin + local services_configured=0 + if [ "$SERVICESFILE" != "-1" ]; then + services_configured=1 + fi + local services=$(cat $SERVICESFILE|grep -ve "^###"|grep -ve "^$") + json_init + json_add_boolean configured $services_configured + json_add_string source "$olsrd" + json_add_string services "$services" + json_dump +} + +case "$1" in + list) + # List method must return the list of methods and parameters that the daemon will accept. Only methods listed here will available to call. + echo '{ "services4": { }, "services6": { } }' + ;; + call) + case "$2" in + services4) + load_services "olsrd" + ;; + services6) + load_services "olsrd6" + ;; + esac + ;; +esac |