| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 | 
							- #!/bin/bash
 - #
 - # .---.                  .              .
 - # |                      |              |
 - # |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
 - # |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
 - # '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
 - #
 - #                    Freedom in the Cloud
 - #
 - # License
 - # =======
 - #
 - # Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
 - #
 - # This program is free software: you can redistribute it and/or modify
 - # it under the terms of the GNU General Public License as published by
 - # the Free Software Foundation, either version 3 of the License, or
 - # (at your option) any later version.
 - #
 - # This program is distributed in the hope that it will be useful,
 - # but WITHOUT ANY WARRANTY; without even the implied warranty of
 - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 - # GNU General Public License for more details.
 - #
 - # You should have received a copy of the GNU General Public License
 - # along with this program. If not, see <http://www.gnu.org/licenses/>.
 - 
 - CURR_USER=$USER
 - 
 - # Version number of this script
 - VERSION="1.01"
 - 
 - WIFI_CHANNEL=2
 - WIFI_INTERFACE=wlan0
 - 
 - # B.A.T.M.A.N settings
 - BATMAN_CELLID='02:BA:00:00:03:01'
 - ESSID='mesh'
 - 
 - # Babel
 - BABEL_PORT=6696
 - 
 - # ssh (from https://stribika.github.io/2015/01/04/secure-secure-shell.html)
 - SSH_CIPHERS="chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
 - SSH_MACS="hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com"
 - SSH_KEX="curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256"
 - SSH_HOST_KEY_ALGORITHMS="ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-ed25519,ssh-rsa"
 - 
 - # see https://stribika.github.io/2015/01/04/secure-secure-shell.html
 - function ssh_remove_small_moduli {
 -   sudo awk '$5 > 2000' /etc/ssh/moduli > /home/$CURR_USER/moduli
 -   sudo mv /home/$CURR_USER/moduli /etc/ssh/moduli
 - }
 - 
 - function configure_ssh_client {
 -   #sudo sed -i 's/#   PasswordAuthentication.*/   PasswordAuthentication no/g' /etc/ssh/ssh_config
 -   #sudo sed -i 's/#   ChallengeResponseAuthentication.*/   ChallengeResponseAuthentication no/g' /etc/ssh/ssh_config
 -   sudo sed -i "s/#   HostKeyAlgorithms.*/   HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS/g" /etc/ssh/ssh_config
 -   sudo sed -i "s/#   Ciphers.*/   Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
 -   sudo sed -i "s/#   MACs.*/   MACs $SSH_MACS/g" /etc/ssh/ssh_config
 -   if ! grep -q "HostKeyAlgorithms" /etc/ssh/ssh_config; then
 -       sudo cp /etc/ssh/ssh_config ~/ssh_config
 -       sudo chown $CURR_USER:$CURR_USER ~/ssh_config
 -       echo "   HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS" >> ~/ssh_config
 -       sudo mv ~/ssh_config /etc/ssh/ssh_config
 -       sudo chown root:root /etc/ssh/ssh_config
 -   fi
 -   sudo sed -i "s/Ciphers.*/Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
 -   if ! grep -q "Ciphers " /etc/ssh/ssh_config; then
 -       sudo cp /etc/ssh/ssh_config ~/ssh_config
 -       sudo chown $CURR_USER:$CURR_USER ~/ssh_config
 -       echo "   Ciphers $SSH_CIPHERS" >> ~/ssh_config
 -       sudo mv ~/ssh_config /etc/ssh/ssh_config
 -       sudo chown root:root /etc/ssh/ssh_config
 -   fi
 -   sudo sed -i "s/MACs.*/MACs $SSH_MACS/g" /etc/ssh/ssh_config
 -   if ! grep -q "MACs " /etc/ssh/ssh_config; then
 -       sudo cp /etc/ssh/ssh_config ~/ssh_config
 -       sudo chown $CURR_USER:$CURR_USER ~/ssh_config
 -       echo "   MACs $SSH_MACS" >> ~/ssh_config
 -       sudo mv ~/ssh_config /etc/ssh/ssh_config
 -       sudo chown root:root /etc/ssh/ssh_config
 -   fi
 - 
 -   # Create ssh keys
 -   if [ ! -f /home/$CURR_USER/.ssh/id_ed25519 ]; then
 -       ssh-keygen -t ed25519 -o -a 100
 -   fi
 -   if [ ! -f /home/$CURR_USER/.ssh/id_rsa ]; then
 -       ssh-keygen -t rsa -b 4096 -o -a 100
 -   fi
 - 
 -   ssh_remove_small_moduli
 - 
 -   echo ''
 -   echo 'Copy the following into a file called /home/username/.ssh/authorized_keys on the Freedombone server'
 -   echo ''
 -   echo $(cat /home/$CURR_USER/.ssh/id_rsa.pub)
 -   echo $(cat /home/$CURR_USER/.ssh/id_ed25519.pub)
 -   echo ''
 - }
 - 
 - function mesh_babel {
 -   sudo apt-get -y install babeld
 - 
 -   babel_script=/tmp/babel
 - 
 -   echo '#!/bin/bash' > $babel_script
 -   echo '' >> $babel_script
 -   echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
 -   echo '    avahi-browse -at' >> $babel_script
 -   echo '    exit 0' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo '' >> $babel_script
 -   echo 'if [[ $1 == "start" ]]; then' >> $babel_script
 -   echo '    # install avahi' >> $babel_script
 -   echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd' >> $babel_script
 -   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
 -   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
 -   echo '    if ! grep -q "avahi-daemon" /etc/crontab; then' >> $babel_script
 -   echo '        if [ -f /bin/systemctl ]; then' >> $babel_script
 -   echo "            echo '2 *   * * *   root    systemctl restart avahi-daemon > /dev/null' >> /etc/crontab" >> $babel_script
 -   echo '        else' >> $babel_script
 -   echo "            echo '2 *   * * *   root    service avahi-daemon restart > /dev/null' >> /etc/crontab" >> $babel_script
 -   echo '        fi' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo '    if [ -f /bin/systemctl ]; then' >> $babel_script
 -   echo '        systemctl restart avahi-daemon' >> $babel_script
 -   echo '    else' >> $babel_script
 -   echo '        service avahi-daemon restart' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo '' >> $babel_script
 -   echo "IFACE=$WIFI_INTERFACE" >> $babel_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
 -   echo '    if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
 -   echo '        IFACE=wlan1' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
 -   echo '    if grep -q "wlan2" /proc/net/dev; then' >> $babel_script
 -   echo '        IFACE=wlan2' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
 -   echo '    if grep -q "wlan3" /proc/net/dev; then' >> $babel_script
 -   echo '        IFACE=wlan3' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo '' >> $babel_script
 -   echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
 -   echo '    if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
 -   echo '        echo "Interface $IFACE was not found"' >> $babel_script
 -   echo '    else' >> $babel_script
 -   echo '        echo "Stopping"' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo '    ifconfig $IFACE down' >> $babel_script
 -   echo '    pkill babeld' >> $babel_script
 -   echo '    if [ -f /bin/systemctl ]; then' >> $babel_script
 -   echo '        systemctl restart network-manager' >> $babel_script
 -   echo '    else' >> $babel_script
 -   echo '        service network-manager restart' >> $babel_script
 -   echo '    fi' >> $babel_script
 -   echo '    exit 1' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo '' >> $babel_script
 -   echo 'if [ -f /bin/systemctl ]; then' >> $babel_script
 -   echo '    systemctl stop network-manager' >> $babel_script
 -   echo 'else' >> $babel_script
 -   echo '    service network-manager stop' >> $babel_script
 -   echo 'fi' >> $babel_script
 -   echo 'ifconfig $IFACE down' >> $babel_script
 -   echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
 -   echo "$WIFI_CHANNEL essid \"$ESSID\"" >> $babel_script
 -   echo 'ifconfig $IFACE up' >> $babel_script
 -   echo -n 'ifconfig $IFACE:avahi ' >> $babel_script
 -   echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
 -   echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
 -   echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
 -   echo -n "$BABEL_PORT -d 5 " >> $babel_script
 -   echo '$IFACE' >> $babel_script
 -   echo 'exit 0' >> $babel_script
 -   chmod +x $babel_script
 -   sudo mv $babel_script /usr/bin/babel
 - }
 - 
 - function mesh_batman {
 -   sudo apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
 -   sudo apt-get -y install python-dev libevent-dev ebtables python-pip
 -   sudo apt-get -y install wireless-tools rfkill
 - 
 -   batman_script=/tmp/batman
 - 
 -   echo '#!/bin/bash' > $batman_script
 -   echo '' >> $batman_script
 -   echo 'if [[ $1 == "start" ]]; then' >> $batman_script
 -   echo '    # install avahi' >> $batman_script
 -   echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd' >> $batman_script
 -   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
 -   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
 -   echo '    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
 -   echo '    sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
 -   echo '    sed -i "s|hosts:.*|hosts:          files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $batman_script
 -   echo '    if ! grep -q "avahi-daemon" /etc/crontab; then' >> $batman_script
 -   echo '        if [ -f /bin/systemctl ]; then' >> $batman_script
 -   echo "            echo '2 *   * * *   root    systemctl restart avahi-daemon > /dev/null' >> /etc/crontab" >> $batman_script
 -   echo '        else' >> $batman_script
 -   echo "            echo '2 *   * * *   root    service avahi-daemon restart > /dev/null' >> /etc/crontab" >> $batman_script
 -   echo '        fi' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '# Mesh definition' >> $batman_script
 -   echo "ESSID=$ESSID" >> $batman_script
 -   echo "CELLID=$BATMAN_CELLID" >> $batman_script
 -   echo "CHANNEL=$WIFI_CHANNEL" >> $batman_script
 -   echo '' >> $batman_script
 -   echo '# Ethernet bridge definition (bridged to bat0)' >> $batman_script
 -   echo 'BRIDGE=br-mesh' >> $batman_script
 -   echo "IFACE=$WIFI_INTERFACE" >> $batman_script
 -   echo 'EIFACE=eth0' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $batman_script
 -   echo '    if grep -q "wlan1" /proc/net/dev; then' >> $batman_script
 -   echo '        IFACE=wlan1' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $batman_script
 -   echo '    if grep -q "wlan2" /proc/net/dev; then' >> $batman_script
 -   echo '        IFACE=wlan2' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo 'if [[ $IFACE == "wlan0" ]]; then' >> $batman_script
 -   echo '    if grep -q "wlan3" /proc/net/dev; then' >> $batman_script
 -   echo '        IFACE=wlan3' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'if [ -e /etc/default/batctl ]; then' >> $batman_script
 -   echo '    . /etc/default/batctl' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'start() {' >> $batman_script
 -   echo '    if [ -z "$IFACE" ] ; then' >> $batman_script
 -   echo '        echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $batman_script
 -   echo '        return' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '    echo "info: enabling batman-adv mesh network $ESSID on $IFACE"' >> $batman_script
 - 
 -   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
 -   echo '        systemctl stop network-manager' >> $batman_script
 -   echo '    else' >> $batman_script
 -   echo '        service network-manager stop' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '    sleep 5' >> $batman_script
 -   echo '' >> $batman_script
 -   echo "    # remove an avahi service which isn't used" >> $batman_script
 -   echo '    if [ -f /etc/avahi/services/udisks.service ]; then' >> $batman_script
 -   echo '        sudo rm /etc/avahi/services/udisks.service' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    # Might have to re-enable wifi' >> $batman_script
 -   echo '    rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    ifconfig $IFACE down' >> $batman_script
 -   echo '    ifconfig $IFACE mtu 1532' >> $batman_script
 -   echo '    iwconfig $IFACE enc off' >> $batman_script
 -   echo '    iwconfig $IFACE mode ad-hoc essid $ESSID channel $CHANNEL' >> $batman_script
 -   echo '    sleep 1' >> $batman_script
 -   echo '    iwconfig $IFACE ap $CELLID' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    modprobe batman-adv' >> $batman_script
 -   echo '    batctl if add $IFACE' >> $batman_script
 -   echo '    ifconfig $IFACE up' >> $batman_script
 -   echo '    avahi-autoipd --force-bind --daemonize --wait $BRIDGE' >> $batman_script
 -   echo '    avahi-autoipd --force-bind --daemonize --wait $IFACE' >> $batman_script
 -   echo '    ifconfig bat0 up promisc' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    #Use persistent HWAddr' >> $batman_script
 -   echo '    ether_new=$(ifconfig eth0 | grep HWaddr | sed -e "s/.*HWaddr //")' >> $batman_script
 -   echo '    if [ ! -f /var/lib/mesh-node/bat0 ]; then' >> $batman_script
 -   echo '        mkdir /var/lib/mesh-node' >> $batman_script
 -   echo '        echo "${ether_new}" > /var/lib/mesh-node/bat0' >> $batman_script
 -   echo '    else' >> $batman_script
 -   echo '        ether=$(cat /var/lib/mesh-node/bat0)' >> $batman_script
 -   echo '        ifconfig bat0 hw ether ${ether}' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    if [ "$EIFACE" ] ; then' >> $batman_script
 -   echo '        brctl addbr $BRIDGE' >> $batman_script
 -   echo '        brctl addif $BRIDGE bat0' >> $batman_script
 -   echo '        brctl addif $BRIDGE $EIFACE' >> $batman_script
 -   echo '        ifconfig bat0 0.0.0.0' >> $batman_script
 -   echo '        ifconfig $EIFACE 0.0.0.0' >> $batman_script
 -   echo '        ifconfig $EIFACE up promisc' >> $batman_script
 -   echo '        ifconfig $BRIDGE up' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    iptables -A INPUT -p tcp -m state -m tcp --dport 548 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -A INPUT -p udp -m state -m udp --dport 548 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -A INPUT -p tcp -m state -m tcp --dport 5353 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -A INPUT -p udp -m state -m udp --dport 5353 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -A INPUT -p tcp -m state -m tcp --dport 5354 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -A INPUT -p udp -m state -m udp --dport 5354 --state NEW -j ACCEPT' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
 -   echo '        systemctl restart avahi-daemon' >> $batman_script
 -   echo '    else' >> $batman_script
 -   echo '        service avahi-daemon restart' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '}' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'stop() {' >> $batman_script
 -   echo '    if [ -z "$IFACE" ]; then' >> $batman_script
 -   echo '        echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $batman_script
 -   echo '        return' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '    if [ "$EIFACE" ]; then' >> $batman_script
 -   echo '        brctl delif $BRIDGE bat0' >> $batman_script
 -   echo '        brctl delif $BRIDGE $EIFACE' >> $batman_script
 -   echo '        ifconfig $BRIDGE down || true' >> $batman_script
 -   echo '        brctl delbr $BRIDGE' >> $batman_script
 -   echo '        ifconfig $EIFACE down -promisc' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    avahi-autoipd -k $BRIDGE' >> $batman_script
 -   echo '    avahi-autoipd -k $IFACE' >> $batman_script
 -   echo '    ifconfig bat0 down -promisc' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    batctl if del $IFACE' >> $batman_script
 -   echo '    rmmod batman-adv' >> $batman_script
 -   echo '    ifconfig $IFACE mtu 1500' >> $batman_script
 -   echo '    ifconfig $IFACE down' >> $batman_script
 -   echo '    iwconfig $IFACE mode managed' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    iptables -D INPUT -p tcp -m state -m tcp --dport 548 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -D INPUT -p udp -m state -m udp --dport 548 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -D INPUT -p tcp -m state -m tcp --dport 5353 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -D INPUT -p udp -m state -m udp --dport 5353 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -D INPUT -p tcp -m state -m tcp --dport 5354 --state NEW -j ACCEPT' >> $batman_script
 -   echo '    iptables -D INPUT -p udp -m state -m udp --dport 5354 --state NEW -j ACCEPT' >> $batman_script
 -   echo '' >> $batman_script
 -   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
 -   echo '        systemctl restart network-manager' >> $batman_script
 -   echo '    else' >> $batman_script
 -   echo '        service network-manager restart' >> $batman_script
 -   echo '    fi' >> $batman_script
 -   echo '}' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'if ! grep -q "$IFACE" /proc/net/dev; then' >> $batman_script
 -   echo '    echo "Interface $IFACE was not found"' >> $batman_script
 -   echo '    stop' >> $batman_script
 -   echo '    exit 1' >> $batman_script
 -   echo 'fi' >> $batman_script
 -   echo '' >> $batman_script
 -   echo 'case "$1" in' >> $batman_script
 -   echo '    start|stop)' >> $batman_script
 -   echo '        $1' >> $batman_script
 -   echo '        ;;' >> $batman_script
 -   echo '    restart)' >> $batman_script
 -   echo '        stop' >> $batman_script
 -   echo '        sleep 10' >> $batman_script
 -   echo '        start' >> $batman_script
 -   echo '        ;;' >> $batman_script
 -   echo '    status)' >> $batman_script
 -   echo '        batctl o' >> $batman_script
 -   echo '        ;;' >> $batman_script
 -   echo '    ping)' >> $batman_script
 -   echo '        batctl ping $2' >> $batman_script
 -   echo '        ;;' >> $batman_script
 -   echo '    ls|list)' >> $batman_script
 -   echo '        avahi-browse -at' >> $batman_script
 -   echo '        ;;' >> $batman_script
 -   echo '    *)' >> $batman_script
 -   echo '    echo "error: invalid parameter $1"' >> $batman_script
 -   echo '    echo "usage: $0 {start|stop|restart|status|ping|ls|list}"' >> $batman_script
 -   echo '    exit 2' >> $batman_script
 -   echo '    ;;' >> $batman_script
 -   echo 'esac' >> $batman_script
 -   echo 'exit 0' >> $batman_script
 -   chmod +x $batman_script
 -   sudo mv $batman_script /usr/bin/batman
 - }
 - 
 - function show_help {
 -     echo ''
 -     echo 'freedombone-client'
 -     echo ''
 -     exit 0
 - }
 - 
 - while [[ $# > 1 ]]
 - do
 - key="$1"
 - 
 - case $key in
 -     -h|--help)
 -     show_help
 -     ;;
 -     *)
 -     # unknown option
 -     ;;
 - esac
 - shift
 - done
 - 
 - echo 'Configuring client'
 - configure_ssh_client
 - mesh_batman
 - mesh_babel
 - echo 'Configuration complete'
 - exit 0
 
 
  |