2010-05-23 13:17:09 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
START=90
|
|
|
|
|
2010-07-01 15:10:19 +00:00
|
|
|
is_module_loaded() {
|
2010-05-23 13:17:09 +00:00
|
|
|
|
2010-07-01 15:10:19 +00:00
|
|
|
if [ ! -d "/sys/module/batman_adv" ]; then
|
|
|
|
echo "batman-adv module directory not found - was the kernel module loaded ?" >&2
|
|
|
|
return 0
|
2010-05-23 13:17:09 +00:00
|
|
|
fi
|
2010-07-01 15:10:19 +00:00
|
|
|
|
|
|
|
return 1
|
2010-05-23 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_mesh () {
|
|
|
|
local meshif="$1"
|
2010-07-01 15:10:19 +00:00
|
|
|
local interfaces orig_interval log_level aggregate_ogm vis_mode
|
|
|
|
|
|
|
|
is_module_loaded
|
|
|
|
[ $? -ne 1 ] && return
|
2010-05-23 13:17:09 +00:00
|
|
|
|
|
|
|
config_get interfaces "$meshif" interfaces
|
|
|
|
config_get orig_interval "$meshif" orig_interval
|
|
|
|
config_get log_level "$meshif" log_level
|
2010-07-01 15:10:19 +00:00
|
|
|
config_get aggregate_ogm "$meshif" aggregate_ogm
|
|
|
|
config_get vis_mode "$meshif" vis_mode
|
2010-05-23 13:17:09 +00:00
|
|
|
|
|
|
|
if [ "$interfaces" = "" ]; then
|
|
|
|
echo Error, you must specify at least a network interface
|
|
|
|
return
|
|
|
|
fi
|
2010-07-01 15:10:19 +00:00
|
|
|
|
|
|
|
for interface in $interfaces
|
|
|
|
do
|
|
|
|
[ ! -f "/sys/class/net/$interface/batman_adv/mesh_iface" ] && echo "Can't add interface $interface - ignoring" && continue
|
|
|
|
echo $meshif > /sys/class/net/$interface/batman_adv/mesh_iface
|
|
|
|
done
|
|
|
|
|
2010-05-23 13:17:09 +00:00
|
|
|
if [ $orig_interval ]; then
|
2010-07-01 15:10:19 +00:00
|
|
|
echo $orig_interval > /sys/class/net/$meshif/batman_adv/originator_interval
|
2010-05-23 13:17:09 +00:00
|
|
|
fi
|
2010-07-01 15:10:19 +00:00
|
|
|
|
2010-05-23 13:17:09 +00:00
|
|
|
if [ $log_level ]; then
|
|
|
|
echo $log_level > /sys/module/batman_adv/parameters/debug 2>&-
|
|
|
|
fi
|
2010-07-01 15:10:19 +00:00
|
|
|
|
|
|
|
if [ $aggregate_ogm ]; then
|
|
|
|
echo $aggregate_ogm > /sys/class/net/$meshif/batman_adv/aggregate_ogm
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $vis_mode ]; then
|
|
|
|
echo $vis_mode > /sys/class/net/$meshif/batman_adv/vis_mode
|
|
|
|
fi
|
2010-05-23 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_mesh() {
|
|
|
|
local meshif="$1"
|
2010-07-01 15:10:19 +00:00
|
|
|
|
|
|
|
is_module_loaded
|
|
|
|
[ $? -ne 1 ] && return
|
|
|
|
|
2010-05-23 13:17:09 +00:00
|
|
|
for iface in $(ls /sys/class/net/*)
|
|
|
|
do
|
|
|
|
[ ! -f "$iface/batman_adv/mesh_iface" ] && continue
|
|
|
|
[ "$(head -1 $iface/batman_adv/mesh_iface)" != "status: $meshif" ] && continue
|
2010-07-01 15:10:19 +00:00
|
|
|
|
2010-05-23 13:17:09 +00:00
|
|
|
echo "none" > $iface/batman_adv/mesh_iface
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# can also be used with "batman-adv start bat0"
|
|
|
|
start() {
|
|
|
|
config_load batman-adv
|
2010-07-01 15:10:19 +00:00
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
2010-05-23 13:17:09 +00:00
|
|
|
start_mesh $1
|
|
|
|
else
|
|
|
|
config_foreach start_mesh mesh
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# can also be used with "batman-adv stop bat0"
|
|
|
|
stop () {
|
|
|
|
config_load batman-adv
|
2010-07-01 15:10:19 +00:00
|
|
|
|
2010-05-23 13:17:09 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
stop_mesh $1
|
|
|
|
else
|
|
|
|
config_foreach stop_mesh mesh
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-07-01 15:10:19 +00:00
|
|
|
|