Simplifying avahi browsing

This commit is contained in:
Bob Mottram 2015-09-11 19:36:04 +01:00
parent 12247529e4
commit fe8e416909
3 changed files with 6 additions and 11 deletions

View File

@ -250,7 +250,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then
fi
fi
avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
if [ ! -f $PEERS_FILE ]; then
echo 'No peers were found'

View File

@ -277,7 +277,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then
fi
fi
avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
if [ ! -f $PEERS_FILE ]; then
echo 'No peers were found'

View File

@ -114,7 +114,7 @@ fi
TEMPFILE_BASE=/tmp/tmpzeronetavahibase.txt
TEMPFILE=/tmp/tmpzeronetavahi.txt
avahi-browse -atr > $TEMPFILE_BASE
cat $TEMPFILE_BASE | grep "Workstation\|hostname =\|address =\|port =" > $TEMPFILE
cat $TEMPFILE_BASE | grep "hostname =\|address =\|port =" > $TEMPFILE
if [ ! -f $TEMPFILE ]; then
exit 1
fi
@ -131,7 +131,7 @@ address=""
peer=""
tracker_ctr=0
while IFS='' read -r line || [[ -n "$line" ]]; do
if [ ${state} -eq "2" ]; then
if [ ${state} -eq "1" ]; then
if [[ $line == *"address ="* ]]; then
address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
echo " http://$peer:$TRACKER_PORT/announce" >> $ZERONET_CONFIG.new
@ -139,13 +139,8 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
tracker_ctr=$((tracker_ctr + 1))
fi
fi
if [ ${state} -eq "1" ]; then
if [[ $line == *"hostname ="* ]]; then
peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
state=2
fi
fi
if [[ $line == *"Workstation"* && $line == "= "* ]]; then
if [[ $line == *"hostname ="* ]]; then
peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
state=1
fi
done < "$TEMPFILE"