1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 OpenWrt.org
7 PROG=/usr/sbin/smartsnmpd
8 CONFIGFILE=/etc/smartsnmpd.conf
10 smartsnmpd_mib_module() {
12 config_get OID "$cfg" oid
13 config_get MODULE "$cfg" module
14 echo " ['$OID'] = '$MODULE'," >> $CONFIGFILE
18 include /lib/functions
20 config_load smartsnmpd
23 procd_set_param command $PROG -c $CONFIGFILE
24 procd_set_param file $CONFIGFILE
25 procd_set_param respawn
28 # before we can call xappend
29 mkdir -p $(dirname $CONFIGFILE)
31 echo "-- auto-generated config file from /etc/config/smartsnmpd" > $CONFIGFILE
33 config_get PORT smartsnmpd port 161
34 echo "port = $PORT" >> $CONFIGFILE
36 config_get RO_COMMUNITY smartsnmpd ro_community 'public'
37 config_get RW_COMMUNITY smartsnmpd rw_community 'private'
38 echo "ro_community = '$RO_COMMUNITY'" >> $CONFIGFILE
39 echo "rw_community = '$RW_COMMUNITY'" >> $CONFIGFILE
41 config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/'
42 echo "mib_module_path = '$MIB_MODULE_PATH'" >> $CONFIGFILE
44 echo "mib_modules = {" >> $CONFIGFILE
45 config_foreach smartsnmpd_mib_module smartsnmpd_module
46 echo "}" >> $CONFIGFILE