Skip to content

Commit

Permalink
Updated up.sh to support passing the target peer address as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
luccioman committed Dec 10, 2018
1 parent 1b3cb38 commit b3d8407
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions bin/up.sh
@@ -1,7 +1,20 @@
#!/usr/bin/env sh
cd "`dirname $0`"
./apicall.sh "/Network.xml?page=1" | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}';
# List the active principal and senior peers known by the local peer or by the peer at the given address
# $1 : (optional) the peer address as host:port

#port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
#./up1.sh localhost:$port
cd "`dirname $0`"

if [ -z "$1" ]; then
# Request the local peer
./apicall.sh "/Network.xml?page=1" | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}'
else
# Request the given peer
if which curl > /dev/null; then
curl -sSf "http://$1/Network.xml?page=1" | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}'
elif which wget > /dev/null; then
wget -nv -t 1 --timeout=120 "http://$1/Network.xml?page=1" -O - | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}'
else
echo "Please install curl or wget" > /dev/stderr
exit 1
fi
fi

0 comments on commit b3d8407

Please sign in to comment.