[package] add a config file and init script to mini_snmpd (#5496)
[openwrt/svn-archive/archive.git] / net / mini_snmpd / files / mini_snmpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2009 OpenWrt.org
3
4 NAME=mini_snmpd
5 PROG=/usr/bin/$NAME
6 START=50
7
8 append_string() {
9 local section="$1"
10 local option="$2"
11 local value="$3"
12 local _val
13 config_get _val "$section" "$option"
14 [ -n "$_val" ] && append args "$3 $_val"
15 }
16
17 mini_snmpd_config() {
18 local cfg="$1"
19 args=""
20
21 append_string "$cfg" community "-c"
22 append_string "$cfg" location "-L"
23 append_string "$cfg" contact "-C"
24 append_string "$cfg" disks "-d"
25 append_string "$cfg" interfaces "-i"
26
27 config_get_bool enabled "$cfg" "enabled" '1'c
28 [ "$enabled" -gt 0 ] && $PROG $args &
29 }
30
31 start() {
32 config_load mini_snmpd
33 config_foreach mini_snmpd_config mini_snmpd
34 }
35
36 stop() {
37 killall mini_snmpd
38 }