2006-10-04 20:57:49 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2012-05-29 01:11:32 +00:00
|
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
2011-11-09 23:47:06 +00:00
|
|
|
|
2007-05-10 10:38:53 +00:00
|
|
|
START=50
|
2006-08-07 12:34:24 +00:00
|
|
|
|
2011-11-09 23:47:06 +00:00
|
|
|
SERVICE_DAEMONIZE=1
|
2011-11-17 10:47:23 +00:00
|
|
|
SERVICE_WRITE_PID=1
|
2011-11-09 23:47:06 +00:00
|
|
|
|
2011-11-17 10:47:23 +00:00
|
|
|
append_bool() {
|
|
|
|
local var="$1"
|
|
|
|
local section="$2"
|
|
|
|
local option="$3"
|
|
|
|
local value="$4"
|
|
|
|
local _val
|
|
|
|
config_get_bool _val "$section" "$option" 0
|
|
|
|
[ $_val -gt 0 ] && append "$var" "$value"
|
|
|
|
}
|
|
|
|
|
|
|
|
append_string() {
|
|
|
|
local var="$1"
|
|
|
|
local section="$2"
|
|
|
|
local option="$3"
|
|
|
|
local val="$4"
|
|
|
|
local _val
|
|
|
|
config_get _val "$section" "$option"
|
|
|
|
[ -n "$_val" ] && append "$var" "$val $_val"
|
|
|
|
}
|
|
|
|
|
|
|
|
section_enabled() {
|
|
|
|
local enabled
|
|
|
|
config_get_bool enabled "$1" 'enabled' 0
|
|
|
|
[ $enabled -gt 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
start_instance() {
|
|
|
|
local section="$1"
|
|
|
|
local if
|
2012-05-29 01:11:32 +00:00
|
|
|
local dev
|
2011-11-17 10:47:23 +00:00
|
|
|
local args
|
|
|
|
|
|
|
|
section_enabled "$section" || return 1
|
|
|
|
|
2012-05-29 01:11:32 +00:00
|
|
|
config_get if "$section" 'interface' 'lan'
|
|
|
|
network_get_device dev "$if" && {
|
|
|
|
args="-n -i $if"
|
|
|
|
append_string args "$section" 'ethers' '-e'
|
|
|
|
append_bool args "$section" 'verbose' '-v'
|
2011-11-17 10:47:23 +00:00
|
|
|
|
2012-05-29 01:11:32 +00:00
|
|
|
SERVICE_PID_FILE="/var/run/rarpd-${if}.pid"
|
|
|
|
service_start /usr/sbin/rarpd $args
|
|
|
|
}
|
2011-11-17 10:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_instance() {
|
|
|
|
local section="$1"
|
|
|
|
local id
|
|
|
|
local if
|
2012-05-29 01:11:32 +00:00
|
|
|
local dev
|
2011-11-17 10:47:23 +00:00
|
|
|
|
|
|
|
section_enabled "$section" || return 1
|
|
|
|
|
2012-05-29 01:11:32 +00:00
|
|
|
config_get if "$section" 'interface' 'lan'
|
|
|
|
network_get_device dev "$if"
|
2011-11-17 10:47:23 +00:00
|
|
|
|
|
|
|
SERVICE_PID_FILE="/var/run/rarpd-${if}.pid"
|
|
|
|
service_stop /usr/sbin/rarpd
|
|
|
|
}
|
2006-08-07 12:34:24 +00:00
|
|
|
|
2006-10-04 20:57:49 +00:00
|
|
|
start() {
|
2012-05-29 01:11:32 +00:00
|
|
|
. /lib/functions/network.sh
|
2011-11-17 10:47:23 +00:00
|
|
|
config_load 'rarpd'
|
|
|
|
config_foreach start_instance 'rarpd'
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
2011-11-09 23:47:06 +00:00
|
|
|
|
2006-10-04 20:57:49 +00:00
|
|
|
stop() {
|
2012-05-29 01:11:32 +00:00
|
|
|
. /lib/functions/network.sh
|
2011-11-17 10:47:23 +00:00
|
|
|
config_load 'rarpd'
|
|
|
|
config_foreach stop_instance 'rarpd'
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|