2022-08-25 17:21:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
2022-10-12 23:29:14 +02:00
|
|
|
# Version: 0.2
|
2022-08-25 17:21:39 +02:00
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
################################################################################
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
2022-12-29 14:51:05 +01:00
|
|
|
. "$MY_PATH/../tools/my.sh"
|
2022-08-25 17:21:39 +02:00
|
|
|
################################################################################
|
2022-10-09 23:07:30 +02:00
|
|
|
## Publish All PLAYER TW,
|
|
|
|
# Run TAG subprocess: tube, voeu
|
2022-08-25 17:21:39 +02:00
|
|
|
############################################
|
2022-10-09 23:07:30 +02:00
|
|
|
echo "## RUNNING PLAYER.refresh"
|
2022-08-25 17:21:39 +02:00
|
|
|
|
2022-12-11 04:40:50 +01:00
|
|
|
PLAYERONE="$1"
|
2023-02-27 03:44:39 +01:00
|
|
|
# [[ $isLAN ]] && PLAYERONE=$(cat ~/.zen/game/players/.current/.player 2>/dev/null)
|
2023-04-20 15:09:17 +02:00
|
|
|
[[ ! ${PLAYERONE} ]] && PLAYERONE=($(ls -t ~/.zen/game/players/ | grep "@" 2>/dev/null))
|
2022-12-11 04:40:50 +01:00
|
|
|
|
2023-02-23 20:58:01 +01:00
|
|
|
echo "FOUND : ${PLAYERONE[@]}"
|
|
|
|
|
2024-03-09 16:51:08 +01:00
|
|
|
echo "RENEWING LOCAL UPLANET REPOSITORY
|
2024-02-03 15:18:29 +01:00
|
|
|
~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_*_*/_*.?_*.?/_*.??_*.??"
|
|
|
|
rm -Rf ~/.zen/tmp/${IPFSNODEID}/UPLANET
|
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/UPLANET
|
2024-03-09 16:51:08 +01:00
|
|
|
echo "CLEANING IPFSNODEID TW CACHE ~/.zen/tmp/${IPFSNODEID}/TW/"
|
2023-11-30 18:23:35 +01:00
|
|
|
rm -Rf ~/.zen/tmp/${IPFSNODEID}/TW/
|
2023-09-11 17:08:22 +02:00
|
|
|
|
2022-10-09 23:07:30 +02:00
|
|
|
## RUNING FOR ALL LOCAL PLAYERS
|
2022-12-11 20:39:27 +01:00
|
|
|
for PLAYER in ${PLAYERONE[@]}; do
|
2023-04-20 15:09:17 +02:00
|
|
|
[[ ! -d ~/.zen/game/players/${PLAYER:-undefined} ]] && echo "BAD ${PLAYERONE}" && continue
|
|
|
|
[[ ! $(echo "${PLAYER}" | grep '@') ]] && continue
|
2022-12-28 17:21:50 +01:00
|
|
|
|
2024-03-02 09:55:51 +01:00
|
|
|
start=`date +%s`
|
2023-02-25 03:19:33 +01:00
|
|
|
# CLEAN LOST ACCOUNT
|
2023-04-20 15:09:17 +02:00
|
|
|
[[ ! -s ~/.zen/game/players/${PLAYER}/secret.dunikey ]] \
|
|
|
|
&& rm -Rf ~/.zen/game/players/${PLAYER} \
|
2024-03-09 16:51:08 +01:00
|
|
|
&& echo "WARNING - ERASE ${PLAYER} - BADLY PLUGGED" \
|
2023-04-20 15:09:17 +02:00
|
|
|
&& continue
|
2023-02-25 03:19:33 +01:00
|
|
|
|
2023-11-28 22:08:12 +01:00
|
|
|
### UPGRADE PLAYER for myos IPFS API ### DOUBLON WITH VISA.new (TO REMOVE)
|
|
|
|
mkdir -p ~/.zen/game/players/${PLAYER}/.ipfs # Prepare PLAYER datastructure
|
|
|
|
echo "/ip4/127.0.0.1/tcp/5001" > ~/.zen/game/players/${PLAYER}/.ipfs/api
|
2023-11-30 18:23:35 +01:00
|
|
|
######## WORK IN PROGRESS #### myos integration
|
2023-11-28 22:08:12 +01:00
|
|
|
|
2022-12-09 03:21:41 +01:00
|
|
|
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
2022-12-09 19:10:45 +01:00
|
|
|
mkdir -p ~/.zen/tmp/${MOATS}
|
2024-03-09 16:51:08 +01:00
|
|
|
echo "############################################ ~/.zen/tmp/${MOATS}"
|
2024-02-17 13:12:37 +01:00
|
|
|
echo "##################################################################"
|
2024-03-09 16:51:08 +01:00
|
|
|
echo ">>>>> PLAYER : ${PLAYER} >>>>>>>>>>>>> REFRESHING TW "
|
2024-03-15 14:25:21 +01:00
|
|
|
echo "################################################ $(date)"
|
2023-04-20 15:09:17 +02:00
|
|
|
PSEUDO=$(cat ~/.zen/game/players/${PLAYER}/.pseudo 2>/dev/null)
|
|
|
|
G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null)
|
|
|
|
ASTRONS=$(cat ~/.zen/game/players/${PLAYER}/.playerns 2>/dev/null)
|
2022-12-09 00:58:48 +01:00
|
|
|
# Get PLAYER wallet amount
|
2024-03-09 16:51:08 +01:00
|
|
|
$MY_PATH/../tools/COINScheck.sh ${G1PUB} > ~/.zen/tmp/${MOATS}/${PLAYER}.COINScheck
|
|
|
|
cat ~/.zen/tmp/${MOATS}/${PLAYER}.COINScheck ###DEBUG MODE
|
|
|
|
COINS=$(cat ~/.zen/tmp/${MOATS}/${PLAYER}.COINScheck | tail -n 1)
|
2023-11-30 18:23:35 +01:00
|
|
|
ZEN=$(echo "($COINS - 1) * 10" | bc | cut -d '.' -f 1)
|
|
|
|
echo "+++ WALLET BALANCE _ $COINS (G1) _ / $ZEN ZEN /"
|
|
|
|
|
2024-03-09 16:51:08 +01:00
|
|
|
#~ ## ZENCARD ARE ACTIVATED WITH 1 G1 + 10 ZEN (= 10 €/OC) ?
|
|
|
|
echo "## >>>>>>>>>>>>>>>> REFRESH ASTRONAUTE TW"
|
2022-10-24 14:59:14 +02:00
|
|
|
|
2022-08-25 17:21:39 +02:00
|
|
|
## REFRESH ASTRONAUTE TW
|
2023-10-11 14:24:09 +02:00
|
|
|
ASTRONAUTENS=$(ipfs key list -l | grep -w ${G1PUB} | cut -d ' ' -f1)
|
|
|
|
|
2024-03-09 16:51:08 +01:00
|
|
|
############### CANNOT FIND PLAYER KEY ###########
|
2023-10-11 14:24:09 +02:00
|
|
|
if [[ ! ${ASTRONAUTENS} ]]; then
|
|
|
|
|
|
|
|
echo "${PLAYER} TW IS DISCONNECTED... RECREATING IPNS KEYS"
|
2024-03-09 16:51:08 +01:00
|
|
|
## TODO : EXTRACT & DECRYPT secret.june FROM TW
|
2023-10-11 14:24:09 +02:00
|
|
|
ipfs key import ${G1PUB} -f pem-pkcs8-cleartext ~/.zen/game/players/${PLAYER}/secret.player
|
|
|
|
ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/game/players/${PLAYER}/secret.player
|
|
|
|
|
|
|
|
source ~/.zen/game/players/${PLAYER}/secret.june
|
|
|
|
${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/feed.ipfskey "$SALT" "$G1PUB"
|
|
|
|
FEEDNS=$(ipfs key import "${PLAYER}_feed" -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/feed.ipfskey)
|
|
|
|
|
2023-11-30 18:23:35 +01:00
|
|
|
## IF ASTRONS="" KEY WILL BE DELETED AFTER REFRESH
|
2023-10-11 14:24:09 +02:00
|
|
|
ASTRONAUTENS=$ASTRONS && ASTRONS=""
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2023-05-02 02:51:23 +02:00
|
|
|
[[ ! ${ASTRONAUTENS} ]] && echo "ERROR BAD ${PLAYER} - CONTINUE" && continue
|
|
|
|
|
2023-04-20 15:09:17 +02:00
|
|
|
echo ">>> $myIPFS/ipns/${ASTRONAUTENS}"
|
2023-01-16 22:38:34 +01:00
|
|
|
|
2023-11-30 18:23:35 +01:00
|
|
|
## ACTIVATE PLAYER TW IN STATION CACHE
|
2023-09-06 14:16:59 +02:00
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/
|
2022-08-25 17:21:39 +02:00
|
|
|
|
2023-10-26 14:41:38 +02:00
|
|
|
################### GET LATEST TW
|
2023-11-30 18:23:35 +01:00
|
|
|
echo "GETTING TW..."
|
2024-03-09 16:51:08 +01:00
|
|
|
####################################################################################################
|
2023-10-20 01:53:09 +02:00
|
|
|
ipfs --timeout 480s get -o ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html /ipns/${ASTRONAUTENS}
|
2024-03-09 16:51:08 +01:00
|
|
|
####################################################################################################
|
2022-10-09 23:07:30 +02:00
|
|
|
## PLAYER TW IS ONLINE ?
|
2023-09-06 14:16:59 +02:00
|
|
|
if [ ! -s ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html ]; then
|
2022-10-09 23:07:30 +02:00
|
|
|
|
2023-10-26 14:41:38 +02:00
|
|
|
NOWCHAIN=$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain)
|
2023-10-20 01:53:09 +02:00
|
|
|
LASTCHAIN=$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain.* | tail -n 1)
|
2024-03-10 14:14:03 +01:00
|
|
|
try=$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.try 2>/dev/null) || try=3
|
2024-01-11 16:59:16 +01:00
|
|
|
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>"
|
|
|
|
echo "<a href='$myIPFS/ipns/${ASTRONAUTENS}'>TW REFRESH FAILED</a>"
|
2024-03-10 14:14:03 +01:00
|
|
|
echo ">> %%% WARNING TRY LEFT : $try %%%"
|
2022-10-09 23:07:30 +02:00
|
|
|
echo "------------------------------------------------"
|
2024-01-11 16:59:16 +01:00
|
|
|
echo " * <a href='${myIPFS}/ipfs/${LASTCHAIN}'>LAST</a>"
|
2024-03-10 14:14:03 +01:00
|
|
|
echo " * <a href='${myIPFS}/ipfs/${NOWCHAIN}'>NOW</a>"
|
2022-10-12 23:29:14 +02:00
|
|
|
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
2024-03-10 14:14:03 +01:00
|
|
|
|
2023-11-30 18:23:35 +01:00
|
|
|
## SEND AN EMAIL ALERT TO PLAYER
|
2024-01-11 16:59:16 +01:00
|
|
|
echo "<html><body><a href='$myIPFS/ipns/${ASTRONAUTENS}'>TW REFRESH FAILED</a>" > ~/.zen/tmp/result
|
|
|
|
echo "<br>------------------------------------------------" >> ~/.zen/tmp/result
|
2024-03-10 14:14:03 +01:00
|
|
|
echo "<br>" >> ~/.zen/tmp/result
|
|
|
|
echo "<br><a href='${myIPFS}/ipfs/${LASTCHAIN}'>TW[-1]</a>" >> ~/.zen/tmp/result
|
|
|
|
echo "<br><a href='${myIPFS}/ipfs/${NOWCHAIN}'>TW[0]</a>" >> ~/.zen/tmp/result
|
|
|
|
echo "<br>" >> ~/.zen/tmp/result
|
|
|
|
echo "<br> %%% WARNING %%% $try TRY LEFT %%%" >> ~/.zen/tmp/result
|
2024-01-11 16:59:16 +01:00
|
|
|
echo "<br>------------------------------------------------" >> ~/.zen/tmp/result
|
2024-03-10 14:14:03 +01:00
|
|
|
echo "<br>REPAIR BY SAVING ONLINE<br>" >> ~/.zen/tmp/result
|
|
|
|
echo "COMMAND :<br>ipfs name publish --key=${PLAYER} /ipfs/${NOWCHAIN}" >> ~/.zen/tmp/result
|
|
|
|
echo "</body></html>" >> ~/.zen/tmp/result
|
2023-11-30 18:23:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
[[ $try == 0 ]] \
|
|
|
|
&& echo "PLAYER ${PLAYER} UNPLUG" \
|
2024-02-14 19:36:37 +01:00
|
|
|
&& ${MY_PATH}/PLAYER.unplug.sh ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html ${PLAYER} \
|
2023-11-30 18:23:35 +01:00
|
|
|
&& continue
|
|
|
|
|
|
|
|
try=$((try-1))
|
|
|
|
echo "$try" > ~/.zen/game/players/${PLAYER}/ipfs/moa/.try
|
2024-03-10 14:14:03 +01:00
|
|
|
|
|
|
|
$MY_PATH/../tools/mailjet.sh "${PLAYER}" ~/.zen/tmp/result "TW[+1] REFRESH WARNING"
|
2023-11-30 00:05:05 +01:00
|
|
|
|
2022-08-25 17:21:39 +02:00
|
|
|
continue
|
2022-10-09 23:07:30 +02:00
|
|
|
|
2022-11-16 04:42:27 +01:00
|
|
|
fi
|
2023-09-08 15:58:39 +02:00
|
|
|
|
|
|
|
#############################################################
|
2024-03-09 16:51:08 +01:00
|
|
|
## FOUND TW
|
|
|
|
#############################################################
|
|
|
|
## CHECK WHO IS ACTUAL OFFICIAL GATEWAY
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' ## MadeInZion Tiddler
|
|
|
|
|
|
|
|
[[ ! -s ~/.zen/tmp/${MOATS}/MadeInZion.json ]] && echo "${PLAYER} MadeInZion : BAD TW (☓‿‿☓) " && continue
|
|
|
|
|
|
|
|
player=$(cat ~/.zen/tmp/${MOATS}/MadeInZion.json | jq -r .[].player)
|
|
|
|
|
|
|
|
## EXTRACT "$:/config/NewTiddler/Tags"
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'TWsign.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '$:/config/NewTiddler/Tags' ## $:/config/NewTiddler/Tags Tiddler
|
|
|
|
signature=$(cat ~/.zen/tmp/${MOATS}/TWsign.json | jq -r .[].text)
|
|
|
|
echo "${player} SIGNATURE = $signature"
|
|
|
|
|
|
|
|
[[ ${player} != ${PLAYER} ]] \
|
|
|
|
&& echo "> BAD PLAYER=$player in TW" \
|
|
|
|
&& continue \
|
|
|
|
|| echo "${PLAYER} OFFICIAL TW - (⌐■_■) -"
|
|
|
|
|
|
|
|
## GET "Astroport" TIDDLER
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport' ## Astroport Tiddler
|
|
|
|
BIRTHDATE=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].birthdate)
|
|
|
|
ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport) ## ZenStation IPNS address
|
|
|
|
CURCHAIN=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].chain | rev | cut -f 1 -d '/' | rev) # Remove "/ipfs/" part
|
|
|
|
[[ ${CURCHAIN} == "" || ${CURCHAIN} == "null" ]] \
|
|
|
|
&& CURCHAIN="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" # AVOID EMPTY
|
|
|
|
|
2024-03-09 18:58:39 +01:00
|
|
|
SBIRTH=$(${MY_PATH}/../tools/MOATS2seconds.sh ${BIRTHDATE})
|
|
|
|
SNOW=$(${MY_PATH}/../tools/MOATS2seconds.sh ${MOATS})
|
|
|
|
DIFF_SECONDS=$(( SNOW - SBIRTH ))
|
|
|
|
days=$((DIFF_SECONDS / 60 / 60 / 24))
|
|
|
|
|
|
|
|
echo "ASTROPORT ZenStation : ${ASTROPORT}"
|
|
|
|
echo "TW was created $days days ago"
|
2024-03-09 16:51:08 +01:00
|
|
|
echo "CURCHAIN=${CURCHAIN}"
|
2024-03-09 18:58:39 +01:00
|
|
|
|
2024-03-09 16:51:08 +01:00
|
|
|
IPNSTAIL=$(echo ${ASTROPORT} | rev | cut -f 1 -d '/' | rev) # Remove "/ipns/" part
|
2024-03-09 18:58:39 +01:00
|
|
|
|
2024-03-09 16:51:08 +01:00
|
|
|
########### ASTROPORT is not IPFSNODEID => EJECT TW
|
|
|
|
if [[ ${IPNSTAIL} != ${IPFSNODEID} || ${IPNSTAIL} == "_ASTROPORT_" ]]; then
|
|
|
|
echo "> I AM ${IPFSNODEID} : PLAYER MOVED TO ${IPNSTAIL} : EJECTION "
|
|
|
|
echo "UNPLUG PLAYER"
|
|
|
|
${MY_PATH}/PLAYER.unplug.sh "${HOME}/.zen/game/players/${PLAYER}/ipfs/moa/index.html" "${PLAYER}" "ONE"
|
|
|
|
echo ">>>> ASTRONAUT ${PLAYER} TW CAPSULE EJECTION TERMINATED"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
######################################
|
|
|
|
#### UPLANET GEO COORD EXTRACTION
|
|
|
|
## GET "GPS" TIDDLER - 0.00 0.00 (if empty: null)
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'GPS.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'GPS' ## GPS Tiddler
|
|
|
|
LAT=$(cat ~/.zen/tmp/${MOATS}/GPS.json | jq -r .[].lat)
|
|
|
|
[[ $LAT == "null" || $LAT == "" ]] && LAT="0.00"
|
|
|
|
LON=$(cat ~/.zen/tmp/${MOATS}/GPS.json | jq -r .[].lon)
|
|
|
|
[[ $LON == "null" || $LON == "" ]] && LON="0.00"
|
|
|
|
|
2024-03-12 00:40:23 +01:00
|
|
|
SECTOR="_${LAT::-1}_${LON::-1}"
|
2024-03-09 16:51:08 +01:00
|
|
|
## UMAP TODATENS ################
|
|
|
|
|
2024-03-10 11:40:45 +01:00
|
|
|
ipfs key rm "temp" >/dev/null 2>&1
|
2024-03-09 16:51:08 +01:00
|
|
|
${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/todate.ipfskey "${TODATE}${UPLANETNAME}${LAT}" "${TODATE}${UPLANETNAME}${LON}"
|
|
|
|
UMAPNS=$(ipfs key import "temp" -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/todate.ipfskey)
|
|
|
|
|
|
|
|
cat ~/.zen/tmp/${MOATS}/GPS.json | jq '.[0] + {"umap": "/ipns/_UMAPNS_"}' \
|
|
|
|
> ~/.zen/tmp/${MOATS}/GPStw.json \
|
|
|
|
&& mv ~/.zen/tmp/${MOATS}/GPStw.json ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
sed -i "s~_UMAPNS_~${UMAPNS}~g" ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
|
|
|
|
#~ cat ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
echo "UMAP _${LAT}_${LON} UMAPNS=/ipns/${UMAPNS}"
|
|
|
|
|
|
|
|
## SECTOR TODATENS ################
|
2024-03-10 11:40:45 +01:00
|
|
|
ipfs key rm "temp" >/dev/null 2>&1
|
2024-03-09 16:51:08 +01:00
|
|
|
${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/sectodate.ipfskey "${TODATE}${UPLANETNAME}${SECTOR}" "${TODATE}${UPLANETNAME}${SECTOR}"
|
|
|
|
TODATESECTORNS=$(ipfs key import "temp" -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/sectodate.ipfskey)
|
|
|
|
|
|
|
|
cat ~/.zen/tmp/${MOATS}/GPS.json | jq '. + {"sectortw": "_SECTORTW_"}' \
|
|
|
|
> ~/.zen/tmp/${MOATS}/GPSsec.json \
|
|
|
|
&& mv ~/.zen/tmp/${MOATS}/GPSsec.json ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
sed -i "s~_SECTORTW_~/ipns/${TODATESECTORNS}/TW~g" ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
|
|
|
|
# (RE)MAKE "SECTORTW_NEWS" TIDDLER
|
|
|
|
cat ${MY_PATH}/../templates/data/SECTORTW_NEWS.json \
|
|
|
|
| sed -e "s~_SECTOR_~${SECTOR}~g" \
|
2024-03-10 00:50:06 +01:00
|
|
|
-e "s~_MOATS_~${MOATS}~g" \
|
2024-03-09 16:51:08 +01:00
|
|
|
-e "s~_SECTORTW_~/ipns/${TODATESECTORNS}/TW~g" \
|
|
|
|
> ~/.zen/tmp/${MOATS}/SECTORTW_NEWS.json
|
|
|
|
|
|
|
|
#~ cat ~/.zen/tmp/${MOATS}/GPS.json
|
|
|
|
echo "SECTOR $SECTOR SECTORTW=/ipns/${TODATESECTORNS}/TW"
|
|
|
|
|
2024-03-13 18:39:18 +01:00
|
|
|
|
|
|
|
PHONEBOOTH=${PLAYER/@/_}
|
|
|
|
PHONEBOOTH=${PHONEBOOTH/\./_}
|
|
|
|
|
2024-03-13 17:51:53 +01:00
|
|
|
# MAKE "ALLO" TIDDLER
|
|
|
|
cat ${MY_PATH}/../templates/data/ALLO.json \
|
|
|
|
| sed -e "s~_IPFSNINJA_~${VDONINJA}~g" \
|
|
|
|
-e "s~_MOATS_~${MOATS}~g" \
|
2024-03-13 18:39:18 +01:00
|
|
|
-e "s~_PHONEBOOTH_~${PHONEBOOTH}~g" \
|
2024-03-13 17:51:53 +01:00
|
|
|
> ~/.zen/tmp/${MOATS}/ALLO.json
|
|
|
|
|
2024-03-10 11:40:45 +01:00
|
|
|
ipfs key rm "temp" >/dev/null 2>&1
|
2024-03-09 16:51:08 +01:00
|
|
|
|
|
|
|
## STORE IN PLAYER CACHE
|
|
|
|
echo "_${LAT}_${LON}" > ~/.zen/game/players/${PLAYER}/.umap
|
|
|
|
cp ~/.zen/tmp/${MOATS}/GPS.json ~/.zen/game/players/${PLAYER}/
|
|
|
|
|
2023-09-08 15:58:39 +02:00
|
|
|
#############################################################
|
2024-03-10 16:01:16 +01:00
|
|
|
# Connect_PLAYER_To_Gchange.sh : Sync FRIENDS TW - TODO : REWRITE
|
2023-09-08 15:58:39 +02:00
|
|
|
##############################################################
|
|
|
|
echo "##################################################################"
|
|
|
|
|
2024-03-10 16:01:16 +01:00
|
|
|
[[ $(echo "$COINS >= 500" | bc -l) -eq 1 ]] \
|
|
|
|
&& echo "## Connect_PLAYER_To_Gchange.sh" \
|
|
|
|
&& ${MY_PATH}/../tools/Connect_PLAYER_To_Gchange.sh "${PLAYER}" \
|
|
|
|
|| echo "$COINS <= 1 G1 + 10 ẑen : bypass Gchange stars exchange (★★★★★)"
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# G1PalPay - 2 G1 mini -> Check for G1 TX incoming comments #
|
|
|
|
##############################################################
|
|
|
|
if [[ $(echo "$COINS >= 2" | bc -l) -eq 1 ]]; then
|
|
|
|
##############################################################
|
|
|
|
# G1PalPay.sh #
|
|
|
|
##############################################################
|
|
|
|
echo "## RUNNING G1PalPay Wallet Monitoring "
|
|
|
|
${MY_PATH}/G1PalPay.sh ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html "${PLAYER}"
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# VOEUX.create.sh #
|
|
|
|
##############################################################
|
|
|
|
${MY_PATH}/VOEUX.create.sh ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html "${PLAYER}" "${G1PUB}"
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# VOEUX.refresh.sh #
|
|
|
|
##############################################################
|
|
|
|
${MY_PATH}/VOEUX.refresh.sh "${PLAYER}" "${MOATS}" ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "> ZenCard not activated ($ZEN ZEN)"
|
|
|
|
fi
|
2023-11-14 19:16:00 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
#####################################################################
|
2024-03-09 19:41:10 +01:00
|
|
|
# (RE)MAKE "CESIUM" TIDDLER
|
2024-03-10 14:14:03 +01:00
|
|
|
echo "Create CESIUM Tiddler"
|
2024-03-09 19:41:10 +01:00
|
|
|
cat ${MY_PATH}/../templates/data/CESIUM.json \
|
|
|
|
| sed -e "s~_G1PUB_~${G1PUB}~g" \
|
2024-03-12 17:00:51 +01:00
|
|
|
-e "s~_MOATS_~${MOATS}~g" \
|
2024-03-09 19:41:10 +01:00
|
|
|
-e "s~_CESIUMIPFS_~${CESIUMIPFS}~g" \
|
|
|
|
-e "s~_PLAYER_~${PLAYER}~g" \
|
|
|
|
> ~/.zen/tmp/${MOATS}/CESIUM.json
|
|
|
|
|
2024-03-09 18:58:39 +01:00
|
|
|
#####################################################################
|
2024-03-15 16:47:28 +01:00
|
|
|
########## $:/moa picture ## lightbeams replacement ###############
|
2024-03-10 14:14:03 +01:00
|
|
|
## GET $:/moa Tiddlers ####################################### START
|
2024-03-10 00:50:06 +01:00
|
|
|
echo "GET $:/moa Tiddlers"
|
2024-03-09 18:58:39 +01:00
|
|
|
###################################################### [tag[$:/moa]]
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'FRIENDS.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[$:/moa]]' ## $:/moa EMAIL Tiddlers
|
|
|
|
#####################################################################
|
2024-03-09 19:41:10 +01:00
|
|
|
fplayers=($(cat ~/.zen/tmp/${MOATS}/FRIENDS.json | jq -rc .[].title))
|
2024-03-10 00:50:06 +01:00
|
|
|
echo "${fplayers[@]}"
|
2024-03-09 19:41:10 +01:00
|
|
|
INPUTPLAYERS=()
|
2024-03-09 18:58:39 +01:00
|
|
|
for fp in ${fplayers[@]}; do
|
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
[[ ! "${fp}" =~ ^[a-zA-Z0-9.%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]] && echo "BAD ${fp} FORMAT" && continue
|
|
|
|
[[ "${fp}" == "${PLAYER}" ]] && echo "IT'S ME - CONTINUE" && continue
|
2024-03-10 00:50:06 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
FPLAYER=$(cat ~/.zen/tmp/${MOATS}/FRIENDS.json | jq .[] | jq -r 'select(.title=="'${fp}'") | .player')
|
|
|
|
[[ $FPLAYER == 'null' || $FPLAYER == '' ]] && echo "FPLAYER null - CONTINUE" && continue
|
2024-03-10 00:50:06 +01:00
|
|
|
|
2024-03-09 19:41:10 +01:00
|
|
|
FTW=$(cat ~/.zen/tmp/${MOATS}/FRIENDS.json | jq .[] | jq -r 'select(.title=="'${fp}'") | .tw')
|
2024-03-10 14:14:03 +01:00
|
|
|
[[ ${FTW} == "/ipns/" && ${FTW} == "null" && ${FTW} == "" ]] && echo "WEIRD FTW ${FTW} - CONTINUE" && continue
|
2024-03-10 00:50:06 +01:00
|
|
|
|
2024-03-09 19:41:10 +01:00
|
|
|
FG1PUB=$(cat ~/.zen/tmp/${MOATS}/FRIENDS.json | jq .[] | jq -r 'select(.title=="'${fp}'") | .g1pub')
|
2024-03-10 14:14:03 +01:00
|
|
|
[[ $FG1PUB == 'null' || $FG1PUB == '' ]] && echo "FG1PUB null - CONTINUE" && continue
|
2024-03-09 18:58:39 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
IHASH=$(cat ~/.zen/tmp/${MOATS}/FRIENDS.json | jq .[] | jq -r 'select(.title=="'${fp}'") | .text' | sha256sum | cut -d ' ' -f 1)
|
|
|
|
|
|
|
|
echo ":: coucou :: $FPLAYER :: (ᵔ◡◡ᵔ) ::"
|
|
|
|
echo "TW: $FTW"
|
|
|
|
echo "G1: $FG1PUB"
|
2024-03-10 00:50:06 +01:00
|
|
|
echo "IHASH: $IHASH"
|
2024-03-09 20:06:01 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
## GET ORIGINH FROM LAST KNOWN TW STATE
|
|
|
|
mkdir -p ~/.zen/game/players/${PLAYER}/FRIENDS/${FPLAYER}
|
|
|
|
if [[ -s ~/.zen/game/players/${PLAYER}/FRIENDS/${FPLAYER}/index.html ]]; then
|
|
|
|
rm -f ~/.zen/tmp/${MOATS}/forigin.json
|
|
|
|
tiddlywiki --load ~/.zen/game/players/${PLAYER}/FRIENDS/${FPLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' "${FPLAYER}.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '${FPLAYER}' ## GET ORIGIN
|
|
|
|
|
|
|
|
ORIGINH=$(cat ~/.zen/tmp/${MOATS}/${FPLAYER}.json | jq -r '.[].text' | sha256sum | cut -d ' ' -f 1)
|
|
|
|
echo "ORIGINH: $ORIGINH"
|
2024-03-09 19:41:10 +01:00
|
|
|
fi
|
2024-03-09 18:58:39 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
( ## REFRESH LOCAL PLAYER CACHE with FRIEND ACTUAL TW (&)
|
|
|
|
ipfs --timeout 180s cat ${FTW} > ~/.zen/game/players/${PLAYER}/FRIENDS/${FPLAYER}/index.html
|
|
|
|
) &
|
2023-09-08 15:58:39 +02:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
## CHECK ALREADY IN ${FPLAYER^^} IHASH
|
|
|
|
rm -f ~/.zen/tmp/${MOATS}/finside.json
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--output ~/.zen/tmp/${MOATS} \
|
|
|
|
--render '.' 'finside.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '${FPLAYER^^}' ## ${FPLAYER^^} autoload Tiddlers
|
|
|
|
|
|
|
|
INSIDEH=$(cat ~/.zen/tmp/${MOATS}/finside.json | jq -rc '.[].ihash')
|
|
|
|
echo "INSIDEH: $INSIDEH"
|
|
|
|
|
|
|
|
## UPDATE IF IHASH CHANGED -> New drawing => Friend get informed
|
|
|
|
if [[ -z $INSIDEH || $INSIDEH != $IHASH || $ORIGINH != $INSIDEH ]]; then
|
|
|
|
cat ${MY_PATH}/../templates/data/_UPPERFPLAYER_.json \
|
|
|
|
| sed -e "s~_UPPERFPLAYER_~${FPLAYER^^}~g" \
|
|
|
|
-e "s~_FPLAYER_~${FPLAYER}~g" \
|
|
|
|
-e "s~_MOATS_~${MOATS}~g" \
|
|
|
|
-e "s~_IHASH_~${IHASH}~g" \
|
2024-03-14 16:45:53 +01:00
|
|
|
-e "s~EXTERNAL~${FPLAYER}~g" \
|
2024-03-10 14:14:03 +01:00
|
|
|
-e "s~_FRIENDTW_~${FTW}~g" \
|
|
|
|
-e "s~_PLAYER_~${PLAYER}~g" \
|
|
|
|
> ~/.zen/tmp/${MOATS}/${FPLAYER^^}.json
|
|
|
|
|
|
|
|
echo "Insert New ${FPLAYER^^}.json"
|
2024-03-13 14:14:34 +01:00
|
|
|
#~ cat ~/.zen/tmp/${MOATS}/${FPLAYER^^}.json | jq
|
2024-03-10 14:14:03 +01:00
|
|
|
|
2024-03-10 15:24:31 +01:00
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--import ${HOME}/.zen/tmp/${MOATS}/${FPLAYER^^}.json 'application/json' \
|
|
|
|
--output ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER} \
|
|
|
|
--render "$:/core/save/all" "newindex.html" "text/plain"
|
|
|
|
[[ -s ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ]] \
|
|
|
|
&& cp ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
&& rm ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html \
|
|
|
|
|| echo "ERROR - CANNOT CREATE TW NEWINDEX - ERROR"
|
|
|
|
|
|
|
|
if [[ $ORIGINH != $INSIDEH ]]; then
|
|
|
|
echo "ORIGINH Update"
|
|
|
|
rm -f ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html
|
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
--import ${HOME}/.zen/tmp/${MOATS}/${FPLAYER}.json 'application/json' \
|
|
|
|
--output ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER} \
|
|
|
|
--render "$:/core/save/all" "newindex.html" "text/plain"
|
|
|
|
[[ -s ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ]] \
|
|
|
|
&& cp ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
|
|
|
&& rm ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html \
|
|
|
|
|| echo "ERROR - CANNOT CREATE TW NEWINDEX - ERROR"
|
|
|
|
fi
|
2024-03-10 14:14:03 +01:00
|
|
|
fi
|
2024-03-09 19:41:10 +01:00
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
## FRIENDS TW FLUX TO IMPORT
|
|
|
|
#####################################################################
|
|
|
|
## GET $:/moa Tiddlers ####################################### END
|
|
|
|
#####################################################################
|
2024-03-09 19:41:10 +01:00
|
|
|
|
2023-09-08 15:58:39 +02:00
|
|
|
###################
|
2024-03-10 14:14:03 +01:00
|
|
|
# REFRESH PLAYER_feed KEY
|
2023-09-08 15:58:39 +02:00
|
|
|
##################################
|
|
|
|
echo "# TW : GW API + LightBeam Feed + Friends"
|
|
|
|
TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3)
|
|
|
|
|
|
|
|
FEEDNS=$(ipfs key list -l | grep -w "${PLAYER}_feed" | cut -d ' ' -f 1)
|
|
|
|
[[ ! ${FEEDNS} ]] && echo ">>>>> ERROR ${PLAYER}_feed IPNS KEY NOT FOUND - ERROR" && continue
|
|
|
|
|
|
|
|
# WRITE lightbeam params
|
2024-03-15 16:47:28 +01:00
|
|
|
#~ echo '[{"title":"$:/plugins/astroport/lightbeams/saver/ipns/lightbeam-name","text":"'${PLAYER}_feed'","tags":""}]' > ~/.zen/tmp/${MOATS}/lightbeam-name.json
|
|
|
|
#~ echo '[{"title":"$:/plugins/astroport/lightbeams/saver/ipns/lightbeam-key","text":"'${FEEDNS}'","tags":""}]' > ~/.zen/tmp/${MOATS}/lightbeam-key.json
|
2023-09-08 15:58:39 +02:00
|
|
|
|
2024-03-15 16:47:28 +01:00
|
|
|
#~ --import ~/.zen/tmp/${MOATS}/lightbeam-name.json "application/json" \
|
|
|
|
#~ --import ~/.zen/tmp/${MOATS}/lightbeam-key.json "application/json" \
|
2024-02-14 13:52:25 +01:00
|
|
|
###########################
|
2024-03-09 16:51:08 +01:00
|
|
|
# UPDATE GW & API
|
2024-02-14 13:52:25 +01:00
|
|
|
#~ echo '[{"title":"$:/ipfs/saver/api/http/localhost/5001","tags":"$:/ipfs/core $:/ipfs/saver/api","text":"'$(myPlayerApiGw)'"}]' > ~/.zen/tmp/${MOATS}/5001.json
|
|
|
|
#~ echo '[{"title":"$:/ipfs/saver/gateway/http/localhost","tags":"$:/ipfs/core $:/ipfs/saver/gateway","text":"'$myIPFS'"}]' > ~/.zen/tmp/${MOATS}/8080.json
|
|
|
|
|
|
|
|
## COPY DATA PRODUCED BY GCHANGE STAR EXTRACTION
|
|
|
|
FRIENDSFEEDS=$(cat ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/FRIENDSFEEDS 2>/dev/null)
|
|
|
|
echo "★★★★★ FRIENDS FEEDS : "${FRIENDSFEEDS}
|
|
|
|
ASTRONAUTES=$(cat ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/ASTRONAUTES 2>/dev/null)
|
|
|
|
echo "★★★★★ FRIENDS TW : "${ASTRONAUTES}
|
|
|
|
|
|
|
|
## Change TW FRIENDFEED ie PLAYER RSS IPNS (must fix TW plugin to work)
|
|
|
|
#~ echo '[{"title":"$:/plugins/astroport/lightbeams/state/subscriptions","text":"'${FRIENDSFEEDS}'","tags":""}]' > ~/.zen/tmp/${MOATS}/friends.json
|
|
|
|
#~ ## ADD --import "$HOME/.zen/tmp/${MOATS}/friends.json" "application/json" \ ## MANUAL TW RSS REGISTRATION
|
|
|
|
|
2024-03-10 14:14:03 +01:00
|
|
|
## PATCH : RESTORE PLAYER GPS.json (protect cache erased by WISH treatment)
|
2024-03-09 01:28:18 +01:00
|
|
|
cp -f ~/.zen/game/players/${PLAYER}/GPS.json ~/.zen/tmp/${MOATS}/
|
2024-03-08 13:24:15 +01:00
|
|
|
## WRITE TIDDLERS IN TW SECTORTW_NEWS.json
|
2024-02-14 13:52:25 +01:00
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
2024-03-06 14:34:52 +01:00
|
|
|
--import ~/.zen/tmp/${MOATS}/GPS.json "application/json" \
|
2024-03-13 17:51:53 +01:00
|
|
|
--import ~/.zen/tmp/${MOATS}/ALLO.json "application/json" \
|
2024-03-06 15:05:50 +01:00
|
|
|
--import ~/.zen/tmp/${MOATS}/CESIUM.json "application/json" \
|
2024-03-08 13:24:15 +01:00
|
|
|
--import ~/.zen/tmp/${MOATS}/SECTORTW_NEWS.json "application/json" \
|
2024-02-14 13:52:25 +01:00
|
|
|
--output ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER} --render "$:/core/save/all" "newindex.html" "text/plain"
|
|
|
|
|
|
|
|
## CHECK IT IS OK
|
|
|
|
[[ -s ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ]] \
|
|
|
|
&& cp ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
2024-03-09 18:58:39 +01:00
|
|
|
&& rm ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/newindex.html \
|
|
|
|
|| echo "ERROR - CANNOT CREATE TW NEWINDEX - ERROR"
|
2024-02-14 13:52:25 +01:00
|
|
|
###########################
|
2023-09-08 15:58:39 +02:00
|
|
|
|
|
|
|
####################
|
2024-03-09 18:58:39 +01:00
|
|
|
## TW NEWINDEX .... #####
|
2023-09-08 15:58:39 +02:00
|
|
|
##############################################################
|
2024-03-09 18:58:39 +01:00
|
|
|
echo "LOCAL BACKUP + MICROLEDGER TW"
|
|
|
|
cp ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
|
|
|
|
|
|
|
|
[[ -s ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain ]] \
|
|
|
|
&& ZCHAIN=$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain) \
|
|
|
|
&& echo "# CHAIN : ${CURCHAIN} -> ${ZCHAIN}" \
|
|
|
|
&& [[ ${CURCHAIN} != "" && ${ZCHAIN} != "" ]] \
|
|
|
|
&& sed -i "s~${CURCHAIN}~${ZCHAIN}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
|
2022-10-09 23:07:30 +02:00
|
|
|
|
2022-11-02 18:51:55 +01:00
|
|
|
##################################################
|
2024-03-09 18:58:39 +01:00
|
|
|
######## UPDATING ${PLAYER}/ipfs/moa/.chain
|
|
|
|
cp ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain \
|
|
|
|
~/.zen/game/players/${PLAYER}/ipfs/moa/.chain.$(cat ~/.zen/game/players/${PLAYER}/ipfs/moa/.moats)
|
2022-08-28 19:21:56 +02:00
|
|
|
|
2024-03-09 18:58:39 +01:00
|
|
|
##########################################
|
|
|
|
## IPFS ADD & PUBLISH
|
|
|
|
##########################################
|
2023-04-20 15:09:17 +02:00
|
|
|
TW=$(ipfs add -Hq ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html | tail -n 1)
|
2024-03-13 22:38:12 +01:00
|
|
|
ipfs --timeout 720s name publish --key=${PLAYER} /ipfs/${TW}
|
2022-08-28 19:21:56 +02:00
|
|
|
|
2024-03-09 18:58:39 +01:00
|
|
|
## LOCAL PLAYER CACHING
|
|
|
|
echo ${TW} > ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain
|
2023-04-25 18:17:46 +02:00
|
|
|
echo ${MOATS} > ~/.zen/game/players/${PLAYER}/ipfs/moa/.moats
|
2022-08-28 19:21:56 +02:00
|
|
|
|
2022-08-28 19:18:46 +02:00
|
|
|
echo "================================================"
|
2023-09-06 14:40:57 +02:00
|
|
|
echo " NEW TW ${PLAYER} : = ${myIPFS}/ipfs/${TW}"
|
2023-04-20 15:09:17 +02:00
|
|
|
echo " $myIPFSGW/ipns/${ASTRONAUTENS}"
|
2022-08-28 19:18:46 +02:00
|
|
|
echo "================================================"
|
2022-08-25 17:21:39 +02:00
|
|
|
|
2023-09-06 14:40:57 +02:00
|
|
|
echo "(☉_☉ ) (☉_☉ ) (☉_☉ ) RSS"
|
2024-01-08 05:04:06 +01:00
|
|
|
## CREATING 30 DAYS JSON RSS STREAM
|
2023-09-07 01:38:26 +02:00
|
|
|
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
2024-03-09 18:58:39 +01:00
|
|
|
--output ~/.zen/game/players/${PLAYER}/ipfs \
|
2024-03-15 17:07:53 +01:00
|
|
|
--render '.' "${PLAYER}.rss.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[days:created[-30]!is[system]!tag[G1Voeu]!externalTiddler[yes]!tag[load-external]]'
|
2024-02-10 12:36:57 +01:00
|
|
|
|
|
|
|
[[ ! -s ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json ]] \
|
2024-02-14 13:52:25 +01:00
|
|
|
&& echo "NO ${PLAYER} RSS - BAD "
|
|
|
|
|
|
|
|
echo "~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json"
|
2022-12-13 23:33:28 +01:00
|
|
|
|
2024-01-08 05:04:06 +01:00
|
|
|
## TODO CREATING 30 DAYS XML RSS STREAM
|
2024-01-08 04:20:59 +01:00
|
|
|
## https://talk.tiddlywiki.org/t/has-anyone-generated-an-rss-feed-from-tiddlywiki/966/26
|
2024-01-08 05:04:06 +01:00
|
|
|
# tiddlywiki.js --load my-wiki.html --render "[[$:/plugins/sq/feeds/templates/rss]]" "feed.xml" "text/plain" "$:/core/templates/wikified-tiddler"
|
|
|
|
### $:/plugins/sycom/atom-feed/atom.xml
|
2024-01-08 04:20:59 +01:00
|
|
|
#~ tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html \
|
2024-03-09 18:58:39 +01:00
|
|
|
#~ --output ~/.zen/game/players/${PLAYER}/ipfs --render '.' "${PLAYER}.rss.xml" 'text/plain' "$:/core/templates/wikified-tiddler" 'exportFilter' '[days:created[-30]!is[system]!tag[G1Voeu]]'
|
2024-01-08 04:20:59 +01:00
|
|
|
|
2024-03-08 14:29:58 +01:00
|
|
|
########################################
|
|
|
|
#### PLAYER ACCOUNT IS ACTIVE ? #########
|
|
|
|
if [[ $(cat ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json) == "[]" ]]; then
|
|
|
|
echo "RSS IS EMPTY -- COINS=$COINS / ZEN=$ZEN --"
|
|
|
|
|
|
|
|
if [[ $(echo "$COINS < 2.1" | bc -l) -eq 1 ]]; then
|
|
|
|
if [[ ${DIFF_SECONDS} -eq $(( 27 * 24 * 60 * 60 )) ]]; then
|
|
|
|
echo "<html><body><h1>WARNING.</h1> Your TW will be UNPLUGGED and stop being published..." > ~/.zen/tmp/alert
|
|
|
|
echo "<br><h3>TW : <a href=$(myIpfsGw)/ipfs/${CURCHAIN}> ${PLAYER}</a></h3> ADD MORE ZEN ($ZEN) </body></html>" >> ~/.zen/tmp/alert
|
|
|
|
|
|
|
|
${MY_PATH}/../tools/mailjet.sh "${PLAYER}" ~/.zen/tmp/alert "TW ALERT"
|
|
|
|
echo "<<<< PLAYER TW WARNING <<<< ${DIFF_SECONDS} > ${days} days"
|
|
|
|
fi
|
|
|
|
if [[ ${DIFF_SECONDS} -gt $(( 29 * 24 * 60 * 60 )) ]]; then
|
|
|
|
echo ">>>> PLAYER TW UNPLUG >>>>> ${days} days => BYE BYE ${PLAYER} ZEN=$ZEN"
|
|
|
|
${MY_PATH}/PLAYER.unplug.sh ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html ${PLAYER}
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-11-29 16:50:42 +01:00
|
|
|
#################################### UNPLUG ACCOUNT
|
2023-10-11 19:32:19 +02:00
|
|
|
|
2023-09-05 23:50:02 +02:00
|
|
|
IRSS=$(ipfs add -q ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json | tail -n 1) \
|
2024-03-15 13:04:12 +01:00
|
|
|
&& ipfs --timeout 180s name publish --key="${PLAYER}_feed" /ipfs/${IRSS}
|
2023-09-05 23:50:02 +02:00
|
|
|
|
2024-02-14 13:52:25 +01:00
|
|
|
######################### REPLACE TW with REDIRECT to latest IPFS or IPNS (reduce 12345 cache size)
|
2023-12-05 16:33:32 +01:00
|
|
|
[[ ! -z ${TW} ]] && TWLNK="/ipfs/${TW}" || TWLNK="/ipns/${ASTRONAUTENS}"
|
|
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url='${TWLNK}'\" />${PLAYER}" \
|
2023-10-09 22:15:29 +02:00
|
|
|
> ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html
|
|
|
|
|
2023-11-30 18:23:35 +01:00
|
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url='/ipfs/${IRSS}'\" />${PLAYER}" \
|
2023-10-09 22:15:29 +02:00
|
|
|
> ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}.feed.html
|
|
|
|
|
2024-02-14 13:52:25 +01:00
|
|
|
#################################################
|
|
|
|
################### COPY DATA TO UP LEVEL GRIDS
|
|
|
|
#################################################
|
2024-02-03 15:18:29 +01:00
|
|
|
if [[ ${LAT} && ${LON} ]]; then
|
|
|
|
## SECTOR BANK COORD
|
2024-03-12 00:40:23 +01:00
|
|
|
SECLAT="${LAT::-1}"
|
|
|
|
SECLON="${LON::-1}"
|
2024-02-03 15:18:29 +01:00
|
|
|
## REGION
|
|
|
|
REGLAT=$(echo ${LAT} | cut -d '.' -f 1)
|
|
|
|
REGLON=$(echo ${LON} | cut -d '.' -f 1)
|
|
|
|
|
2024-02-17 13:56:32 +01:00
|
|
|
echo "/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}"
|
|
|
|
## IPFSNODEID 12345 CACHE UPLANET/__/_*_*/_*.?_*.?/_*.??_*.??
|
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/RSS/
|
2024-02-03 15:18:29 +01:00
|
|
|
|
2024-02-17 13:56:32 +01:00
|
|
|
cp ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json \
|
|
|
|
~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/RSS/
|
2024-02-03 15:18:29 +01:00
|
|
|
|
2024-03-14 15:42:25 +01:00
|
|
|
${MY_PATH}/../tools/json_dir.all.sh \
|
|
|
|
~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/RSS/
|
|
|
|
|
2024-02-17 13:56:32 +01:00
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/TW/${PLAYER}
|
2024-03-14 15:42:25 +01:00
|
|
|
#~ cp ~/.zen/tmp/${IPFSNODEID}/TW/${PLAYER}/index.html ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/TW/${PLAYER}/
|
|
|
|
## IPFS PLAYER TW ##
|
|
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url='/ipfs/${TW}'\" />${TODATE}:${PLAYER}" \
|
|
|
|
> ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/TW/${PLAYER}/index.html
|
|
|
|
## IPNS UMAP _index.html ##
|
2024-03-14 17:43:31 +01:00
|
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url='/ipns/${UMAPNS}'\" />${TODATE}:_${LAT}_${LON}" \
|
2024-03-14 15:42:25 +01:00
|
|
|
> ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON}/_index.html
|
2024-02-17 13:56:32 +01:00
|
|
|
|
2024-03-14 17:43:31 +01:00
|
|
|
## IF PLAYER INACTIVE PAY 1 ZEN TO UMAPG1PUB
|
|
|
|
[[ $(cat ~/.zen/game/players/${PLAYER}/ipfs/${PLAYER}.rss.json) == "[]" ]] \
|
|
|
|
&& UMAPG1PUB=$(${MY_PATH}/../tools/keygen "${UPLANETNAME}${LAT}" "${UPLANETNAME}${LON}") \
|
|
|
|
&& YOUSER=$($MY_PATH/../tools/clyuseryomail.sh "${PLAYER}") \
|
|
|
|
&& ${MY_PATH}/../tools/PAY4SURE.sh "${HOME}/.zen/game/players/${PLAYER}/secret.dunikey" "0.1" "${UMAPG1PUB}" "UPLANET:TW:${YOUSER}:/ipfs/${TW}"
|
2024-02-03 15:18:29 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
ls -al ~/.zen/tmp/${IPFSNODEID}/UPLANET/__/_${REGLAT}_${REGLON}/_${SECLAT}_${SECLON}/_${LAT}_${LON} 2>/dev/null
|
2023-09-05 23:50:02 +02:00
|
|
|
echo "(☉_☉ ) (☉_☉ ) (☉_☉ )"
|
2022-12-13 23:33:28 +01:00
|
|
|
|
2023-10-11 14:24:09 +02:00
|
|
|
## MAINTAIN R/RW TW STATE
|
|
|
|
[[ ${ASTRONS} == "" ]] \
|
|
|
|
&& echo "${PLAYER} DISCONNECT" \
|
|
|
|
&& ipfs key rm ${PLAYER} \
|
|
|
|
&& ipfs key rm ${PLAYER}_feed \
|
|
|
|
&& ipfs key rm ${G1PUB}
|
|
|
|
|
2024-01-08 22:28:40 +01:00
|
|
|
## CLEANING CACHE
|
|
|
|
rm -Rf ~/.zen/tmp/${MOATS}
|
2024-02-14 13:52:25 +01:00
|
|
|
echo
|
2023-09-05 22:55:18 +02:00
|
|
|
|
2024-03-02 09:55:51 +01:00
|
|
|
end=`date +%s`
|
|
|
|
dur=`expr $end - $start`
|
|
|
|
echo "${PLAYER} refreshing took $dur seconds (${MOATS})"
|
|
|
|
|
2022-08-25 17:21:39 +02:00
|
|
|
done
|
2024-01-08 22:28:40 +01:00
|
|
|
echo "============================================ PLAYER.refresh DONE."
|
2022-09-12 14:58:08 +02:00
|
|
|
|
2022-08-25 17:21:39 +02:00
|
|
|
exit 0
|