From a77f47f404a2dadd75d0353f0610eb94e294f4bb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 30 Apr 2016 10:03:27 +0100 Subject: [PATCH] Remove unused functions from client install --- src/freedombone-client | 417 +++++++---------------------------------- 1 file changed, 69 insertions(+), 348 deletions(-) diff --git a/src/freedombone-client b/src/freedombone-client index 5cdf3f4c..c6d42f20 100755 --- a/src/freedombone-client +++ b/src/freedombone-client @@ -36,382 +36,103 @@ 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' -WIFI_SSID='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" -ZERONET_PORT=15441 -IPFS_PORT=4001 -TRACKER_PORT=6969 - -TOXID_REPO='https://github.com/bashrc/toxid' - # 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 + 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 + #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 + # 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 + 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 '' + 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_batman { - if [ -f /usr/local/bin/${PROJECT_NAME} ]; then - TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}') - else - TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}') - fi - - 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 $TOXIC_FILE ]; then - sudo apt-get -y install toxic - echo "n -/nick $USER -/exit -" | $TOXIC_FILE -d - fi - fi - - 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 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 "WIFI_SSID=$WIFI_SSID" >> $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 $WIFI_SSID 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 $WIFI_SSID 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 configure_monkeysphere { + sudo apt-get -y install monkeysphere } function show_help { - echo '' - echo $"${PROJECT_NAME}-client" - echo '' - exit 0 + echo '' + echo $"${PROJECT_NAME}-client" + echo '' + exit 0 } while [[ $# > 1 ]] do - key="$1" + key="$1" - case $key in - -h|--help) - show_help - ;; - --essid) - shift - WIFI_SSID="$1" - ;; - --channel) - shift - WIFI_CHANNEL=${1} - ;; - *) - # unknown option - ;; - esac - shift + case $key in + -h|--help) + show_help + ;; + --essid) + shift + WIFI_SSID="$1" + ;; + --channel) + shift + WIFI_CHANNEL=${1} + ;; + *) + # unknown option + ;; + esac + shift done echo $'Configuring client' configure_ssh_client +configure_monkeysphere ${PROJECT_NAME}-mesh-install batman_client ${PROJECT_NAME}-mesh-install babel_client echo $'Configuration complete'