rubo77

Untitled

Dec 6th, 2012
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. IFACE=wlan0
  3. ESSID=batman.kiel.freifunk.net
  4. CHANNEL=11
  5. CELLID=02:ca:ff:ee:ba:be
  6. NODELINK=http://freifunk.in-kiel.de/ffmap/nodes.html
  7.  
  8. if [ "$1" = "hh" ]; then
  9.   ESSID=f8:d1:11:87:52:2e
  10.   CHANNEL=1
  11.   CELLID=f8:d1:11:87:52:2e
  12.   NODELINK=http://10.130.10.1/ffhh/nodes.html
  13. fi
  14.  
  15. if [ "$1" = "--help" ]; then
  16.   echo "[start](default) or [stop]"
  17.   echo to connect to hamburg call this script with option hh
  18.   echo edit the options in the top section of this script to connect to another network
  19.   echo your network devices:
  20.   lspci|grep -i net
  21.   exit
  22. fi
  23.  
  24. NETWORKMANAGER="service network-manager"
  25. # some distributions have
  26. #NETWORKMANAGER="/etc/init.d/network-manager"
  27.  
  28. if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
  29.   echo "You must be root to run this script!"; exit 1
  30. fi
  31.  
  32.  
  33. if [ "$1" = "stop" ]; then
  34.   echo "resuming normal networking..."
  35.   echo "restart network-manager"
  36.   $NETWORKMANAGER restart
  37.   echo "turn wlan iface off"
  38.   batctl if del $IFACE
  39.   sleep 10
  40.   echo "OK"
  41.   echo "echo it can take a few minutes until network-manager gets a new route"
  42.   echo
  43.   exit
  44. elif [ "$1" = "restart" ]; then
  45.   echo "not implemented. call this script first with stop and then with start"
  46.   exit
  47. else # "start"
  48.   echo "stopping network-manager"
  49.   $NETWORKMANAGER stop
  50.   echo "pls wait"
  51.   sleep 10
  52.   echo "turn wlan iface off"
  53.   ifconfig $IFACE down
  54.   echo" set maximal transfer unit from standard 1500 to 1528"
  55.   ifconfig $IFACE mtu 1528
  56.   echo "turn wlan encryption off"
  57.   iwconfig $IFACE enc off
  58.   echo "start ad-hoc mode"
  59.   iwconfig $IFACE mode ad-hoc essid $ESSID ap $CELLID channel $CHANNEL
  60.   #eigentlich sollte man lieber das hier benutzen, geht aber nicht:
  61.   # iw dev wlan0 ibss join $ESSID 2412 HT40+ fixed-freq $CELLID
  62.   echo "load module into kernel"
  63.   modprobe batman-adv
  64.   echo "adding iface to batman"
  65.   batctl if add $IFACE
  66.   echo "turn wlan iface on"
  67.   ifconfig $IFACE up
  68.   echo "turn batman iface on"
  69.   ifconfig bat0 up
  70.   echo "ESSID $ESSID on $IFACE should be ready"
  71.  
  72.   #sollte man eigentlich machen, geht aber nicht:
  73.   #batctl gw client
  74.  
  75.   echo "internet starting, this may take some minutes due to latency..."
  76.   dhclient bat0
  77.   echo "internet connection IP:"
  78.   ifconfig|grep Bcast
  79.   echo you should have an IP like 10.x.x.x
  80.   echo after a minute your node should popup on the nodeGraph here $NODELINK
  81.   echo
  82.   echo "to resume normal networking call this script with option stop"
  83.   echo
  84. fi
Advertisement
Add Comment
Please, Sign In to add comment