From ad53814c69f44c34ea7cf4a4c1e54fbff3994157 Mon Sep 17 00:00:00 2001 From: fred Date: Mon, 11 Sep 2023 23:55:07 +0200 Subject: [PATCH] debug time --- ASTROBOT/G1CopierYoutube.sh | 25 +++++++++++---------- ASTROBOT/G1Kodi.sh | 44 +------------------------------------ RUNTIME/PLAYER.refresh.sh | 4 ++-- RUNTIME/UPLANET.refresh.sh | 41 +++++++++++++++++++++++++++++++--- 4 files changed, 54 insertions(+), 60 deletions(-) diff --git a/ASTROBOT/G1CopierYoutube.sh b/ASTROBOT/G1CopierYoutube.sh index a6ee6163..d04c7b95 100755 --- a/ASTROBOT/G1CopierYoutube.sh +++ b/ASTROBOT/G1CopierYoutube.sh @@ -224,7 +224,9 @@ if [[ ! ${TIDDLER} ]]; then [[ ! isLAN ]] && TEXT="$TEXT <>" echo $TEXT - echo '[ + TIDDLER="${HOME}/.zen/tmp/${IPFSNODEID}/G1CopierYoutube/${PLAYER}/${YID}.TW.json" + + echo '[ { "created": "'${MOATS}'", "resolution": "'${RES}'", @@ -250,21 +252,19 @@ if [[ ! ${TIDDLER} ]]; then "tags": "'ipfs G1CopierYoutube ${PLAYER} ${EXTRATAG} ${MIME} ${CTITLE}'" } ] -' > "${HOME}/.zen/tmp/${IPFSNODEID}/G1CopierYoutube/${PLAYER}/$YID.TW.json" +' > ${TIDDLER} tot=$((tot+1)) - TIDDLER="${HOME}/.zen/tmp/${IPFSNODEID}/G1CopierYoutube/${PLAYER}/$YID.TW.json" - else ################################################################### - echo + echo "${TIDDLER} FOUND" ################################################################### ## TODO : ADD EMAIL TAG ( TIMESTAMP & ADD SIGNATURE over existing ones) continue fi -cp -f "${TIDDLER}" "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/" + cp -f "${TIDDLER}" "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/" ################################################################# @@ -275,20 +275,21 @@ cp -f "${TIDDLER}" "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/" rm -f ~/.zen/tmp/${IPFSNODEID}/newindex.html - echo ">>> Importing ${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/$YID.TW.json" + echo ">>> Importing ${TIDDLER}" tiddlywiki --load ${INDEX} \ - --import "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/$YID.TW.json" "application/json" \ + --import "${TIDDLER}" "application/json" \ --output ~/.zen/tmp/${IPFSNODEID} --render "$:/core/save/all" "newindex.html" "text/plain" -# --deletetiddlers '[tag[CopierYoutube]]' ### REFRESH CHANNEL COPY - if [[ -s ~/.zen/tmp/${IPFSNODEID}/newindex.html ]]; then ## COPY JSON TIDDLER TO PLAYER - ln -s "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/$YID.TW.json" "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/${ZFILE}.json" + ln -s "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/$YID.TW.json" \ + "${HOME}/.zen/game/players/${PLAYER}/G1CopierYoutube/${ZFILE}.json" - [[ $(diff ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} ) ]] && cp ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} && echo "===> Mise à jour ${INDEX}" + [[ $(diff ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} ) ]] \ + && mv ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} \ + && echo "===> Mise à jour ${INDEX}" else echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/${IPFSNODEID}/newindex.html" diff --git a/ASTROBOT/G1Kodi.sh b/ASTROBOT/G1Kodi.sh index 5c57b802..b6dc4f71 100755 --- a/ASTROBOT/G1Kodi.sh +++ b/ASTROBOT/G1Kodi.sh @@ -264,49 +264,7 @@ done < ~/.zen/tmp/${MOATS}/${PLAYER}.movie.id ## VERIFY, COULD BE DONE IN PLAYER REFRESH if [[ $(diff ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html ${INDEX}) ]]; then - cp ${INDEX} ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html - ## PLAYER.refresh will detect change & publish - - #~ ################################################ - #~ ## GET TW CHAIN - #~ tiddlywiki --load ${INDEX} \ - #~ --output ~/.zen/tmp/${MOATS} \ - #~ --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport' - #~ ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport) - #~ [[ $ASTROPORT == "" ]] && echo "INCOMPATIBLE TW - ADD Astroport TIDDLER - CORRECTION NEEDED -" && exit 1 - - #~ CURCHAIN=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].chain | rev | cut -f 1 -d '/' | rev) # Remove "/ipfs/" part - #~ [[ $CURCHAIN == "" || $CURCHAIN == "null" ]] && echo "FATAL ERROR TW CHAIN IS BROKEN : CHECK ${INDEX} - EXIT -" && exit 1 - #~ ## CHAINING - #~ echo "CURCHAIN=$CURCHAIN" - #~ [[ -s ~/.zen/game/players/$PLAYER/ipfs/moa/.chain ]] \ - #~ && ZCHAIN=$(cat ~/.zen/game/players/$PLAYER/ipfs/moa/.chain) \ - #~ && echo "# CHAIN : $CURCHAIN -> $ZCHAIN" \ - #~ && sed -i "s~$CURCHAIN~$ZCHAIN~g" ${INDEX} - - #~ ################################################ - #~ ## UPDATE PLAYER TW - #~ espeak "I P N S Publishing. Please wait..." - #~ cp ${INDEX} ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html - - #~ cp ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain \ - #~ ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain.$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.moats) - - #~ TW=$(ipfs add -Hq ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html | tail -n 1) - #~ ipfs name publish --key=${PLAYER} /ipfs/$TW - - #~ ## UPDATE LAST KNOWN FOR NEXT CHAIN - #~ echo $TW > ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain - #~ echo ${MOATS} > ~/.zen/game/players/${PLAYER}/ipfs/moa/.moats - - #~ echo "================================================" - #~ echo "${PLAYER} : $myIPFS/ipns/$ASTRONAUTENS" - #~ echo "================================================" - #~ echo - #~ espeak "DONE " - -#~ else - + cp ${INDEX} ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html echo "CHANGED TW" fi diff --git a/RUNTIME/PLAYER.refresh.sh b/RUNTIME/PLAYER.refresh.sh index 754850e9..02166f6c 100755 --- a/RUNTIME/PLAYER.refresh.sh +++ b/RUNTIME/PLAYER.refresh.sh @@ -258,9 +258,9 @@ for PLAYER in ${PLAYERONE[@]}; do ## Publish on LAT/ON key on 12345 CACHE [[ ${LAT} && ${LON} ]] \ - && mkdir ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON}/RSS/ \ + && mkdir -p ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON}/RSS/ \ && cp ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON}/RSS/ \ - && echo "" > ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON}/index.html + && echo "" > ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON}/index.html ls -al ~/.zen/tmp/${IPFSNODEID}/UPLANET/_${LAT}_${LON} 2>/dev/null echo "(☉_☉ ) (☉_☉ ) (☉_☉ )" diff --git a/RUNTIME/UPLANET.refresh.sh b/RUNTIME/UPLANET.refresh.sh index 3eda115d..ecfd5218 100755 --- a/RUNTIME/UPLANET.refresh.sh +++ b/RUNTIME/UPLANET.refresh.sh @@ -22,16 +22,19 @@ mkdir ~/.zen/tmp/${MOATS} ############################ ## RUNING FOR ALL UMAP FOUND IN STATION MAP CACHE : "_LAT_LON" - ## SEARCH UMAP + ## SEARCH UMAP (created by PLAYER.refresh.sh) UMAPS=($(ls -t ~/.zen/tmp/${IPFSNODEID}/UPLANET/ 2>/dev/null)) echo "FOUND : ${UMAPS[@]}" for UMAP in ${UMAPS[@]}; do + start=`date +%s` echo ">>> REFRESHING ${UMAP}" LAT=$(echo ${UMAP} | cut -d '_' -f 2) LON=$(echo ${UMAP} | cut -d '_' -f 3) + [[ $LAT == "" || $LON == "" ]] && echo ">> ERROR BAD $LAT $LON" && continue + ############################################################## WALLET=$(${MY_PATH}/../tools/keygen -t duniter "$LAT" "$LON") [[ ! ${WALLET} ]] && echo "ERROR generating WALLET" && exit 1 @@ -47,10 +50,14 @@ mkdir ~/.zen/tmp/${MOATS} ############################################### ## FORMAT CONTROL - [[ ! -s ~/.zen/tmp/${MOATS}/${UMAP}/${UMAP}/UMAP.refresh ]] \ - && echo ">>> ERROR - UMAP.refresh MISSING - ERROR -" \ + [[ ! -d ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET} || ! -d ~/.zen/tmp/${MOATS}/${UMAP}/${UMAP} ]] \ + && echo ">>> ERROR - UMAP BAD FORMAT - ERROR -" \ && continue + ## UMAP.refresh CORRECTION + [[ ! -s ~/.zen/tmp/${MOATS}/${UMAP}/${UMAP}/UMAP.refresh ]] \ + && echo "${IPFSNODEID}" > ~/.zen/tmp/${MOATS}/${UMAP}/${UMAP}/UMAP.refresh + ######################################################## ## NODE SELECTION in UMAP.refresh UREFRESH="${HOME}/.zen/tmp/${MOATS}/${UMAP}/${UMAP}/UMAP.refresh" @@ -77,6 +84,8 @@ mkdir ~/.zen/tmp/${MOATS} mv ${UREFRESH}.shuf ${UREFRESH} ######################################################## # NODE SELECTION in UMAP.refresh + ############################################################## + ############################################################## ############################################################## ## CALCULATE SURROUNDING UMAPS ############################################################## @@ -89,6 +98,7 @@ mkdir ~/.zen/tmp/${MOATS} ipfs key rm ${NWALLET} > /dev/null 2>&1 ## AVOID ERROR ON IMPORT ${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/NWALLET.priv "$NLAT" "$NLON" NUMAPNS=$(ipfs key import ${NWALLET} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/NWALLET.priv) + ipfs key rm ${NWALLET} ############################################################## # South Umap @@ -174,5 +184,30 @@ mkdir ~/.zen/tmp/${MOATS} SWUMAPNS=$(ipfs key import ${SEWALLET} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/SEWALLET.priv) ipfs key rm ${SEWALLET} + ############################################################## + ############################ PUBLISHING UMAP + ############################################################## + UMAPROOT=$(ipfs add -rwHq ~/.zen/tmp/${MOATS}/${UMAP}/* | tail -n 1) + + ZCHAIN=$(cat ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_chain 2>/dev/null) + ZMOATS=$(cat ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_moats 2>/dev/null) + [[ ${ZCHAIN} && ${ZMOATS} ]] \ + && cp ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_chain ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_chain.${ZMOATS} \ + && echo "UPDATING MOATS" + + ## DOES CHAIN CHANGED or INIT ? + [[ ${ZCHAIN} != ${UMAPROOT} || ${ZCHAIN} == "" ]] \ + && echo "${UMAPROOT}" > ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_chain \ + && echo "${MOATS}" > ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/_moats \ + && UMAPROOT=$(ipfs add -rwHq ~/.zen/tmp/${MOATS}/${UMAP}/${WALLET}/* | tail -n 1) && echo "ROOT was ${ZCHAIN}" + + echo "PUBLISHING NEW UMAPROOT : http://ipfs.localhost:8080/ipfs/${UMAPROOT}" + + ipfs name publish --key=${WALLET} /ipfs/${UMAPROOT} + end=`date +%s` + ipfs key rm ${WALLET} ## REMOVE IPNS KEY + + echo "(UMAP) PUBLISH time was "`expr $end - $start` seconds. + done