mirror of
https://github.com/openwrt/packages.git
synced 2026-01-11 16:00:23 +04:00
mini_snmpd: import 1.2b from oldpackages for reference http://git.openwrt.org/?p=packages.git;a=commit;h=787e4e15a2792eb4d059001e1fb8bc84da8d65fd
Signed-off-by: Luke McKee <hojuruku@gmail.com>
This commit is contained in:
65
net/mini_snmpd/files/mini_snmpd.init
Normal file
65
net/mini_snmpd/files/mini_snmpd.init
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
|
||||
START=50
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
|
||||
append_disk() {
|
||||
local disk="$1"
|
||||
append disks "$disk" ','
|
||||
}
|
||||
|
||||
append_interface() {
|
||||
local name="$1"
|
||||
local device
|
||||
network_get_device device "$name"
|
||||
append interfaces "${device:-$name}" ','
|
||||
}
|
||||
|
||||
append_string() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local value="$3"
|
||||
local _val
|
||||
config_get _val "$section" "$option"
|
||||
[ -n "$_val" ] && append args "$3 $_val"
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local args=""
|
||||
local disks=""
|
||||
local interfaces=""
|
||||
local ipv6
|
||||
|
||||
append_string "$cfg" community "-c"
|
||||
append_string "$cfg" location "-L"
|
||||
append_string "$cfg" contact "-C"
|
||||
|
||||
config_get_bool ipv6 "$cfg" "ipv6" '0'
|
||||
[ "$ipv6" -gt 0 ] && append args "-6"
|
||||
|
||||
config_get_bool enabled "$cfg" "enabled" '1'
|
||||
[ "$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
|
||||
}
|
||||
|
||||
start() {
|
||||
. /lib/functions/network.sh
|
||||
|
||||
config_load 'mini_snmpd'
|
||||
config_foreach start_instance 'mini_snmpd'
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/bin/mini_snmpd
|
||||
}
|
||||
Reference in New Issue
Block a user