This commit is contained in:
Bob Mottram 2015-08-27 21:18:44 +01:00
parent b7c8141ae5
commit dc148cbbad
1 changed files with 12 additions and 10 deletions

View File

@ -159,6 +159,7 @@ function install_toxid {
function run_tox {
if [ -f $TOXIC_PATH ]; then
if [[ $SERVER_INSTALLATION == "no" ]]; then
# update bootstrap nodes
if [ -f $DHTNODES ]; then
if [ ! -f $DHTNODES.internet ]; then
@ -167,18 +168,19 @@ function run_tox {
fi
lstox -f dht > /tmp/dht
sudo cp /tmp/dht $DHTNODES
fi
# get a list of peers
PEER_TOX_ID_LIST=$(lstox | grep $AVAHI_DOMAIN | sort -u)
if [ ! $PEER_TOX_ID_LIST ]; then
if [ ! "$PEER_TOX_ID_LIST" ]; then
echo 'No peers found'
exit 0
fi
PEER_TOX_ID_LIST_COUNT=$(echo $PEER_TOX_ID_LIST | wc -l)
PEER_TOX_ID_LIST_COUNT=$(echo "$PEER_TOX_ID_LIST" | wc -l)
PEER_TOX_ID=''
if [ $PEER_TOX_ID_LIST_COUNT -lt "2" ]; then
# single peer
PEER_TOX_ID=$(echo $PEER_TOX_ID_LIST | awk -F ' ' '{print $3}')
PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | awk -F ' ' '{print $3}')
else
# choose a user from a list
echo ''
@ -190,7 +192,7 @@ function run_tox {
ctr=$((ctr + 1))
done < "$PEER_TOX_ID_LIST"
read user_index
PEER_TOX_ID=$(echo $PEER_TOX_ID_LIST | tail -n+${user_index} | head -n1 | awk -F ' ' '{print $3}')
PEER_TOX_ID=$(echo "$PEER_TOX_ID_LIST" | tail -n+${user_index} | head -n1 | awk -F ' ' '{print $3}')
fi
# if this is a valid ID