#!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org # batmand start script, version 0.2 START=54 BIN=/usr/sbin/batmand* BATMANDEVS="eth0 eth1 ath0 ath1" BATMANDEVS_USE="" start() { echo "Starting batmand..." if [ ! -x $BIN ]; then echo "batmand not installed"; exit; fi; ip_classB=""; ip_host=""; for iface in $BATMANDEVS; do if [ -n "$(ifconfig $iface 2>/dev/null)" ]; then ip_classB=$(ifconfig $iface 2>/dev/null | awk 'BEGIN{FS=" +|:|\\."} $2 == "inet" {print $4"."$5; exit}') ip_host=$(ifconfig $iface 2>/dev/null | awk 'BEGIN{FS=" +|:|\\."} $2 == "inet" {print $7; exit}') break; fi; done if [ -z "$ip_classB" ]; then echo "no usable device found"; exit; fi; base_addr=40 brd=$ip_classB".43.255" msk=255.255.252.0 for iface in $BATMANDEVS; do if [ -z "$(ifconfig $iface 2>/dev/null)" ]; then continue; fi if [ base_addr = 43 ]; then echo "WARNING: batmand startscript only supports up to three batmand-devices (excluding tap)" break; fi ifconfig $iface:1 $ip_classB"."$((base_addr++))".$ip_host" netmask $msk broadcast $brd BATMANDEVS_USE=$BATMANDEVS_USE" "$iface:1 done $BIN $BATMANDEVS_USE } stop() { echo "Stopping batmand if running..." killall $(find $BIN | awk 'BEGIN{FS="/"}{print$NF}') >/dev/null 2>&1 for iface in $BATMANDEVS; do ifconfig $iface:1 down >/dev/null 2>/dev/null done sleep 1 }