smartsnmpd.init (1229B)
1 #!/bin/sh /etc/rc.common 2 # Copyright (C) 2014 OpenWrt.org 3 4 START=97 5 6 USE_PROCD=1 7 PROG=/usr/sbin/smartsnmpd 8 CONFIGFILE=/etc/smartsnmpd.conf 9 10 smartsnmpd_mib_module() { 11 local cfg="$1" 12 config_get OID "$cfg" oid 13 config_get MODULE "$cfg" module 14 echo " ['$OID'] = '$MODULE'," >> $CONFIGFILE 15 } 16 17 start_service() { 18 include /lib/functions 19 20 config_load smartsnmpd 21 22 procd_open_instance 23 procd_set_param command $PROG -c $CONFIGFILE 24 procd_set_param file $CONFIGFILE 25 procd_set_param respawn 26 procd_close_instance 27 28 # before we can call xappend 29 mkdir -p $(dirname $CONFIGFILE) 30 31 echo "-- auto-generated config file from /etc/config/smartsnmpd" > $CONFIGFILE 32 33 config_get PORT smartsnmpd port 161 34 echo "port = $PORT" >> $CONFIGFILE 35 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 40 41 config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/' 42 echo "mib_module_path = '$MIB_MODULE_PATH'" >> $CONFIGFILE 43 44 echo "mib_modules = {" >> $CONFIGFILE 45 config_foreach smartsnmpd_mib_module smartsnmpd_module 46 echo "}" >> $CONFIGFILE 47 }