From 174be0eeeca2d91a9efd40b2aa976ecc4f477832 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 24 Aug 2022 11:50:26 +0200 Subject: [PATCH] verify 'ipfs cat' file exist & not empty --- G1VOEUX.sh | 6 +++--- tools/VISA.new.sh | 3 ++- tools/VOEUX.refresh.sh | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/G1VOEUX.sh b/G1VOEUX.sh index b17d53a0..384f3c6e 100755 --- a/G1VOEUX.sh +++ b/G1VOEUX.sh @@ -38,7 +38,7 @@ mkdir -p ~/.zen/tmp/TW rm -f ~/.zen/tmp/TW/index.html ipfs --timeout 6s cat /ipns/$ASTRONAUTENS > ~/.zen/tmp/TW/index.html -if [ ! -f ~/.zen/tmp/TW/index.html ]; then +if [ ! -s ~/.zen/tmp/TW/index.html ]; then echo "ERROR IPNS TIMEOUT. Restoring local backup..." TW=$(ipfs add -rHq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1) ipfs name publish --key=$PLAYER /ipfs/$TW @@ -111,7 +111,7 @@ do --import ~/.zen/Astroport.ONE/templates/data/local.api.json "application/json" \ --import ~/.zen/Astroport.ONE/templates/data/local.gw.json "application/json" \ --output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain" - [[ -f ~/.zen/tmp/newindex.html ]] && cp ~/.zen/tmp/newindex.html ~/.zen/game/world/$WISHKEY/index.html + [[ -s ~/.zen/tmp/newindex.html ]] && cp ~/.zen/tmp/newindex.html ~/.zen/game/world/$WISHKEY/index.html ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://127.0.0.1:8080", "http://astroport", "https://astroport.com", "https://qo-op.com", "https://tube.copylaradio.com", "http://'$(hostname)'.local:8080" ]' ## RESTART IPFS !? @@ -186,7 +186,7 @@ convert -gravity northwest -pointsize 50 -fill black -draw "text 30,300 \"Ğ1 VO --output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain" echo "PLAYER TW Update..." - if [[ -f ~/.zen/tmp/newindex.html ]]; then + if [[ -s ~/.zen/tmp/newindex.html ]]; then echo "Mise à jour ~/.zen/game/players/$PLAYER/ipfs/moa/index.html" cp -f ~/.zen/tmp/newindex.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html MOATS=$(date -u +"%Y%m%d%H%M%S%4N") diff --git a/tools/VISA.new.sh b/tools/VISA.new.sh index 236b8d97..8754e850 100755 --- a/tools/VISA.new.sh +++ b/tools/VISA.new.sh @@ -31,7 +31,8 @@ if [[ $SALT != "" && PEPPER != "" ]]; then ipfs key list -l | grep -w $GNS ipfs key list -l | grep -w $GNS | wc -l - if [ ! -f ~/.zen/tmp/TW/index.html ]; then + if [ ! -s ~/.zen/tmp/TW/index.html ]; then + rm -f ~/.zen/tmp/TW/index.html echo "Aucun ancien TW détecté! Appuyez sur ENTRER pour créer un nouveau TW Astronaute" read else diff --git a/tools/VOEUX.refresh.sh b/tools/VOEUX.refresh.sh index ce497897..5702caf5 100755 --- a/tools/VOEUX.refresh.sh +++ b/tools/VOEUX.refresh.sh @@ -77,7 +77,7 @@ for PLAYER in $(ls ~/.zen/game/players/); do mkdir -p ~/.zen/tmp/astro ipfs --timeout 12s cat /ipns/$ASTRONAUTENS > ~/.zen/tmp/astro/index.html - if [ ! -f ~/.zen/tmp/astro/index.html ]; then + if [ ! -s ~/.zen/tmp/astro/index.html ]; then echo "ERROR IPNS TIMEOUT. Using local backup..." continue else