You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

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