[OpenWrt-Devel] procd ubox jsonfilter: dev question. how to properly handle interface changes per instance only in init scripts

Luke McKee hojuruku at gmail.com
Fri Jul 8 16:35:46 EDT 2016

<hojuruku> https://github.com/hojuruku/openwrt-packages/blob/mini_snmpd/net/mini_snmpd/files/mini_snmpd.init
any comments on the script. I'd like some feedback on how to do per
instance restarts if an interface changes.
<hojuruku> i just updated it. its nearly done just for knowing how to
properly do per instance interface restarts so the daemons are only
reloaded if the interface they are bound to changes, whilst the other
instances are not restarted

The script is now using /sbin/validate_data / uci_validate_section()
to take configuration from uci.

You'll notice in the comments there are some issues with ash (no array
variables - not fixable)
And one with jsonfilter  and the other with /sbin/validate_data not
properly handling setting default variables. Will these get upstream

root at wifi:/etc/init.d# /etc/init.d/mini_snmpd start
{ "name": "mini_snmpd", "script": "\/etc\/init.d\/mini_snmpd",
"instances": { "instance1": { "command": [ "\/usr\/bin\/mini_snmpd",
"-n", "-c", "public", "-C", "Luke McKee <hojuruku at gmail.com>", "-t",
"2", "-a", "-d \/overlay,\/tmp", "-i loopback,lan,wan" ], "stdout":
true, "stderr": true, "respawn": [ "600", "10", "10" ] } },
"triggers": [ [ "config.change", [ "if", [ "eq", "package",
"mini_snmpd" ], [ "run_script", "\/etc\/init.d\/mini_snmpd", "reload"
] ] ] ], "validate": [ { "package": "mini_snmpd", "type":
"mini_snmpd", "data": { "enabled": "bool", "ipv6": "bool", "debug":
"bool", "auth": "bool", "community": "rangelength(1,32)", "contact":
"maxlength(255)", "location": "maxlength(255)", "listen_interface":
"(uciname)", "udp_port": "port", "tcp_port": "port", "vendor_oid":
"string", "mib_timeout": "and(min(1),uinteger)", "disks":
"list(directory)", "interfaces": "list(uciname)" } } ] }
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list