2009-07-11 11:26:37 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2012-05-28 15:35:45 +00:00
|
|
|
# Copyright (C) 2009-2012 OpenWrt.org
|
2009-07-11 11:26:37 +00:00
|
|
|
|
|
|
|
START=50
|
|
|
|
|
2011-11-16 09:44:31 +00:00
|
|
|
SERVICE_DAEMONIZE=1
|
|
|
|
SERVICE_WRITE_PID=1
|
|
|
|
|
|
|
|
append_disk() {
|
|
|
|
local disk="$1"
|
|
|
|
append disks "$disk" ','
|
|
|
|
}
|
|
|
|
|
|
|
|
append_interface() {
|
|
|
|
local name="$1"
|
2012-05-28 15:35:45 +00:00
|
|
|
local device
|
|
|
|
network_get_device device "$name"
|
|
|
|
append interfaces "${device:-$name}" ','
|
2011-11-16 09:44:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-11 11:26:37 +00:00
|
|
|
append_string() {
|
|
|
|
local section="$1"
|
|
|
|
local option="$2"
|
|
|
|
local value="$3"
|
|
|
|
local _val
|
|
|
|
config_get _val "$section" "$option"
|
|
|
|
[ -n "$_val" ] && append args "$3 $_val"
|
|
|
|
}
|
|
|
|
|
2011-11-16 09:44:31 +00:00
|
|
|
start_instance() {
|
2009-07-11 11:26:37 +00:00
|
|
|
local cfg="$1"
|
2011-11-16 09:44:31 +00:00
|
|
|
local args=""
|
|
|
|
local disks=""
|
|
|
|
local interfaces=""
|
|
|
|
local ipv6
|
2009-07-11 11:26:37 +00:00
|
|
|
|
|
|
|
append_string "$cfg" community "-c"
|
|
|
|
append_string "$cfg" location "-L"
|
|
|
|
append_string "$cfg" contact "-C"
|
2011-05-04 19:07:17 +00:00
|
|
|
|
|
|
|
config_get_bool ipv6 "$cfg" "ipv6" '0'
|
|
|
|
[ "$ipv6" -gt 0 ] && append args "-6"
|
|
|
|
|
|
|
|
config_get_bool enabled "$cfg" "enabled" '1'
|
2011-11-16 09:44:31 +00:00
|
|
|
[ "$enabled" -gt 0 ] || return 1
|
|
|
|
|
|
|
|
config_list_foreach "$section" 'disks' append_disk
|
|
|
|
args="${args}${disks:+ -d $disks}"
|
|
|
|
|
|
|
|
config_list_foreach "$section" 'interfaces' append_interface
|
|
|
|
args="${args}${interfaces:+ -i $interfaces}"
|
|
|
|
|
|
|
|
service_start /usr/bin/mini_snmpd $args
|
2009-07-11 11:26:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2012-05-28 15:35:45 +00:00
|
|
|
. /lib/functions/network.sh
|
|
|
|
|
2011-11-16 09:44:31 +00:00
|
|
|
config_load 'mini_snmpd'
|
|
|
|
config_foreach start_instance 'mini_snmpd'
|
2009-07-11 11:26:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2011-11-16 09:44:31 +00:00
|
|
|
service_stop /usr/bin/mini_snmpd
|
2009-07-11 11:26:37 +00:00
|
|
|
}
|