3f579aba93
git-svn-id: svn://svn.openwrt.org/openwrt/packages@32061 3c298f89-4303-0410-b956-a3cf2f4a3e73
61 lines
1.0 KiB
Bash
61 lines
1.0 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2011 OpenWrt.org
|
|
|
|
. /lib/functions.sh
|
|
. /lib/batman-adv/config.sh
|
|
|
|
start_mesh() {
|
|
local mesh="$1"
|
|
local ifaces=$(awk -F':' '{if (NR > 2) print $1}' /proc/net/dev)
|
|
|
|
for iface in $ifaces; do
|
|
[ -d /sys/class/net/$iface/batman_adv/ ] && bat_add_interface "$mesh" "$iface"
|
|
done
|
|
|
|
bat_config "$mesh"
|
|
}
|
|
|
|
stop_mesh() {
|
|
local mesh="$1"
|
|
local ifaces=$(awk -F':' '{if (NR > 2) print $1}' /proc/net/dev)
|
|
|
|
for iface in $ifaces; do
|
|
[ -d /sys/class/net/$iface/batman_adv/ ] && bat_del_interface "$mesh" "$iface"
|
|
done
|
|
}
|
|
|
|
# can also be used with "batman-adv start bat0"
|
|
start() {
|
|
bat_load_module
|
|
config_load batman-adv
|
|
|
|
if [ -n "$1" ]; then
|
|
start_mesh $1
|
|
else
|
|
config_foreach start_mesh mesh
|
|
fi
|
|
}
|
|
|
|
# can also be used with "batman-adv stop bat0"
|
|
stop () {
|
|
config_load batman-adv
|
|
|
|
if [ -n "$1" ]; then
|
|
stop_mesh $1
|
|
else
|
|
config_foreach stop_mesh mesh
|
|
fi
|
|
}
|
|
|
|
restart() {
|
|
stop $1
|
|
start $1
|
|
}
|
|
|
|
case "$1" in
|
|
start) start $2 ;;
|
|
stop) stop $2 ;;
|
|
restart) restart $2 ;;
|
|
*) echo "Usage: batman-adv <start|stop|restart> [mesh instance]"
|
|
esac
|