浏览代码

script to use batman

Bob Mottram 10 年前
父节点
当前提交
0f712e41a8
共有 1 个文件被更改,包括 33 次插入26 次删除
  1. 33
    26
      src/freedombone

+ 33
- 26
src/freedombone 查看文件

@@ -1543,6 +1543,9 @@ function mesh_batman {
1543 1543
       return
1544 1544
   fi
1545 1545
 
1546
+  apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
1547
+  apt-get -y install python-dev libevent-dev ebtables python-pip git
1548
+
1546 1549
   modprobe batman-adv
1547 1550
   [ $? -ne 0 ] && echo "B.A.T.M.A.N module not available" && exit 76482
1548 1551
   if ! grep -q "batman_adv" /etc/modules; then
@@ -1578,33 +1581,37 @@ function mesh_batman {
1578 1581
 
1579 1582
   # TODO add wlan0
1580 1583
 
1581
-  apt-get -y install iproute bridge-utils libnetfilter-conntrack3 python-dev libevent-dev ebtables python-pip git
1582
-
1583
-  # TODO turn the following into a script which can be run on startup
1584
-
1585
-  # stop network manager to make the mesh network work
1586
-  service networking stop
1587
-
1588
-  # configure the wlan interface to operate with mtus of 1532(batman requires it) and turn enc off to ensure it works
1589
-  ifconfig wlan0 down
1590
-  ifconfig wlan0 mtu 1532
1591
-  iwconfig wlan0 enc off
1592
-
1593
-  # add the interface to the ad-hoc network - or create it.
1594
-  iwconfig wlan0 mode ad-hoc essid NetworkName ap $BATMAN_IPV6 channel 2
1595
-
1596
-  # add wlan0 to the batman-adv virtual interface(so it can communicate with other batman-adv nodes)
1597
-  batctl if add wlan0
1598
-  ifconfig wlan0 up
1599
-  ifconfig bat0 up
1600
-
1601
-  # make the bridge linking the batman-adv virtual interface to the ethernet port
1602
-  brctl addbr bridge-link
1603
-  brctl addif bridge-link bat0
1604
-  brctl addif bridge-link eth0
1605 1584
 
1606
-  #get the ip address for the bridge from the dhcp server
1607
-  dhclient bridge-link
1585
+  echo '#!/bin/bash' > /usr/bin/mesh
1586
+  echo '' > /usr/bin/mesh
1587
+  echo '# stop network manager to make the mesh network work' >> /usr/bin/mesh
1588
+  echo 'service networking stop' >> /usr/bin/mesh
1589
+  echo '' >> /usr/bin/mesh
1590
+  echo '# configure the wlan interface to operate with mtus of 1532(batman requires it) and turn enc off to ensure it works' >> /usr/bin/mesh
1591
+  echo 'ifconfig wlan0 down' >> /usr/bin/mesh
1592
+  echo 'ifconfig wlan0 mtu 1532' >> /usr/bin/mesh
1593
+  echo 'iwconfig wlan0 enc off' >> /usr/bin/mesh
1594
+  echo '' >> /usr/bin/mesh
1595
+  echo '# add the interface to the ad-hoc network - or create it.' >> /usr/bin/mesh
1596
+  echo "iwconfig wlan0 mode ad-hoc essid NetworkName ap $BATMAN_IPV6 channel 2" >> /usr/bin/mesh
1597
+  echo '' >> /usr/bin/mesh
1598
+  echo '# add wlan0 to the batman-adv virtual interface(so it can communicate with other batman-adv nodes)' >> /usr/bin/mesh
1599
+  echo 'batctl if add wlan0' >> /usr/bin/mesh
1600
+  echo 'ifconfig wlan0 up' >> /usr/bin/mesh
1601
+  echo 'ifconfig bat0 up' >> /usr/bin/mesh
1602
+  echo '' >> /usr/bin/mesh
1603
+  echo '# make the bridge linking the batman-adv virtual interface to the ethernet port' >> /usr/bin/mesh
1604
+  echo 'brctl addbr bridge-link' >> /usr/bin/mesh
1605
+  echo 'brctl addif bridge-link bat0' >> /usr/bin/mesh
1606
+  echo 'brctl addif bridge-link eth0' >> /usr/bin/mesh
1607
+  echo '' >> /usr/bin/mesh
1608
+  echo '#get the ip address for the bridge from the dhcp server' >> /usr/bin/mesh
1609
+  echo 'dhclient bridge-link' >> /usr/bin/mesh
1610
+  echo '' >> /usr/bin/mesh
1611
+  echo 'exit 0' >> /usr/bin/mesh
1612
+  chmod +x /usr/bin/mesh
1613
+
1614
+  /usr/bin/mesh
1608 1615
 
1609 1616
   if ! grep -q "Mesh Networking (B.A.T.M.A.N)" /home/$MY_USERNAME/README; then
1610 1617
       echo '' >> /home/$MY_USERNAME/README