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