Stop if batman verify fails

This commit is contained in:
Bob Mottram 2016-06-26 10:34:54 +01:00
parent 0425e7ea5d
commit d7a0571518
1 changed files with 37 additions and 36 deletions

View File

@ -92,12 +92,49 @@ function status {
batctl o batctl o
} }
function stop {
if [ -z "$IFACE" ]; then
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
return
fi
if [ "$EIFACE" ]; then
brctl delif $BRIDGE bat0
brctl delif $BRIDGE $EIFACE
ifconfig $BRIDGE down || true
brctl delbr $BRIDGE
ifconfig $EIFACE down -promisc
fi
avahi-autoipd -k $BRIDGE
avahi-autoipd -k $IFACE
ifconfig bat0 down -promisc
batctl if del $IFACE
rmmod batman-adv
ifconfig $IFACE mtu 1500
ifconfig $IFACE down
iwconfig $IFACE mode managed
iptables -D INPUT -p tcp --dport 548 -j ACCEPT
iptables -D INPUT -p udp --dport 548 -j ACCEPT
iptables -D INPUT -p tcp --dport 5353 -j ACCEPT
iptables -D INPUT -p udp --dport 5353 -j ACCEPT
iptables -D INPUT -p tcp --dport 5354 -j ACCEPT
iptables -D INPUT -p udp --dport 5354 -j ACCEPT
iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT
iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT
iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
systemctl restart network-manager
}
function verify { function verify {
tempfile="$(mktemp)" tempfile="$(mktemp)"
batctl o > $tempfile batctl o > $tempfile
if grep -q "disabled" $tempfile; then if grep -q "disabled" $tempfile; then
echo $'B.A.T.M.A.N. not enabled' echo $'B.A.T.M.A.N. not enabled'
rm $tempfile rm $tempfile
stop
exit 726835 exit 726835
fi fi
echo $'B.A.T.M.A.N. is running' echo $'B.A.T.M.A.N. is running'
@ -171,42 +208,6 @@ function start {
verify verify
} }
stop() {
if [ -z "$IFACE" ]; then
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
return
fi
if [ "$EIFACE" ]; then
brctl delif $BRIDGE bat0
brctl delif $BRIDGE $EIFACE
ifconfig $BRIDGE down || true
brctl delbr $BRIDGE
ifconfig $EIFACE down -promisc
fi
avahi-autoipd -k $BRIDGE
avahi-autoipd -k $IFACE
ifconfig bat0 down -promisc
batctl if del $IFACE
rmmod batman-adv
ifconfig $IFACE mtu 1500
ifconfig $IFACE down
iwconfig $IFACE mode managed
iptables -D INPUT -p tcp --dport 548 -j ACCEPT
iptables -D INPUT -p udp --dport 548 -j ACCEPT
iptables -D INPUT -p tcp --dport 5353 -j ACCEPT
iptables -D INPUT -p udp --dport 5353 -j ACCEPT
iptables -D INPUT -p tcp --dport 5354 -j ACCEPT
iptables -D INPUT -p udp --dport 5354 -j ACCEPT
iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT
iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT
iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
systemctl restart network-manager
}
if ! grep -q "$IFACE" /proc/net/dev; then if ! grep -q "$IFACE" /proc/net/dev; then
echo 'Interface $IFACE was not found' echo 'Interface $IFACE was not found'
stop stop