packages/net/smartsnmpd/files/smartsnmpd.init
Xiongfei Guo 6bfb2ef4bd Add smartsnmpd.
smartsnmpd is an implementation of SNMP Agent developed by Credo Semi. It
use Lua as script language to write SNMP MIB nodes to improve the efficiency
of developtment.

This package add native support for OpenWrt. Include using ubus and uci to
get status/info. And, it use uloop as low level event library. So it's
some sort of desgin for OpenWrt.

Website: https://github.com/credosemi/smartsnmp

Signed-off-by: Leo Ma <leoma@credosemi.com>
Signed-off-by: Xiongfei Guo <xfguo@credosemi.com>
2014-08-13 14:04:05 +08:00

47 lines
1.2 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org
START=97
USE_PROCD=1
PROG=/usr/sbin/smartsnmpd
CONFIGFILE=/etc/smartsnmpd.conf
smartsnmpd_mib_module() {
local cfg="$1"
config_get OID "$cfg" oid
config_get MODULE "$cfg" module
echo " ['$OID'] = '$MODULE'," >> $CONFIGFILE
}
start_service() {
include /lib/functions
config_load smartsnmpd
procd_open_instance
procd_set_param command $PROG -c $CONFIGFILE
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
# before we can call xappend
mkdir -p $(dirname $CONFIGFILE)
echo "-- auto-generated config file from /etc/config/smartsnmpd" > $CONFIGFILE
config_get PORT smartsnmpd port 161
echo "port = $PORT" >> $CONFIGFILE
config_get RO_COMMUNITY smartsnmpd ro_community 'public'
config_get RW_COMMUNITY smartsnmpd rw_community 'private'
echo "ro_community = '$RO_COMMUNITY'" >> $CONFIGFILE
echo "rw_community = '$RW_COMMUNITY'" >> $CONFIGFILE
config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/'
echo "mib_module_path = '$MIB_MODULE_PATH'" >> $CONFIGFILE
echo "mib_modules = {" >> $CONFIGFILE
config_foreach smartsnmpd_mib_module smartsnmpd_module
echo "}" >> $CONFIGFILE
}