1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-27 12:57:42 +02:00
openwrt-xburst/package/trelay/files/trelay.init
nbd 751ddce336 add trelay, a trivial ethernet relay which allows pseudo-bridging ad-hoc or client mode devices over vlans to other hosts
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31122 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-03-28 11:02:38 +00:00

33 lines
688 B
Bash

#!/bin/sh /etc/rc.common
START=80
check_relay() {
local cfg="$1"
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return
config_get dev1 "$cfg" dev1
config_get dev2 "$cfg" dev2
[ -d "/sys/kernel/debug/trelay/${dev1}-${dev2}" ] && return
[ -d "/sys/class/net/${dev1}" -a -d "/sys/class/net/${dev2}" ] || return
ifconfig "$dev1" up
ifconfig "$dev2" up
echo "${dev1}-${dev2},${dev1},${dev2}" > /sys/kernel/debug/trelay/add
}
start() {
config_load trelay
config_foreach check_relay trelay
touch /var/run/trelay.active
}
stop() {
rm -f /var/run/trelay.active
for relay in /sys/kernel/debug/trelay/*; do
[ -d "$relay" ] && echo > "$relay/remove"
done
}