Advertisement
rubo77

Eigenen Rechner in das Freifunk-Netz

Dec 6th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.73 KB | None | 0 0
  1. #! /bin/bash
  2. IFACE=wlan0
  3. ESSID=batman.kiel.freifunk.net
  4. CHANNEL=11
  5. NAME=kiel
  6.  
  7. if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
  8.   echo "You must be root to run this script!"; exit 1
  9. fi
  10.  
  11. if [ "$1" = "stop" ]; then
  12.   echo "resuming normal networking..."
  13.   echo "restart network-manager"
  14.   service network-manager restart
  15.   echo "turn wlan iface off"
  16.   batctl if del $IFACE
  17.   sleep 10
  18.   echo "OK"
  19.   echo "echo it can take a few minutes until network-manager gets a new route"
  20.   echo
  21.   exit
  22. elif [ "$1" = "restart" ]; then
  23.   echo "not implemented. call this script first with stop and then with start"
  24.   exit
  25. elif [ "$1" = "--help" ]; then
  26.   echo "[start](default) or [stop]"
  27.   echo edit the options in the top section of this script to connect to another network
  28.   exit
  29. else # "start"
  30.   echo "stopping network-manager"
  31.   service network-manager stop
  32.   echo "pls wait"
  33.   sleep 10
  34.   echo "turn wlan iface off"
  35.   ifconfig $IFACE down
  36.   echo" set maximal transfer unit from standard 1500 to 1528"
  37.   ifconfig $IFACE mtu 1528
  38.   echo "turn wlan encryption off"
  39.   iwconfig $IFACE enc off
  40.   echo "start ad-hoc mode"
  41.   iwconfig $IFACE mode ad-hoc essid $ESSID ap 02:ca:ff:ee:ba:be channel $CHANNEL
  42.   echo "load module into kernel"
  43.   modprobe batman-adv
  44.   echo "adding iface to batman"
  45.   batctl if add $IFACE
  46.   echo "turn wlan iface on"
  47.   ifconfig $IFACE up
  48.   echo "turn batman iface on"
  49.   ifconfig bat0 up
  50.   echo "ESSID $ESSID on $IFACE should be ready"
  51.   echo "internet starting, this may take some minutes due to latency..."
  52.   dhclient bat0
  53.   echo "internet connection IP:"
  54.   ifconfig|grep Bcast
  55.   echo
  56.   echo "to resume normal networking call this script with option stop"
  57.   echo
  58. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement