|  | @@ -37,9 +37,9 @@ CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
 | 
	
		
			
			| 37 | 37 |  
 | 
	
		
			
			| 38 | 38 |  MUMBLE_PATH=/usr/bin/mumble
 | 
	
		
			
			| 39 | 39 |  if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
 | 
	
		
			
			| 40 |  | -	TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			|  | 40 | +    TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			| 41 | 41 |  else
 | 
	
		
			
			| 42 |  | -	TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			|  | 42 | +    TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			| 43 | 43 |  fi
 | 
	
		
			
			| 44 | 44 |  DHTNODES=/usr/share/toxic/DHTnodes
 | 
	
		
			
			| 45 | 45 |  
 | 
	
	
		
			
			|  | @@ -50,13 +50,13 @@ TOXCORE_REPO='git://github.com/irungentoo/toxcore.git'
 | 
	
		
			
			| 50 | 50 |  TOXCORE_COMMIT=
 | 
	
		
			
			| 51 | 51 |  # obtain tox values from main install
 | 
	
		
			
			| 52 | 52 |  if grep -q "TOX_PORT=" $CONFIG_FILE; then
 | 
	
		
			
			| 53 |  | -	TOX_PORT=$(cat $CONFIG_FILE | grep "TOX_PORT=" | nead -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			|  | 53 | +    TOX_PORT=$(cat $CONFIG_FILE | grep "TOX_PORT=" | nead -n 1 | awk -F '=' '{print $2}')
 | 
	
		
			
			| 54 | 54 |  fi
 | 
	
		
			
			| 55 | 55 |  if grep -q "TOXCORE_REPO=" $CONFIG_FILE; then
 | 
	
		
			
			| 56 |  | -	TOXCORE_REPO=$(cat $CONFIG_FILE | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
 | 
	
		
			
			|  | 56 | +    TOXCORE_REPO=$(cat $CONFIG_FILE | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
 | 
	
		
			
			| 57 | 57 |  fi
 | 
	
		
			
			| 58 | 58 |  if grep -q "TOXCORE_COMMIT=" $CONFIG_FILE; then
 | 
	
		
			
			| 59 |  | -	TOXCORE_COMMIT=$(cat $CONFIG_FILE | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
 | 
	
		
			
			|  | 59 | +    TOXCORE_COMMIT=$(cat $CONFIG_FILE | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
 | 
	
		
			
			| 60 | 60 |  fi
 | 
	
		
			
			| 61 | 61 |  TOXID_REPO='https://github.com/bashrc/toxid'
 | 
	
		
			
			| 62 | 62 |  TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
 | 
	
	
		
			
			|  | @@ -69,226 +69,228 @@ QTOX_INI="/home/$USER/.config/tox/qtox.ini"
 | 
	
		
			
			| 69 | 69 |  SERVER_INSTALLATION="no"
 | 
	
		
			
			| 70 | 70 |  
 | 
	
		
			
			| 71 | 71 |  function install_toxcore {
 | 
	
		
			
			| 72 |  | -	if [ -f /etc/tox-bootstrapd.conf ]; then
 | 
	
		
			
			| 73 |  | -		return
 | 
	
		
			
			| 74 |  | -	fi
 | 
	
		
			
			| 75 |  | -
 | 
	
		
			
			| 76 |  | -	sudo apt-get -y install build-essential libtool autotools-dev
 | 
	
		
			
			| 77 |  | -	sudo apt-get -y install automake checkinstall check git yasm
 | 
	
		
			
			| 78 |  | -	sudo apt-get -y install libsodium13 libsodium-dev libcap2-bin
 | 
	
		
			
			| 79 |  | -	sudo apt-get -y install libconfig9 libconfig-dev
 | 
	
		
			
			| 80 |  | -
 | 
	
		
			
			| 81 |  | -	if [ ! -d ~/develop ]; then
 | 
	
		
			
			| 82 |  | -		mkdir ~/develop
 | 
	
		
			
			| 83 |  | -	fi
 | 
	
		
			
			| 84 |  | -	cd ~/develop
 | 
	
		
			
			| 85 |  | -	git clone $TOXCORE_REPO ~/develop/toxcore
 | 
	
		
			
			| 86 |  | -	cd ~/develop/toxcore
 | 
	
		
			
			| 87 |  | -	git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
 | 
	
		
			
			| 88 |  | -	autoreconf -i
 | 
	
		
			
			| 89 |  | -	./configure --enable-daemon
 | 
	
		
			
			| 90 |  | -	if [ ! "$?" = "0" ]; then
 | 
	
		
			
			| 91 |  | -		exit 78467
 | 
	
		
			
			| 92 |  | -	fi
 | 
	
		
			
			| 93 |  | -	make
 | 
	
		
			
			| 94 |  | -	if [ ! "$?" = "0" ]; then
 | 
	
		
			
			| 95 |  | -		exit 84562
 | 
	
		
			
			| 96 |  | -	fi
 | 
	
		
			
			| 97 |  | -	sudo make install
 | 
	
		
			
			| 98 |  | -	sudo cp /usr/local/lib/libtoxcore* /usr/lib/
 | 
	
		
			
			| 99 |  | -
 | 
	
		
			
			| 100 |  | -	if [ ! -f /usr/local/bin/tox-bootstrapd ]; then
 | 
	
		
			
			| 101 |  | -		echo $"File not found /usr/local/bin/tox-bootstrapd"
 | 
	
		
			
			| 102 |  | -		exit 73862
 | 
	
		
			
			| 103 |  | -	fi
 | 
	
		
			
			| 104 |  | -
 | 
	
		
			
			| 105 |  | -	sudo useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
 | 
	
		
			
			| 106 |  | -	sudo chmod 700 /var/lib/tox-bootstrapd
 | 
	
		
			
			| 107 |  | -	if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
 | 
	
		
			
			| 108 |  | -		echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
 | 
	
		
			
			| 109 |  | -		exit 476835
 | 
	
		
			
			| 110 |  | -	fi
 | 
	
		
			
			| 111 |  | -
 | 
	
		
			
			| 112 |  | -	# create configuration file
 | 
	
		
			
			| 113 |  | -	echo "port = $TOX_PORT" > /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 114 |  | -	echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 115 |  | -	echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 116 |  | -	echo 'enable_ipv6 = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 117 |  | -	echo 'enable_ipv4_fallback = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 118 |  | -	echo 'enable_lan_discovery = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 119 |  | -	echo 'enable_tcp_relay = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 120 |  | -	echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 121 |  | -	echo 'enable_motd = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 122 |  | -	echo 'motd = "tox-bootstrapd"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 123 |  | -	sudo cp /tmp/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
 | 
	
		
			
			| 124 |  | -	rm /tmp/tox-bootstrapd.conf
 | 
	
		
			
			| 125 |  | -
 | 
	
		
			
			| 126 |  | -	if [ -f /bin/systemctl ]; then
 | 
	
		
			
			| 127 |  | -		if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
 | 
	
		
			
			| 128 |  | -			echo $"File not found ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
 | 
	
		
			
			| 129 |  | -			exit 7359
 | 
	
		
			
			| 130 |  | -		fi
 | 
	
		
			
			| 131 |  | -		sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/
 | 
	
		
			
			| 132 |  | -
 | 
	
		
			
			| 133 |  | -		sudo systemctl daemon-reload
 | 
	
		
			
			| 134 |  | -		sudo systemctl enable tox-bootstrapd.service
 | 
	
		
			
			| 135 |  | -		sudo systemctl start tox-bootstrapd.service
 | 
	
		
			
			| 136 |  | -		if [ ! "$?" = "0" ]; then
 | 
	
		
			
			| 137 |  | -			sudo systemctl status tox-bootstrapd.service
 | 
	
		
			
			| 138 |  | -			exit 5846
 | 
	
		
			
			| 139 |  | -		fi
 | 
	
		
			
			| 140 |  | -
 | 
	
		
			
			| 141 |  | -		sudo systemctl restart tox-bootstrapd.service
 | 
	
		
			
			| 142 |  | -	else
 | 
	
		
			
			| 143 |  | -		sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.sh /etc/init.d/tox-bootstrapd
 | 
	
		
			
			| 144 |  | -		sudo chmod 755 /etc/init.d/tox-bootstrapd
 | 
	
		
			
			| 145 |  | -		sudo update-rc.d tox-bootstrapd defaults
 | 
	
		
			
			| 146 |  | -		sudo service tox-bootstrapd start
 | 
	
		
			
			| 147 |  | -	fi
 | 
	
		
			
			| 148 |  | -
 | 
	
		
			
			| 149 |  | -	TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | awk -F ' ' '{print $8}' | tail -1)
 | 
	
		
			
			| 150 |  | -	if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
 | 
	
		
			
			| 151 |  | -		echo $'Could not obtain the tox node public key'
 | 
	
		
			
			| 152 |  | -		exit 6529
 | 
	
		
			
			| 153 |  | -	fi
 | 
	
		
			
			| 154 |  | -
 | 
	
		
			
			| 155 |  | -	# save the public key for later reference
 | 
	
		
			
			| 156 |  | -	echo "$TOX_PUBLIC_KEY" > /tmp/boostrapid
 | 
	
		
			
			| 157 |  | -	sudo mv /tmp/boostrapid $TOX_BOOTSTRAP_ID_FILE
 | 
	
		
			
			|  | 72 | +    if [ -f /etc/tox-bootstrapd.conf ]; then
 | 
	
		
			
			|  | 73 | +        return
 | 
	
		
			
			|  | 74 | +    fi
 | 
	
		
			
			|  | 75 | +
 | 
	
		
			
			|  | 76 | +    sudo apt-get -y install build-essential libtool autotools-dev
 | 
	
		
			
			|  | 77 | +    sudo apt-get -y install automake checkinstall check git yasm
 | 
	
		
			
			|  | 78 | +    sudo apt-get -y install libsodium13 libsodium-dev libcap2-bin
 | 
	
		
			
			|  | 79 | +    sudo apt-get -y install libconfig9 libconfig-dev
 | 
	
		
			
			|  | 80 | +
 | 
	
		
			
			|  | 81 | +    if [ ! -d ~/develop ]; then
 | 
	
		
			
			|  | 82 | +        mkdir ~/develop
 | 
	
		
			
			|  | 83 | +    fi
 | 
	
		
			
			|  | 84 | +    cd ~/develop
 | 
	
		
			
			|  | 85 | +    git clone $TOXCORE_REPO ~/develop/toxcore
 | 
	
		
			
			|  | 86 | +    cd ~/develop/toxcore
 | 
	
		
			
			|  | 87 | +    if [ $TOXCORE_COMMIT ]; then
 | 
	
		
			
			|  | 88 | +        git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
 | 
	
		
			
			|  | 89 | +    fi
 | 
	
		
			
			|  | 90 | +    autoreconf -i
 | 
	
		
			
			|  | 91 | +    ./configure --enable-daemon
 | 
	
		
			
			|  | 92 | +    if [ ! "$?" = "0" ]; then
 | 
	
		
			
			|  | 93 | +        exit 78467
 | 
	
		
			
			|  | 94 | +    fi
 | 
	
		
			
			|  | 95 | +    make
 | 
	
		
			
			|  | 96 | +    if [ ! "$?" = "0" ]; then
 | 
	
		
			
			|  | 97 | +        exit 84562
 | 
	
		
			
			|  | 98 | +    fi
 | 
	
		
			
			|  | 99 | +    sudo make install
 | 
	
		
			
			|  | 100 | +    sudo cp /usr/local/lib/libtoxcore* /usr/lib/
 | 
	
		
			
			|  | 101 | +
 | 
	
		
			
			|  | 102 | +    if [ ! -f /usr/local/bin/tox-bootstrapd ]; then
 | 
	
		
			
			|  | 103 | +        echo $"File not found /usr/local/bin/tox-bootstrapd"
 | 
	
		
			
			|  | 104 | +        exit 73862
 | 
	
		
			
			|  | 105 | +    fi
 | 
	
		
			
			|  | 106 | +
 | 
	
		
			
			|  | 107 | +    sudo useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
 | 
	
		
			
			|  | 108 | +    sudo chmod 700 /var/lib/tox-bootstrapd
 | 
	
		
			
			|  | 109 | +    if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
 | 
	
		
			
			|  | 110 | +        echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
 | 
	
		
			
			|  | 111 | +        exit 476835
 | 
	
		
			
			|  | 112 | +    fi
 | 
	
		
			
			|  | 113 | +
 | 
	
		
			
			|  | 114 | +    # create configuration file
 | 
	
		
			
			|  | 115 | +    echo "port = $TOX_PORT" > /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 116 | +    echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 117 | +    echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 118 | +    echo 'enable_ipv6 = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 119 | +    echo 'enable_ipv4_fallback = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 120 | +    echo 'enable_lan_discovery = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 121 | +    echo 'enable_tcp_relay = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 122 | +    echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 123 | +    echo 'enable_motd = true' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 124 | +    echo 'motd = "tox-bootstrapd"' >> /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 125 | +    sudo cp /tmp/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
 | 
	
		
			
			|  | 126 | +    rm /tmp/tox-bootstrapd.conf
 | 
	
		
			
			|  | 127 | +
 | 
	
		
			
			|  | 128 | +    if [ -f /bin/systemctl ]; then
 | 
	
		
			
			|  | 129 | +        if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
 | 
	
		
			
			|  | 130 | +            echo $"File not found ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
 | 
	
		
			
			|  | 131 | +            exit 7359
 | 
	
		
			
			|  | 132 | +        fi
 | 
	
		
			
			|  | 133 | +        sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/
 | 
	
		
			
			|  | 134 | +
 | 
	
		
			
			|  | 135 | +        sudo systemctl daemon-reload
 | 
	
		
			
			|  | 136 | +        sudo systemctl enable tox-bootstrapd.service
 | 
	
		
			
			|  | 137 | +        sudo systemctl start tox-bootstrapd.service
 | 
	
		
			
			|  | 138 | +        if [ ! "$?" = "0" ]; then
 | 
	
		
			
			|  | 139 | +            sudo systemctl status tox-bootstrapd.service
 | 
	
		
			
			|  | 140 | +            exit 5846
 | 
	
		
			
			|  | 141 | +        fi
 | 
	
		
			
			|  | 142 | +
 | 
	
		
			
			|  | 143 | +        sudo systemctl restart tox-bootstrapd.service
 | 
	
		
			
			|  | 144 | +    else
 | 
	
		
			
			|  | 145 | +        sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.sh /etc/init.d/tox-bootstrapd
 | 
	
		
			
			|  | 146 | +        sudo chmod 755 /etc/init.d/tox-bootstrapd
 | 
	
		
			
			|  | 147 | +        sudo update-rc.d tox-bootstrapd defaults
 | 
	
		
			
			|  | 148 | +        sudo service tox-bootstrapd start
 | 
	
		
			
			|  | 149 | +    fi
 | 
	
		
			
			|  | 150 | +
 | 
	
		
			
			|  | 151 | +    TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | awk -F ' ' '{print $8}' | tail -1)
 | 
	
		
			
			|  | 152 | +    if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
 | 
	
		
			
			|  | 153 | +        echo $'Could not obtain the tox node public key'
 | 
	
		
			
			|  | 154 | +        exit 6529
 | 
	
		
			
			|  | 155 | +    fi
 | 
	
		
			
			|  | 156 | +
 | 
	
		
			
			|  | 157 | +    # save the public key for later reference
 | 
	
		
			
			|  | 158 | +    echo "$TOX_PUBLIC_KEY" > /tmp/boostrapid
 | 
	
		
			
			|  | 159 | +    sudo mv /tmp/boostrapid $TOX_BOOTSTRAP_ID_FILE
 | 
	
		
			
			| 158 | 160 |  }
 | 
	
		
			
			| 159 | 161 |  
 | 
	
		
			
			| 160 | 162 |  function install_toxid {
 | 
	
		
			
			| 161 |  | -	if [ -f /usr/local/bin/toxid ]; then
 | 
	
		
			
			| 162 |  | -		return
 | 
	
		
			
			| 163 |  | -	fi
 | 
	
		
			
			| 164 |  | -	cd ~/develop
 | 
	
		
			
			| 165 |  | -	git clone $TOXID_REPO ~/develop/toxid
 | 
	
		
			
			| 166 |  | -	cd ~/develop/toxid
 | 
	
		
			
			| 167 |  | -	make
 | 
	
		
			
			| 168 |  | -	sudo make install
 | 
	
		
			
			| 169 |  | -
 | 
	
		
			
			| 170 |  | -	if [ ! -f /usr/local/bin/toxid ]; then
 | 
	
		
			
			| 171 |  | -		echo $"Couldn't install toxid"
 | 
	
		
			
			| 172 |  | -		exit 6389
 | 
	
		
			
			| 173 |  | -	fi
 | 
	
		
			
			| 174 |  | -
 | 
	
		
			
			| 175 |  | -	if ! grep -Fxq "toxavahi" /etc/crontab; then
 | 
	
		
			
			| 176 |  | -		cp /etc/crontab /tmp/crontab
 | 
	
		
			
			| 177 |  | -		echo "* *       * * *   root    toxavahi > /dev/null" >> /tmp/crontab
 | 
	
		
			
			| 178 |  | -		sudo cp /tmp/crontab /etc/crontab
 | 
	
		
			
			| 179 |  | -		rm /tmp/crontab
 | 
	
		
			
			| 180 |  | -	fi
 | 
	
		
			
			|  | 163 | +    if [ -f /usr/local/bin/toxid ]; then
 | 
	
		
			
			|  | 164 | +        return
 | 
	
		
			
			|  | 165 | +    fi
 | 
	
		
			
			|  | 166 | +    cd ~/develop
 | 
	
		
			
			|  | 167 | +    git clone $TOXID_REPO ~/develop/toxid
 | 
	
		
			
			|  | 168 | +    cd ~/develop/toxid
 | 
	
		
			
			|  | 169 | +    make
 | 
	
		
			
			|  | 170 | +    sudo make install
 | 
	
		
			
			|  | 171 | +
 | 
	
		
			
			|  | 172 | +    if [ ! -f /usr/local/bin/toxid ]; then
 | 
	
		
			
			|  | 173 | +        echo $"Couldn't install toxid"
 | 
	
		
			
			|  | 174 | +        exit 6389
 | 
	
		
			
			|  | 175 | +    fi
 | 
	
		
			
			|  | 176 | +
 | 
	
		
			
			|  | 177 | +    if ! grep -Fxq "toxavahi" /etc/crontab; then
 | 
	
		
			
			|  | 178 | +        cp /etc/crontab /tmp/crontab
 | 
	
		
			
			|  | 179 | +        echo "* *       * * *   root    toxavahi > /dev/null" >> /tmp/crontab
 | 
	
		
			
			|  | 180 | +        sudo cp /tmp/crontab /etc/crontab
 | 
	
		
			
			|  | 181 | +        rm /tmp/crontab
 | 
	
		
			
			|  | 182 | +    fi
 | 
	
		
			
			| 181 | 183 |  }
 | 
	
		
			
			| 182 | 184 |  
 | 
	
		
			
			| 183 | 185 |  function run_tox {
 | 
	
		
			
			| 184 |  | -	echo $QTOX_INI
 | 
	
		
			
			| 185 |  | -	if [[ -f $TOXIC_FILE || -f $QTOX_INI ]]; then
 | 
	
		
			
			| 186 |  | -		if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			| 187 |  | -			# update bootstrap nodes
 | 
	
		
			
			| 188 |  | -			if [ -f $DHTNODES ]; then
 | 
	
		
			
			| 189 |  | -				if [ ! -f $DHTNODES.internet ]; then
 | 
	
		
			
			| 190 |  | -					sudo cp $DHTNODES $DHTNODES.internet
 | 
	
		
			
			| 191 |  | -				fi
 | 
	
		
			
			| 192 |  | -			fi
 | 
	
		
			
			| 193 |  | -			lstox -f dht > /tmp/dht
 | 
	
		
			
			| 194 |  | -			sudo cp /tmp/dht $DHTNODES
 | 
	
		
			
			| 195 |  | -		fi
 | 
	
		
			
			| 196 |  | -
 | 
	
		
			
			| 197 |  | -		# get a list of peers
 | 
	
		
			
			| 198 |  | -		PEER_TOX_ID_LIST=$(lstox | grep $AVAHI_DOMAIN | sort -u)
 | 
	
		
			
			| 199 |  | -		if [ ! "$PEER_TOX_ID_LIST" ]; then
 | 
	
		
			
			| 200 |  | -			echo $'No peers found'
 | 
	
		
			
			| 201 |  | -			exit 0
 | 
	
		
			
			| 202 |  | -		fi
 | 
	
		
			
			| 203 |  | -		PEER_TOX_ID_LIST_COUNT=$(echo "$PEER_TOX_ID_LIST" | wc -l)
 | 
	
		
			
			| 204 |  | -		PEER_TOX_ID=''
 | 
	
		
			
			| 205 |  | -		if [ $PEER_TOX_ID_LIST_COUNT -lt "2" ]; then
 | 
	
		
			
			| 206 |  | -			# single peer
 | 
	
		
			
			| 207 |  | -			PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | awk -F ' ' '{print $3}')
 | 
	
		
			
			| 208 |  | -		else
 | 
	
		
			
			| 209 |  | -			# choose a user from a list
 | 
	
		
			
			| 210 |  | -			echo ''
 | 
	
		
			
			| 211 |  | -			echo $"Select a user on $AVAHI_DOMAIN:"
 | 
	
		
			
			| 212 |  | -			ctr=0
 | 
	
		
			
			| 213 |  | -			while IFS='' read -r line || [[ -n "$line" ]]; do
 | 
	
		
			
			| 214 |  | -				toxusername=$(echo $line | awk -F ' ' '{print $2}')
 | 
	
		
			
			| 215 |  | -				echo "    $ctr. $toxusername"
 | 
	
		
			
			| 216 |  | -				ctr=$((ctr + 1))
 | 
	
		
			
			| 217 |  | -			done < "$PEER_TOX_ID_LIST"
 | 
	
		
			
			| 218 |  | -			read user_index
 | 
	
		
			
			| 219 |  | -			PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | tail -n+${user_index} | head -n1 | awk -F ' ' '{print $3}')
 | 
	
		
			
			| 220 |  | -		fi
 | 
	
		
			
			| 221 |  | -
 | 
	
		
			
			| 222 |  | -		# if this is a valid ID
 | 
	
		
			
			| 223 |  | -		if [ ${#PEER_TOX_ID} -gt 30 ]; then
 | 
	
		
			
			| 224 |  | -			# start client and make a friend request
 | 
	
		
			
			| 225 |  | -			if [ -f $QTOX_INI ]; then
 | 
	
		
			
			| 226 |  | -				echo $'Launch qTox'
 | 
	
		
			
			| 227 |  | -				qtox &
 | 
	
		
			
			| 228 |  | -			else
 | 
	
		
			
			| 229 |  | -
 | 
	
		
			
			| 230 |  | -				echo "n
 | 
	
		
			
			|  | 186 | +    echo $QTOX_INI
 | 
	
		
			
			|  | 187 | +    if [[ -f $TOXIC_FILE || -f $QTOX_INI ]]; then
 | 
	
		
			
			|  | 188 | +        if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			|  | 189 | +            # update bootstrap nodes
 | 
	
		
			
			|  | 190 | +            if [ -f $DHTNODES ]; then
 | 
	
		
			
			|  | 191 | +                if [ ! -f $DHTNODES.internet ]; then
 | 
	
		
			
			|  | 192 | +                    sudo cp $DHTNODES $DHTNODES.internet
 | 
	
		
			
			|  | 193 | +                fi
 | 
	
		
			
			|  | 194 | +            fi
 | 
	
		
			
			|  | 195 | +            lstox -f dht > /tmp/dht
 | 
	
		
			
			|  | 196 | +            sudo cp /tmp/dht $DHTNODES
 | 
	
		
			
			|  | 197 | +        fi
 | 
	
		
			
			|  | 198 | +
 | 
	
		
			
			|  | 199 | +        # get a list of peers
 | 
	
		
			
			|  | 200 | +        PEER_TOX_ID_LIST=$(lstox | grep $AVAHI_DOMAIN | sort -u)
 | 
	
		
			
			|  | 201 | +        if [ ! "$PEER_TOX_ID_LIST" ]; then
 | 
	
		
			
			|  | 202 | +            echo $'No peers found'
 | 
	
		
			
			|  | 203 | +            exit 0
 | 
	
		
			
			|  | 204 | +        fi
 | 
	
		
			
			|  | 205 | +        PEER_TOX_ID_LIST_COUNT=$(echo "$PEER_TOX_ID_LIST" | wc -l)
 | 
	
		
			
			|  | 206 | +        PEER_TOX_ID=''
 | 
	
		
			
			|  | 207 | +        if [ $PEER_TOX_ID_LIST_COUNT -lt "2" ]; then
 | 
	
		
			
			|  | 208 | +            # single peer
 | 
	
		
			
			|  | 209 | +            PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | awk -F ' ' '{print $3}')
 | 
	
		
			
			|  | 210 | +        else
 | 
	
		
			
			|  | 211 | +            # choose a user from a list
 | 
	
		
			
			|  | 212 | +            echo ''
 | 
	
		
			
			|  | 213 | +            echo $"Select a user on $AVAHI_DOMAIN:"
 | 
	
		
			
			|  | 214 | +            ctr=0
 | 
	
		
			
			|  | 215 | +            while IFS='' read -r line || [[ -n "$line" ]]; do
 | 
	
		
			
			|  | 216 | +                toxusername=$(echo $line | awk -F ' ' '{print $2}')
 | 
	
		
			
			|  | 217 | +                echo "    $ctr. $toxusername"
 | 
	
		
			
			|  | 218 | +                ctr=$((ctr + 1))
 | 
	
		
			
			|  | 219 | +            done < "$PEER_TOX_ID_LIST"
 | 
	
		
			
			|  | 220 | +            read user_index
 | 
	
		
			
			|  | 221 | +            PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | tail -n+${user_index} | head -n1 | awk -F ' ' '{print $3}')
 | 
	
		
			
			|  | 222 | +        fi
 | 
	
		
			
			|  | 223 | +
 | 
	
		
			
			|  | 224 | +        # if this is a valid ID
 | 
	
		
			
			|  | 225 | +        if [ ${#PEER_TOX_ID} -gt 30 ]; then
 | 
	
		
			
			|  | 226 | +            # start client and make a friend request
 | 
	
		
			
			|  | 227 | +            if [ -f $QTOX_INI ]; then
 | 
	
		
			
			|  | 228 | +                echo $'Launch qTox'
 | 
	
		
			
			|  | 229 | +                qtox &
 | 
	
		
			
			|  | 230 | +            else
 | 
	
		
			
			|  | 231 | +
 | 
	
		
			
			|  | 232 | +                echo "n
 | 
	
		
			
			| 231 | 233 |  /nick $USER
 | 
	
		
			
			| 232 | 234 |  /add $PEER_TOX_ID
 | 
	
		
			
			| 233 | 235 |  /exit
 | 
	
		
			
			| 234 | 236 |  " | $TOXIC_FILE -d
 | 
	
		
			
			| 235 |  | -				# Running twice is a hack to get around buggyness in the client
 | 
	
		
			
			| 236 |  | -				$TOXIC_FILE -d
 | 
	
		
			
			| 237 |  | -			fi
 | 
	
		
			
			| 238 |  | -			exit 0
 | 
	
		
			
			| 239 |  | -		else
 | 
	
		
			
			| 240 |  | -			# ID was invalid
 | 
	
		
			
			| 241 |  | -			echo $PEER_TOX_ID
 | 
	
		
			
			| 242 |  | -			echo $"Tox ID for $AVAHI_DOMAIN was not found"
 | 
	
		
			
			| 243 |  | -			exit 6
 | 
	
		
			
			| 244 |  | -		fi
 | 
	
		
			
			| 245 |  | -	fi
 | 
	
		
			
			|  | 237 | +                # Running twice is a hack to get around buggyness in the client
 | 
	
		
			
			|  | 238 | +                $TOXIC_FILE -d
 | 
	
		
			
			|  | 239 | +            fi
 | 
	
		
			
			|  | 240 | +            exit 0
 | 
	
		
			
			|  | 241 | +        else
 | 
	
		
			
			|  | 242 | +            # ID was invalid
 | 
	
		
			
			|  | 243 | +            echo $PEER_TOX_ID
 | 
	
		
			
			|  | 244 | +            echo $"Tox ID for $AVAHI_DOMAIN was not found"
 | 
	
		
			
			|  | 245 | +            exit 6
 | 
	
		
			
			|  | 246 | +        fi
 | 
	
		
			
			|  | 247 | +    fi
 | 
	
		
			
			| 246 | 248 |  }
 | 
	
		
			
			| 247 | 249 |  
 | 
	
		
			
			| 248 | 250 |  if [ -f /var/lib/batman ]; then
 | 
	
		
			
			| 249 |  | -	SERVER_INSTALLATION="yes"
 | 
	
		
			
			|  | 251 | +    SERVER_INSTALLATION="yes"
 | 
	
		
			
			| 250 | 252 |  fi
 | 
	
		
			
			| 251 | 253 |  
 | 
	
		
			
			| 252 | 254 |  if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			| 253 |  | -	if [ ! -f /usr/bin/batman ]; then
 | 
	
		
			
			| 254 |  | -		${PROJECT_NAME}-client
 | 
	
		
			
			| 255 |  | -	fi
 | 
	
		
			
			|  | 255 | +    if [ ! -f /usr/bin/batman ]; then
 | 
	
		
			
			|  | 256 | +        ${PROJECT_NAME}-client
 | 
	
		
			
			|  | 257 | +    fi
 | 
	
		
			
			| 256 | 258 |  fi
 | 
	
		
			
			| 257 | 259 |  
 | 
	
		
			
			| 258 | 260 |  # alternative toxic paths
 | 
	
		
			
			| 259 | 261 |  if [ -f /usr/local/bin/toxic ]; then
 | 
	
		
			
			| 260 |  | -	TOXIC_FILE=/usr/local/bin/toxic
 | 
	
		
			
			|  | 262 | +    TOXIC_FILE=/usr/local/bin/toxic
 | 
	
		
			
			| 261 | 263 |  fi
 | 
	
		
			
			| 262 | 264 |  if [ -f /usr/local/share/toxic/DHTnodes ]; then
 | 
	
		
			
			| 263 |  | -	DHTNODES=/usr/local/share/toxic/DHTnodes
 | 
	
		
			
			|  | 265 | +    DHTNODES=/usr/local/share/toxic/DHTnodes
 | 
	
		
			
			| 264 | 266 |  fi
 | 
	
		
			
			| 265 | 267 |  
 | 
	
		
			
			| 266 | 268 |  if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			| 267 |  | -	if [ ! -f /tmp/meshtype ]; then
 | 
	
		
			
			| 268 |  | -		install_toxcore
 | 
	
		
			
			| 269 |  | -		install_toxid
 | 
	
		
			
			| 270 |  | -		sudo batman start
 | 
	
		
			
			| 271 |  | -		if [ ! "$?" = "0" ]; then
 | 
	
		
			
			| 272 |  | -			exit 2
 | 
	
		
			
			| 273 |  | -		fi
 | 
	
		
			
			| 274 |  | -	fi
 | 
	
		
			
			|  | 269 | +    if [ ! -f /tmp/meshtype ]; then
 | 
	
		
			
			|  | 270 | +        install_toxcore
 | 
	
		
			
			|  | 271 | +        install_toxid
 | 
	
		
			
			|  | 272 | +        sudo batman start
 | 
	
		
			
			|  | 273 | +        if [ ! "$?" = "0" ]; then
 | 
	
		
			
			|  | 274 | +            exit 2
 | 
	
		
			
			|  | 275 | +        fi
 | 
	
		
			
			|  | 276 | +    fi
 | 
	
		
			
			| 275 | 277 |  fi
 | 
	
		
			
			| 276 | 278 |  
 | 
	
		
			
			| 277 | 279 |  avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
 | 
	
		
			
			| 278 | 280 |  
 | 
	
		
			
			| 279 | 281 |  if [ ! -f $PEERS_FILE ]; then
 | 
	
		
			
			| 280 |  | -	echo $'No peers were found'
 | 
	
		
			
			| 281 |  | -	exit 0
 | 
	
		
			
			|  | 282 | +    echo $'No peers were found'
 | 
	
		
			
			|  | 283 | +    exit 0
 | 
	
		
			
			| 282 | 284 |  fi
 | 
	
		
			
			| 283 | 285 |  
 | 
	
		
			
			| 284 | 286 |  ctr=0
 | 
	
		
			
			| 285 | 287 |  while IFS='' read -r line || [[ -n "$line" ]]; do
 | 
	
		
			
			| 286 |  | -	ctr=$((ctr + 1))
 | 
	
		
			
			|  | 288 | +    ctr=$((ctr + 1))
 | 
	
		
			
			| 287 | 289 |  done < "$PEERS_FILE"
 | 
	
		
			
			| 288 | 290 |  
 | 
	
		
			
			| 289 | 291 |  if [ ${ctr} -lt "1" ]; then
 | 
	
		
			
			| 290 |  | -	echo $'No peers were found'
 | 
	
		
			
			| 291 |  | -	exit 0
 | 
	
		
			
			|  | 292 | +    echo $'No peers were found'
 | 
	
		
			
			|  | 293 | +    exit 0
 | 
	
		
			
			| 292 | 294 |  fi
 | 
	
		
			
			| 293 | 295 |  
 | 
	
		
			
			| 294 | 296 |  clear
 | 
	
	
		
			
			|  | @@ -303,8 +305,8 @@ echo ''
 | 
	
		
			
			| 303 | 305 |  echo $'Please choose a peer to connect to:'
 | 
	
		
			
			| 304 | 306 |  idx=1
 | 
	
		
			
			| 305 | 307 |  while IFS='' read -r line || [[ -n "$line" ]]; do
 | 
	
		
			
			| 306 |  | -	echo "    $idx. $line"
 | 
	
		
			
			| 307 |  | -	idx=$((idx + 1))
 | 
	
		
			
			|  | 308 | +    echo "    $idx. $line"
 | 
	
		
			
			|  | 309 | +    idx=$((idx + 1))
 | 
	
		
			
			| 308 | 310 |  done < "$PEERS_FILE"
 | 
	
		
			
			| 309 | 311 |  
 | 
	
		
			
			| 310 | 312 |  peer_index=0
 | 
	
	
		
			
			|  | @@ -312,42 +314,42 @@ read peer_index
 | 
	
		
			
			| 312 | 314 |  
 | 
	
		
			
			| 313 | 315 |  # if no selection made
 | 
	
		
			
			| 314 | 316 |  if [ ! $peer_index ]; then
 | 
	
		
			
			| 315 |  | -	echo $'Nothing was selected'
 | 
	
		
			
			| 316 |  | -	echo ''
 | 
	
		
			
			| 317 |  | -	exit 0
 | 
	
		
			
			|  | 317 | +    echo $'Nothing was selected'
 | 
	
		
			
			|  | 318 | +    echo ''
 | 
	
		
			
			|  | 319 | +    exit 0
 | 
	
		
			
			| 318 | 320 |  fi
 | 
	
		
			
			| 319 | 321 |  
 | 
	
		
			
			| 320 | 322 |  # get the avahi domain name
 | 
	
		
			
			| 321 | 323 |  AVAHI_DOMAIN=
 | 
	
		
			
			| 322 | 324 |  idx=1
 | 
	
		
			
			| 323 | 325 |  while IFS='' read -r line || [[ -n "$line" ]]; do
 | 
	
		
			
			| 324 |  | -	if [ ${idx} -eq "$peer_index" ]; then
 | 
	
		
			
			| 325 |  | -		AVAHI_DOMAIN=${line}.local
 | 
	
		
			
			| 326 |  | -	fi
 | 
	
		
			
			| 327 |  | -	idx=$((idx + 1))
 | 
	
		
			
			|  | 326 | +    if [ ${idx} -eq "$peer_index" ]; then
 | 
	
		
			
			|  | 327 | +        AVAHI_DOMAIN=${line}.local
 | 
	
		
			
			|  | 328 | +    fi
 | 
	
		
			
			|  | 329 | +    idx=$((idx + 1))
 | 
	
		
			
			| 328 | 330 |  done < "$PEERS_FILE"
 | 
	
		
			
			| 329 | 331 |  
 | 
	
		
			
			| 330 | 332 |  if [ ! $AVAHI_DOMAIN ]; then
 | 
	
		
			
			| 331 |  | -	echo $'No domain name'
 | 
	
		
			
			| 332 |  | -	exit 3
 | 
	
		
			
			|  | 333 | +    echo $'No domain name'
 | 
	
		
			
			|  | 334 | +    exit 3
 | 
	
		
			
			| 333 | 335 |  fi
 | 
	
		
			
			| 334 | 336 |  
 | 
	
		
			
			| 335 | 337 |  # if only mumble is installed
 | 
	
		
			
			| 336 | 338 |  if [ ! -f $TOXIC_FILE ]; then
 | 
	
		
			
			| 337 |  | -	if [ -f $MUMBLE_PATH ]; then
 | 
	
		
			
			| 338 |  | -		$MUMBLE_PATH &
 | 
	
		
			
			| 339 |  | -		exit 0
 | 
	
		
			
			| 340 |  | -	fi
 | 
	
		
			
			| 341 |  | -	echo $'You need mumble/toxic/qTox installed on your system'
 | 
	
		
			
			| 342 |  | -	if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			| 343 |  | -		sudo batman stop
 | 
	
		
			
			| 344 |  | -	fi
 | 
	
		
			
			| 345 |  | -	exit 4
 | 
	
		
			
			|  | 339 | +    if [ -f $MUMBLE_PATH ]; then
 | 
	
		
			
			|  | 340 | +        $MUMBLE_PATH &
 | 
	
		
			
			|  | 341 | +        exit 0
 | 
	
		
			
			|  | 342 | +    fi
 | 
	
		
			
			|  | 343 | +    echo $'You need mumble/toxic/qTox installed on your system'
 | 
	
		
			
			|  | 344 | +    if [[ $SERVER_INSTALLATION == "no" ]]; then
 | 
	
		
			
			|  | 345 | +        sudo batman stop
 | 
	
		
			
			|  | 346 | +    fi
 | 
	
		
			
			|  | 347 | +    exit 4
 | 
	
		
			
			| 346 | 348 |  fi
 | 
	
		
			
			| 347 | 349 |  
 | 
	
		
			
			| 348 | 350 |  # if only tox is installed
 | 
	
		
			
			| 349 | 351 |  if [ ! -f $MUMBLE_PATH ]; then
 | 
	
		
			
			| 350 |  | -	run_tox
 | 
	
		
			
			|  | 352 | +    run_tox
 | 
	
		
			
			| 351 | 353 |  fi
 | 
	
		
			
			| 352 | 354 |  
 | 
	
		
			
			| 353 | 355 |  echo ''
 | 
	
	
		
			
			|  | @@ -360,32 +362,32 @@ read peer_index
 | 
	
		
			
			| 360 | 362 |  
 | 
	
		
			
			| 361 | 363 |  # if no selection made
 | 
	
		
			
			| 362 | 364 |  if [ ! $peer_index ]; then
 | 
	
		
			
			| 363 |  | -	echo $'Nothing was selected'
 | 
	
		
			
			| 364 |  | -	echo ''
 | 
	
		
			
			| 365 |  | -	exit 0
 | 
	
		
			
			|  | 365 | +    echo $'Nothing was selected'
 | 
	
		
			
			|  | 366 | +    echo ''
 | 
	
		
			
			|  | 367 | +    exit 0
 | 
	
		
			
			| 366 | 368 |  fi
 | 
	
		
			
			| 367 | 369 |  
 | 
	
		
			
			| 368 | 370 |  if [[ $peer_index == 1 ]]; then
 | 
	
		
			
			| 369 |  | -	if [ -f $MUMBLE_PATH ]; then
 | 
	
		
			
			| 370 |  | -		echo ''
 | 
	
		
			
			| 371 |  | -		echo $'To setup for the first time click "Add New", then set:'
 | 
	
		
			
			| 372 |  | -		echo $"    Label:    $AVAHI_DOMAIN"
 | 
	
		
			
			| 373 |  | -		echo $"    Address:  $AVAHI_DOMAIN"
 | 
	
		
			
			| 374 |  | -		echo $'    Port:     64738'
 | 
	
		
			
			| 375 |  | -		echo $"    Username: $USER"
 | 
	
		
			
			| 376 |  | -		echo ''
 | 
	
		
			
			| 377 |  | -		echo $'Press Enter to continue.'
 | 
	
		
			
			| 378 |  | -		echo ''
 | 
	
		
			
			| 379 |  | -		read peer_index
 | 
	
		
			
			| 380 |  | -		$MUMBLE_PATH &
 | 
	
		
			
			| 381 |  | -	else
 | 
	
		
			
			| 382 |  | -		echo $'Mumble may not be installed on this system'
 | 
	
		
			
			| 383 |  | -		exit 5
 | 
	
		
			
			| 384 |  | -	fi
 | 
	
		
			
			|  | 371 | +    if [ -f $MUMBLE_PATH ]; then
 | 
	
		
			
			|  | 372 | +        echo ''
 | 
	
		
			
			|  | 373 | +        echo $'To setup for the first time click "Add New", then set:'
 | 
	
		
			
			|  | 374 | +        echo $"    Label:    $AVAHI_DOMAIN"
 | 
	
		
			
			|  | 375 | +        echo $"    Address:  $AVAHI_DOMAIN"
 | 
	
		
			
			|  | 376 | +        echo $'    Port:     64738'
 | 
	
		
			
			|  | 377 | +        echo $"    Username: $USER"
 | 
	
		
			
			|  | 378 | +        echo ''
 | 
	
		
			
			|  | 379 | +        echo $'Press Enter to continue.'
 | 
	
		
			
			|  | 380 | +        echo ''
 | 
	
		
			
			|  | 381 | +        read peer_index
 | 
	
		
			
			|  | 382 | +        $MUMBLE_PATH &
 | 
	
		
			
			|  | 383 | +    else
 | 
	
		
			
			|  | 384 | +        echo $'Mumble may not be installed on this system'
 | 
	
		
			
			|  | 385 | +        exit 5
 | 
	
		
			
			|  | 386 | +    fi
 | 
	
		
			
			| 385 | 387 |  fi
 | 
	
		
			
			| 386 | 388 |  
 | 
	
		
			
			| 387 | 389 |  if [[ $peer_index == 2 ]]; then
 | 
	
		
			
			| 388 |  | -	run_tox
 | 
	
		
			
			|  | 390 | +    run_tox
 | 
	
		
			
			| 389 | 391 |  fi
 | 
	
		
			
			| 390 | 392 |  
 | 
	
		
			
			| 391 | 393 |  exit 0
 |