diff --git a/zen/ipns_TAG_refresh.sh b/zen/ipns_TAG_refresh.sh index 1e72e44..e8aff37 100755 --- a/zen/ipns_TAG_refresh.sh +++ b/zen/ipns_TAG_refresh.sh @@ -220,14 +220,23 @@ for ipnslink in $(ls ~/.zen/PIN/*/IPNSLINK); do ipnsid=$(cat $ipnslink) ipfsid=$(echo $ipnslink | cut -d '/' -f 6) mediakey=$(cat ~/.zen/PIN/${ipfsid}/MEDIAKEY) - - [[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue + + [[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue ## GET ACTUAL IPNS .chain VALUE actual=$(ipfs --timeout 12s cat /ipns/$ipnsid/.chain) ## PUBLISH IT - [[ $actual ]] && ipfs --timeout 20s name publish -k ${mediakey} --quieter /ipfs/${actual} - echo "REFRESHED https://tube.copylaradio.com/ipns/$ipnsid TO /ipfs/$actual" + if [[ $actual != "" ]]; then + echo "${mediakey} : STATION DHT ONLINE" + ipfs --timeout 20s name publish -k ${mediakey} --quieter /ipfs/${actual} + echo "${actual}" > ~/.zen/PIN/$ipfsid/ACTUAL + else + echo "${mediakey} : STATION OFFLINE" + [[ -f ~/.zen/PIN/$ipfsid/ACTUAL ]] && actual=$(cat ~/.zen/PIN/$ipfsid/ACTUAL) || continue + ipfs --timeout 20s name publish -k ${mediakey} --quieter /ipfs/${actual} + fi + echo "PUBLISH https://tube.copylaradio.com/ipns/$ipnsid TO /ipfs/$actual" + actual="" done ########################################################################