#!/bin/bash set -x topic="$1" last="$2" timeout="$3" cur=$(ipfs name resolve --nocache "$topic") if [ "$cur" != "$last" ]; then exit 1 fi timeout "${timeout}s" ipfs pubsub sub "$topic" 2>/dev/null | while read VALUE; do pkill -P $$ cur=$(ipfs name resolve --nocache "$topic") if [ "$cur" != "$last" ]; then exit 1 fi exit 0 done cur=$(ipfs name resolve --nocache "$topic") if [ "$cur" != "$last" ]; then exit 1 fi exit 0