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,26 +159,28 @@ function install_toxid {
function run_tox { function run_tox {
if [ -f $TOXIC_PATH ]; then if [ -f $TOXIC_PATH ]; then
# update bootstrap nodes if [[ $SERVER_INSTALLATION == "no" ]]; then
if [ -f $DHTNODES ]; then # update bootstrap nodes
if [ ! -f $DHTNODES.internet ]; then if [ -f $DHTNODES ]; then
sudo cp $DHTNODES $DHTNODES.internet if [ ! -f $DHTNODES.internet ]; then
sudo cp $DHTNODES $DHTNODES.internet
fi
fi fi
lstox -f dht > /tmp/dht
sudo cp /tmp/dht $DHTNODES
fi fi
lstox -f dht > /tmp/dht
sudo cp /tmp/dht $DHTNODES
# 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