2015-01-24 21:02:39 +01:00
|
|
|
#!/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
|
2015-07-09 19:59:43 +02:00
|
|
|
VERSION="1.01"
|
2015-01-24 21:02:39 +01:00
|
|
|
|
2015-07-30 22:04:59 +02:00
|
|
|
WIFI_CHANNEL=2
|
2015-08-09 15:45:59 +02:00
|
|
|
WIFI_INTERFACE=wlan0
|
2015-07-30 22:04:59 +02:00
|
|
|
|
|
|
|
# B.A.T.M.A.N settings
|
|
|
|
BATMAN_CELLID='02:BA:00:00:03:01'
|
|
|
|
ESSID='mesh'
|
2015-07-19 20:37:57 +02:00
|
|
|
|
2015-07-30 22:24:38 +02:00
|
|
|
# Babel
|
|
|
|
BABEL_PORT=6696
|
|
|
|
|
2015-01-24 21:02:39 +01:00
|
|
|
# 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"
|
|
|
|
|
2015-08-24 09:20:34 +02:00
|
|
|
ZERONET_PORT=15441
|
2015-08-29 23:44:13 +02:00
|
|
|
TRACKER_PORT=6969
|
2015-08-24 09:20:34 +02:00
|
|
|
|
2015-01-24 21:02:39 +01:00
|
|
|
# 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
|
2015-08-09 11:06:29 +02:00
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
2015-08-09 10:59:28 +02:00
|
|
|
echo " HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
2015-01-24 21:02:39 +01:00
|
|
|
fi
|
|
|
|
sudo sed -i "s/Ciphers.*/Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
|
|
|
|
if ! grep -q "Ciphers " /etc/ssh/ssh_config; then
|
2015-08-09 11:06:29 +02:00
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
2015-08-09 10:59:28 +02:00
|
|
|
echo " Ciphers $SSH_CIPHERS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
2015-01-24 21:02:39 +01:00
|
|
|
fi
|
|
|
|
sudo sed -i "s/MACs.*/MACs $SSH_MACS/g" /etc/ssh/ssh_config
|
|
|
|
if ! grep -q "MACs " /etc/ssh/ssh_config; then
|
2015-08-09 11:06:29 +02:00
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
2015-08-09 10:59:28 +02:00
|
|
|
echo " MACs $SSH_MACS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
2015-08-09 13:15:59 +02:00
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
2015-01-24 21:02:39 +01:00
|
|
|
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 ''
|
|
|
|
}
|
|
|
|
|
2015-07-30 22:22:37 +02:00
|
|
|
function mesh_babel {
|
2015-08-26 21:55:41 +02:00
|
|
|
if [ ! -f /tmp/meshtype ]; then
|
|
|
|
sudo apt-get -y install babeld
|
|
|
|
sudo apt-get -y install irssi mumble
|
2015-08-27 22:39:35 +02:00
|
|
|
if [ ! -f /usr/bin/toxic ]; then
|
|
|
|
sudo apt-get -y install toxic
|
|
|
|
echo "n
|
|
|
|
/nick $USER
|
|
|
|
/exit
|
|
|
|
" | /usr/bin/toxic -d
|
|
|
|
fi
|
|
|
|
|
2015-08-26 22:26:22 +02:00
|
|
|
CURR_DIR=$(pwd)
|
|
|
|
if [ ! -f ~/develop/toxid ]; then
|
|
|
|
if [ ! -f ~/develop ]; then
|
|
|
|
mkdir ~/develop
|
|
|
|
fi
|
|
|
|
cd ~/develop
|
|
|
|
git clone https://github.com/bashrc/toxid
|
|
|
|
fi
|
|
|
|
cd ~/develop/toxid
|
|
|
|
sudo make install
|
|
|
|
cd $CURR_DIR
|
2015-08-26 21:55:41 +02:00
|
|
|
fi
|
2015-07-30 22:22:37 +02:00
|
|
|
|
|
|
|
babel_script=/tmp/babel
|
|
|
|
|
2015-08-08 11:01:41 +02:00
|
|
|
echo '#!/bin/bash' > $babel_script
|
2015-08-08 10:28:40 +02:00
|
|
|
echo '' >> $babel_script
|
2015-08-08 10:54:49 +02:00
|
|
|
echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
|
2015-08-24 21:57:22 +02:00
|
|
|
echo ' avahi-browse -atl' >> $babel_script
|
2015-08-08 10:54:49 +02:00
|
|
|
echo ' exit 0' >> $babel_script
|
|
|
|
echo 'fi' >> $babel_script
|
|
|
|
echo '' >> $babel_script
|
2015-08-08 10:42:50 +02:00
|
|
|
echo 'if [[ $1 == "start" ]]; then' >> $babel_script
|
2015-08-22 13:40:03 +02:00
|
|
|
echo ' if [ -f /tmp/meshtype ] ; then' >> $babel_script
|
|
|
|
echo ' echo "Mesh already running"' >> $babel_script
|
|
|
|
echo ' return' >> $babel_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-08-08 10:42:50 +02:00
|
|
|
echo ' # install avahi' >> $babel_script
|
2015-08-29 23:44:13 +02:00
|
|
|
echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $babel_script
|
2015-08-08 10:42:50 +02:00
|
|
|
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 [ -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
|
2015-08-23 14:55:21 +02:00
|
|
|
echo ' echo "babel" > /tmp/meshtype' >> $babel_script
|
2015-08-08 10:28:40 +02:00
|
|
|
echo 'fi' >> $babel_script
|
|
|
|
echo '' >> $babel_script
|
2015-08-09 15:45:59 +02:00
|
|
|
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
|
2015-08-08 10:50:18 +02:00
|
|
|
echo 'fi' >> $babel_script
|
2015-08-09 20:28:03 +02:00
|
|
|
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
|
2015-07-30 22:22:37 +02:00
|
|
|
echo '' >> $babel_script
|
2015-08-08 10:50:18 +02:00
|
|
|
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
|
2015-07-30 22:22:37 +02:00
|
|
|
echo ' ifconfig $IFACE down' >> $babel_script
|
|
|
|
echo ' pkill babeld' >> $babel_script
|
2015-08-08 00:22:21 +02:00
|
|
|
echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
|
2015-08-08 11:06:43 +02:00
|
|
|
echo ' systemctl restart network-manager' >> $babel_script
|
2015-08-08 00:22:21 +02:00
|
|
|
echo ' else' >> $babel_script
|
2015-08-08 00:48:47 +02:00
|
|
|
echo ' service network-manager restart' >> $babel_script
|
2015-08-08 00:22:21 +02:00
|
|
|
echo ' fi' >> $babel_script
|
2015-07-30 22:22:37 +02:00
|
|
|
echo ' exit 1' >> $babel_script
|
|
|
|
echo 'fi' >> $babel_script
|
|
|
|
echo '' >> $babel_script
|
2015-08-08 00:23:01 +02:00
|
|
|
echo 'if [ -f /bin/systemctl ]; then' >> $babel_script
|
2015-08-08 11:06:43 +02:00
|
|
|
echo ' systemctl stop network-manager' >> $babel_script
|
2015-08-08 00:23:01 +02:00
|
|
|
echo 'else' >> $babel_script
|
2015-08-08 00:48:47 +02:00
|
|
|
echo ' service network-manager stop' >> $babel_script
|
2015-08-08 00:23:01 +02:00
|
|
|
echo 'fi' >> $babel_script
|
2015-07-30 22:22:37 +02:00
|
|
|
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
|
2015-08-08 16:36:27 +02:00
|
|
|
echo -n "$BABEL_PORT -d 5 " >> $babel_script
|
|
|
|
echo '$IFACE' >> $babel_script
|
2015-07-30 22:22:37 +02:00
|
|
|
echo 'exit 0' >> $babel_script
|
|
|
|
chmod +x $babel_script
|
|
|
|
sudo mv $babel_script /usr/bin/babel
|
|
|
|
}
|
|
|
|
|
2015-07-19 20:37:57 +02:00
|
|
|
function mesh_batman {
|
2015-08-26 21:55:41 +02:00
|
|
|
if [ ! -f /tmp/meshtype ]; then
|
|
|
|
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
|
|
|
|
sudo apt-get -y install irssi mumble
|
2015-08-27 22:39:35 +02:00
|
|
|
if [ ! -f /usr/bin/toxic ]; then
|
|
|
|
sudo apt-get -y install toxic
|
|
|
|
echo "n
|
|
|
|
/nick $USER
|
|
|
|
/exit
|
|
|
|
" | /usr/bin/toxic -d
|
|
|
|
fi
|
2015-08-26 21:55:41 +02:00
|
|
|
fi
|
2015-07-30 22:04:59 +02:00
|
|
|
|
|
|
|
batman_script=/tmp/batman
|
|
|
|
|
2015-08-08 11:01:41 +02:00
|
|
|
echo '#!/bin/bash' > $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo '' >> $batman_script
|
2015-08-08 10:41:50 +02:00
|
|
|
echo 'if [[ $1 == "start" ]]; then' >> $batman_script
|
|
|
|
echo ' # install avahi' >> $batman_script
|
2015-08-29 23:44:13 +02:00
|
|
|
echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $batman_script
|
2015-08-08 10:41:50 +02:00
|
|
|
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
|
2015-08-09 13:15:59 +02:00
|
|
|
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
|
2015-08-09 23:14:41 +02:00
|
|
|
echo ' sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $batman_script
|
2015-08-23 14:55:21 +02:00
|
|
|
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
|
2015-08-09 23:44:41 +02:00
|
|
|
echo ' fi' >> $batman_script
|
2015-08-08 10:28:40 +02:00
|
|
|
echo 'fi' >> $batman_script
|
|
|
|
echo '' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-08 18:56:56 +02:00
|
|
|
echo '# Ethernet bridge definition (bridged to bat0)' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo 'BRIDGE=br-mesh' >> $batman_script
|
2015-08-09 15:45:59 +02:00
|
|
|
echo "IFACE=$WIFI_INTERFACE" >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo 'EIFACE=eth0' >> $batman_script
|
2015-08-08 00:26:40 +02:00
|
|
|
echo '' >> $batman_script
|
2015-08-09 15:45:59 +02:00
|
|
|
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
|
2015-08-08 00:26:40 +02:00
|
|
|
echo 'fi' >> $batman_script
|
2015-08-09 20:28:03 +02:00
|
|
|
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
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-22 13:40:03 +02:00
|
|
|
echo ' if [ -f /tmp/meshtype ] ; then' >> $batman_script
|
|
|
|
echo ' echo "Mesh already running"' >> $batman_script
|
|
|
|
echo ' return' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-07 23:53:28 +02:00
|
|
|
|
|
|
|
echo ' if [ -f /bin/systemctl ]; then' >> $batman_script
|
2015-08-08 11:06:43 +02:00
|
|
|
echo ' systemctl stop network-manager' >> $batman_script
|
2015-08-07 23:53:28 +02:00
|
|
|
echo ' else' >> $batman_script
|
2015-08-08 00:48:47 +02:00
|
|
|
echo ' service network-manager stop' >> $batman_script
|
2015-08-07 23:53:28 +02:00
|
|
|
echo ' fi' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo ' sleep 5' >> $batman_script
|
|
|
|
echo '' >> $batman_script
|
2015-08-09 12:10:56 +02:00
|
|
|
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
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-08 20:35:45 +02:00
|
|
|
echo ' ifconfig $IFACE mtu 1532' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-09 16:05:38 +02:00
|
|
|
echo ' avahi-autoipd --force-bind --daemonize --wait $BRIDGE' >> $batman_script
|
|
|
|
echo ' avahi-autoipd --force-bind --daemonize --wait $IFACE' >> $batman_script
|
2015-08-09 12:13:21 +02:00
|
|
|
echo ' ifconfig bat0 up promisc' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo '' >> $batman_script
|
|
|
|
echo ' #Use persistent HWAddr' >> $batman_script
|
|
|
|
echo ' ether_new=$(ifconfig eth0 | grep HWaddr | sed -e "s/.*HWaddr //")' >> $batman_script
|
2015-08-08 23:55:36 +02:00
|
|
|
echo ' if [ ! -f /var/lib/mesh-node/bat0 ]; then' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-08 19:45:53 +02:00
|
|
|
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
|
2015-07-30 22:04:59 +02:00
|
|
|
echo ' ifconfig $BRIDGE up' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-08-08 18:35:25 +02:00
|
|
|
echo '' >> $batman_script
|
2015-08-23 23:58:49 +02:00
|
|
|
echo ' iptables -A INPUT -p tcp --dport 548 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -A INPUT -p udp --dport 548 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -A INPUT -p tcp --dport 5353 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -A INPUT -p udp --dport 5353 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -A INPUT -p tcp --dport 5354 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
|
2015-08-24 09:20:34 +02:00
|
|
|
echo " iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
|
|
|
|
echo " iptables -A INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
|
2015-08-29 18:48:43 +02:00
|
|
|
echo " iptables -A INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
|
2015-08-31 13:20:57 +02:00
|
|
|
echo " iptables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
|
2015-08-29 22:39:21 +02:00
|
|
|
echo " iptables -A INPUT -p udp --dport 1900 -j ACCEPT" >> $batman_script
|
2015-08-31 11:44:50 +02:00
|
|
|
echo " iptables -A INPUT -p tcp --dport 80 -j ACCEPT" >> $batman_script
|
2015-09-02 13:57:29 +02:00
|
|
|
echo " iptables -A INPUT -p udp -m udp -j ACCEPT" >> $batman_script
|
2015-08-08 19:31:18 +02:00
|
|
|
echo '' >> $batman_script
|
2015-08-08 18:35:25 +02:00
|
|
|
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
|
2015-08-22 13:40:03 +02:00
|
|
|
echo ' echo "batman" > /tmp/meshtype' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo '}' >> $batman_script
|
|
|
|
echo '' >> $batman_script
|
|
|
|
echo 'stop() {' >> $batman_script
|
2015-08-08 16:50:56 +02:00
|
|
|
echo ' if [ -z "$IFACE" ]; then' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo ' echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $batman_script
|
|
|
|
echo ' return' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-08-08 16:50:56 +02:00
|
|
|
echo ' if [ "$EIFACE" ]; then' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-09 13:28:59 +02:00
|
|
|
echo ' avahi-autoipd -k $BRIDGE' >> $batman_script
|
2015-08-09 13:50:56 +02:00
|
|
|
echo ' avahi-autoipd -k $IFACE' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-23 23:58:49 +02:00
|
|
|
echo ' iptables -D INPUT -p tcp --dport 548 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -D INPUT -p udp --dport 548 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -D INPUT -p tcp --dport 5353 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -D INPUT -p udp --dport 5353 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -D INPUT -p tcp --dport 5354 -j ACCEPT' >> $batman_script
|
|
|
|
echo ' iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
|
2015-08-24 09:20:34 +02:00
|
|
|
echo " iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
|
|
|
|
echo " iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
|
2015-08-29 18:48:43 +02:00
|
|
|
echo " iptables -D INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
|
2015-08-31 13:20:57 +02:00
|
|
|
echo " iptables -D INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
|
2015-08-29 22:39:21 +02:00
|
|
|
echo " iptables -D INPUT -p udp --dport 1900 -j ACCEPT" >> $batman_script
|
2015-08-31 11:44:50 +02:00
|
|
|
echo " iptables -D INPUT -p tcp --dport 80 -j ACCEPT" >> $batman_script
|
2015-09-02 13:57:29 +02:00
|
|
|
echo " iptables -D INPUT -p udp -m udp -j ACCEPT" >> $batman_script
|
2015-08-08 19:31:18 +02:00
|
|
|
echo '' >> $batman_script
|
2015-08-07 23:53:28 +02:00
|
|
|
echo ' if [ -f /bin/systemctl ]; then' >> $batman_script
|
2015-08-08 11:06:43 +02:00
|
|
|
echo ' systemctl restart network-manager' >> $batman_script
|
2015-08-07 23:53:28 +02:00
|
|
|
echo ' else' >> $batman_script
|
2015-08-08 00:48:47 +02:00
|
|
|
echo ' service network-manager restart' >> $batman_script
|
2015-08-07 23:53:28 +02:00
|
|
|
echo ' fi' >> $batman_script
|
2015-08-26 21:49:27 +02:00
|
|
|
echo ' ' >> $batman_script
|
|
|
|
echo ' # restore tox bootstrap nodes for the internet' >> $batman_script
|
|
|
|
echo ' if [ -f /usr/share/toxic/DHTnodes.internet ]; then' >> $batman_script
|
|
|
|
echo ' mv /usr/share/toxic/DHTnodes.internet /usr/share/toxic/DHTnodes' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
|
|
|
echo ' if [ -f /usr/local/share/toxic/DHTnodes.internet ]; then' >> $batman_script
|
|
|
|
echo ' mv /usr/local/share/toxic/DHTnodes.internet /usr/local/share/toxic/DHTnodes' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-09-03 19:21:37 +02:00
|
|
|
echo '' >> $batman_script
|
2015-09-03 20:58:03 +02:00
|
|
|
echo ' sudo rm -f /tmp/meshtype' >> $batman_script
|
|
|
|
echo '' >> $batman_script
|
2015-09-03 19:21:37 +02:00
|
|
|
echo ' # kill processes' >> $batman_script
|
2015-09-03 19:31:08 +02:00
|
|
|
echo ' zeronet_proc=$(ps aux | grep zeronet | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $batman_script
|
2015-09-03 19:34:36 +02:00
|
|
|
echo ' if [ "$zeronet_proc" ]; then' >> $batman_script
|
2015-09-03 19:31:08 +02:00
|
|
|
echo ' kill -9 $zeronet_proc 2> /dev/null' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
|
|
|
echo ' tracker_proc=$(ps aux | grep bttrack | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $batman_script
|
2015-09-03 19:34:36 +02:00
|
|
|
echo ' if [ "$tracker_proc" ]; then' >> $batman_script
|
2015-09-03 19:31:08 +02:00
|
|
|
echo ' kill -9 $tracker_proc 2> /dev/null' >> $batman_script
|
|
|
|
echo ' fi' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo '}' >> $batman_script
|
|
|
|
echo '' >> $batman_script
|
2015-08-08 00:26:40 +02:00
|
|
|
echo 'if ! grep -q "$IFACE" /proc/net/dev; then' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
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
|
2015-08-08 18:02:27 +02:00
|
|
|
echo ' restart)' >> $batman_script
|
|
|
|
echo ' stop' >> $batman_script
|
|
|
|
echo ' sleep 10' >> $batman_script
|
|
|
|
echo ' start' >> $batman_script
|
|
|
|
echo ' ;;' >> $batman_script
|
2015-08-08 00:35:45 +02:00
|
|
|
echo ' status)' >> $batman_script
|
|
|
|
echo ' batctl o' >> $batman_script
|
|
|
|
echo ' ;;' >> $batman_script
|
2015-08-09 10:54:44 +02:00
|
|
|
echo ' ping)' >> $batman_script
|
|
|
|
echo ' batctl ping $2' >> $batman_script
|
|
|
|
echo ' ;;' >> $batman_script
|
2015-08-08 10:54:49 +02:00
|
|
|
echo ' ls|list)' >> $batman_script
|
2015-08-24 21:57:22 +02:00
|
|
|
echo ' avahi-browse -atl' >> $batman_script
|
2015-08-08 10:54:49 +02:00
|
|
|
echo ' ;;' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo ' *)' >> $batman_script
|
|
|
|
echo ' echo "error: invalid parameter $1"' >> $batman_script
|
2015-08-09 10:54:44 +02:00
|
|
|
echo ' echo "usage: $0 {start|stop|restart|status|ping|ls|list}"' >> $batman_script
|
2015-07-30 22:04:59 +02:00
|
|
|
echo ' exit 2' >> $batman_script
|
|
|
|
echo ' ;;' >> $batman_script
|
|
|
|
echo 'esac' >> $batman_script
|
|
|
|
echo 'exit 0' >> $batman_script
|
|
|
|
chmod +x $batman_script
|
2015-08-23 13:55:33 +02:00
|
|
|
sudo cp -f $batman_script /usr/bin/batman
|
|
|
|
rm $batman_script
|
2015-07-19 20:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_help {
|
|
|
|
echo ''
|
2015-07-30 22:26:39 +02:00
|
|
|
echo 'freedombone-client'
|
2015-07-19 20:37:57 +02:00
|
|
|
echo ''
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
while [[ $# > 1 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2015-01-24 21:02:39 +01:00
|
|
|
echo 'Configuring client'
|
|
|
|
configure_ssh_client
|
2015-07-19 20:37:57 +02:00
|
|
|
mesh_batman
|
2015-07-30 22:22:37 +02:00
|
|
|
mesh_babel
|
2015-01-24 21:02:39 +01:00
|
|
|
echo 'Configuration complete'
|
2015-07-19 20:37:57 +02:00
|
|
|
exit 0
|