astrXbian/zen/tools/ping_my_friends_on_ipfs.sh

25 lines
1.1 KiB
Bash
Raw Normal View History

2021-07-06 19:30:48 +02:00
#!/bin/bash
2021-08-06 12:24:24 +02:00
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l)
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
echo "## IPFS PINGing MY FRIENDS"
for ipfsid in $(cat ~/.zen/ipfs_swarm/.*/.ipfsnodeid); do
if [[ $ipfsid != $IPFSNODEID ]]; then
echo "TESTING $ipfsid"
2021-08-06 12:32:21 +02:00
ipfs -timeout=7s ping -n5 /p2p/$ipfsid 2>/dev/null | tail -n 1
if [ $? -eq 0 ]; then
2022-05-14 15:56:55 +02:00
zuidonline=$(ipfs -timeout=10s cat /ipns/$ipfsid/.$ipfsid/.player 2>/dev/null) || zuidonline="TIMEOUT"
[[ -f ~/.zen/ipfs_swarm/.$ipfsid/.player ]] && zuidoffline=$(cat ~/.zen/ipfs_swarm/.$ipfsid/.player) || zuidoffline="UNKOWN"
2021-08-06 12:32:21 +02:00
echo "Station $zuidonline [$zuidoffline] : OK"
else
2022-05-14 15:56:55 +02:00
echo "Station $(cat ~/.zen/ipfs_swarm/.$ipfsid/.player) : DEAD"
2021-08-06 12:32:21 +02:00
fi
echo ""
2021-07-06 19:30:48 +02:00
fi
done