freedombone/src/freedombone-client

413 lines
18 KiB
Plaintext
Raw Normal View History

2015-01-24 21:02:39 +01:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# License
# =======
#
2016-01-02 22:58:27 +01:00
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
2015-01-24 21:02:39 +01:00
#
# This program is free software: you can redistribute it and/or modify
2016-02-13 23:09:27 +01:00
# it under the terms of the GNU Affero General Public License as published by
2015-01-24 21:02:39 +01:00
# 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
2016-02-13 23:09:27 +01:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
2015-01-24 21:02:39 +01:00
#
2016-02-13 23:09:27 +01:00
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-01-24 21:02:39 +01:00
2015-11-27 12:42:16 +01:00
PROJECT_NAME='freedombone'
2015-11-27 17:52:23 +01:00
export TEXTDOMAIN=${PROJECT_NAME}-client
2015-11-27 12:42:16 +01:00
export TEXTDOMAINDIR="/usr/share/locale"
2015-01-24 21:02:39 +01:00
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
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-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"
ZERONET_PORT=15441
2015-09-30 11:47:37 +02:00
IPFS_PORT=4001
2015-08-29 23:44:13 +02:00
TRACKER_PORT=6969
2016-01-25 20:48:08 +01:00
TOXID_REPO='https://github.com/bashrc/toxid'
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 ''
2015-11-27 16:29:43 +01:00
echo $'Copy the following into a file called /home/username/.ssh/authorized_keys on the Freedombone server'
2015-01-24 21:02:39 +01:00
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_batman {
2016-03-15 18:48:44 +01: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
if [ ! -f /usr/bin/toxic ]; then
sudo apt-get -y install toxic
echo "n
/nick $USER
/exit
" | /usr/bin/toxic -d
2016-03-15 18:48:44 +01:00
fi
fi
2015-07-30 22:04:59 +02:00
2016-03-15 18:48:44 +01:00
BATMAN_SCRIPT=/tmp/batman
2015-07-30 22:04:59 +02:00
2016-03-15 18:48:44 +01:00
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 bittornado' >> $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|#disallow-other-stacks=.*|disallow-other-stacks=yes|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 [ -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 '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 [ -f /tmp/meshtype ] ; then' >> $BATMAN_SCRIPT
echo ' echo "Mesh already running"' >> $BATMAN_SCRIPT
echo ' return' >> $BATMAN_SCRIPT
echo ' fi' >> $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
2015-08-07 23:53:28 +02:00
2016-03-15 18:48:44 +01:00
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 --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
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
echo " iptables -A INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -A INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -A INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -A INPUT -p udp -m udp -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 ' echo "batman" > /tmp/meshtype' >> $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 --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
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
echo " iptables -D INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -D INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -D INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -D INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
echo " iptables -D INPUT -p udp -m udp -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 ' # 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
echo '' >> $BATMAN_SCRIPT
echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
echo ' systemctl stop avahi-daemon' >> $BATMAN_SCRIPT
echo ' else' >> $BATMAN_SCRIPT
echo ' service avahi-daemon stop' >> $BATMAN_SCRIPT
echo ' fi' >> $BATMAN_SCRIPT
echo '' >> $BATMAN_SCRIPT
echo ' sudo rm -f /tmp/meshtype' >> $BATMAN_SCRIPT
echo '' >> $BATMAN_SCRIPT
echo ' # kill processes' >> $BATMAN_SCRIPT
echo ' zeronet_proc=$(ps aux | grep zeronet | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
echo ' if [ "$zeronet_proc" ]; then' >> $BATMAN_SCRIPT
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
echo ' if [ "$tracker_proc" ]; then' >> $BATMAN_SCRIPT
echo ' kill -9 $tracker_proc 2> /dev/null' >> $BATMAN_SCRIPT
echo ' fi' >> $BATMAN_SCRIPT
echo ' if [ ! -f /etc/systemd/system/ipfs.service ]; then' >> $BATMAN_SCRIPT
echo ' ipfs_proc=$(ps aux | grep ipfs | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
echo ' if [ "$ipfs_proc" ]; then' >> $BATMAN_SCRIPT
echo ' kill -9 $ipfs_proc 2> /dev/null' >> $BATMAN_SCRIPT
echo ' fi' >> $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 -atl' >> $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 cp -f $BATMAN_SCRIPT /usr/bin/batman
rm $BATMAN_SCRIPT
}
function show_help {
echo ''
2015-12-08 17:22:48 +01:00
echo $"${PROJECT_NAME}-client"
echo ''
exit 0
}
while [[ $# > 1 ]]
do
2016-03-15 18:48:44 +01:00
key="$1"
2016-03-15 18:48:44 +01:00
case $key in
-h|--help)
show_help
;;
--essid)
shift
ESSID="$1"
;;
--channel)
shift
WIFI_CHANNEL=${1}
;;
*)
# unknown option
;;
esac
2015-09-05 12:05:57 +02:00
shift
done
2015-11-27 16:29:43 +01:00
echo $'Configuring client'
2015-01-24 21:02:39 +01:00
configure_ssh_client
2016-03-15 18:48:44 +01:00
${PROJECT_NAME}-mesh-install batman_client
${PROJECT_NAME}-mesh-install babel_client
2015-11-27 16:29:43 +01:00
echo $'Configuration complete'
exit 0