wait_for_ipns_change 437 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -x
  3. topic="$1"
  4. last="$2"
  5. timeout="$3"
  6. cur=$(ipfs name resolve --nocache "$topic")
  7. if [ "$cur" != "$last" ]; then
  8. exit 1
  9. fi
  10. timeout "${timeout}s" ipfs pubsub sub "$topic" 2>/dev/null | while read VALUE; do
  11. pkill -P $$
  12. cur=$(ipfs name resolve --nocache "$topic")
  13. if [ "$cur" != "$last" ]; then
  14. exit 1
  15. fi
  16. exit 0
  17. done
  18. cur=$(ipfs name resolve --nocache "$topic")
  19. if [ "$cur" != "$last" ]; then
  20. exit 1
  21. fi
  22. exit 0