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.

49 lines
1.1 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. {
  25. config_get PORT smartsnmpd port 161
  26. echo "port = $PORT"
  27. config_get RO_COMMUNITY smartsnmpd ro_community 'public'
  28. config_get RW_COMMUNITY smartsnmpd rw_community 'private'
  29. echo "ro_community = '$RO_COMMUNITY'"
  30. echo "rw_community = '$RW_COMMUNITY'"
  31. config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/'
  32. echo "mib_module_path = '$MIB_MODULE_PATH'"
  33. echo "mib_modules = {"
  34. config_foreach smartsnmpd_mib_module smartsnmpd_module
  35. echo "}"
  36. } >> $CONFIGFILE
  37. }