2023-10-14 17:11:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.2
|
|
|
|
# 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
|
|
|
|
. "$MY_PATH/../tools/my.sh"
|
|
|
|
################################################################################
|
|
|
|
## MAP REFRESH
|
|
|
|
# LOAD EXTRA DATA TO CACHE ~/.zen/tmp/${IPFSNODEID}/
|
|
|
|
# PUBLISH STATION BALISE
|
|
|
|
############################################
|
2023-10-16 20:00:10 +02:00
|
|
|
echo "## RUNNING NODE.refresh"
|
2023-10-14 17:11:14 +02:00
|
|
|
[[ ${IPFSNODEID} == "" ]] && echo "IPFSNODEID is empty - EXIT -" && exit 1
|
|
|
|
|
2023-12-07 15:09:54 +01:00
|
|
|
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
|
|
|
|
2023-10-14 17:11:14 +02:00
|
|
|
#################################################################
|
|
|
|
## IPFSNODEID ASTRONAUTES SIGNALING ## 12345 port
|
|
|
|
############################
|
|
|
|
|
|
|
|
# UDATE STATION BALISE
|
|
|
|
if [[ -d ~/.zen/tmp/${IPFSNODEID} ]]; then
|
|
|
|
|
|
|
|
# ONLY FRESH DATA HERE
|
|
|
|
BSIZE=$(du -b ~/.zen/tmp/${IPFSNODEID} | tail -n 1 | cut -f 1)
|
|
|
|
## Getting actual online version
|
|
|
|
#~ ipfs get -o ~/.zen/tmp/${IPFSNODEID} /ipns/${IPFSNODEID}/
|
|
|
|
|
|
|
|
## COPY STATION yt-dlp.list
|
|
|
|
cp $HOME/.zen/.yt-dlp.list ~/.zen/tmp/${IPFSNODEID}/yt-dlp.list
|
|
|
|
|
|
|
|
## COPY COINS VALUE OF THE DAY
|
2023-12-07 15:09:54 +01:00
|
|
|
rm -Rf ~/.zen/tmp/${IPFSNODEID}/COINS/
|
2023-10-14 17:11:14 +02:00
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/COINS/
|
|
|
|
cp -f ~/.zen/tmp/coucou/*.COINS ~/.zen/tmp/${IPFSNODEID}/COINS/
|
|
|
|
|
2023-12-07 15:09:54 +01:00
|
|
|
## COPY 20h12.log
|
2024-02-15 19:26:07 +01:00
|
|
|
rm -f ~/.zen/tmp/${IPFSNODEID}/20h12.log ## TODO REMOVE
|
|
|
|
cp -f /tmp/20h12.log ~/.zen/tmp/${IPFSNODEID}/20h12.txt
|
2023-12-07 15:09:54 +01:00
|
|
|
|
2023-10-14 17:11:14 +02:00
|
|
|
## COPY FRIENDS
|
|
|
|
PLAYERONE=($(ls -t ~/.zen/game/players/ | grep "@" 2>/dev/null))
|
|
|
|
echo "FOUND : ${PLAYERONE[@]}"
|
|
|
|
## RUNING FOR ALL LOCAL PLAYERS
|
|
|
|
for PLAYER in ${PLAYERONE[@]}; do
|
2023-10-20 01:53:09 +02:00
|
|
|
echo "${PLAYER} GCHANGE FRIENDS"
|
|
|
|
[[ -d ~/.zen/tmp/${IPFSNODEID}/${PLAYER} && ${PLAYER} != "" ]] && rm -Rf ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/ ## TODO REMOVE (PROTOCOL UPGRADE)
|
|
|
|
mkdir -p ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/FRIENDS/
|
2024-01-10 23:49:26 +01:00
|
|
|
cp -Rf ~/.zen/game/players/${PLAYER}/FRIENDS/* ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/FRIENDS/ 2>/dev/null
|
2023-10-14 17:11:14 +02:00
|
|
|
done
|
|
|
|
|
2024-02-10 20:58:40 +01:00
|
|
|
## INFORM GPS LOCATION
|
2024-02-15 19:22:03 +01:00
|
|
|
[[ -s ~/.zen/game/players/.current/GPS.json ]] \
|
|
|
|
&& cp ~/.zen/game/players/.current/GPS.json ~/.zen/tmp/${IPFSNODEID}/ \
|
2024-03-19 23:37:47 +01:00
|
|
|
&& LAT=$(cat ~/.zen/tmp/${IPFSNODEID}/GPS.json | jq -r .[].lat) \
|
|
|
|
&& LON=$(cat ~/.zen/tmp/${IPFSNODEID}/GPS.json | jq -r .[].lon) \
|
2024-02-15 19:22:03 +01:00
|
|
|
&& echo "LAT=${LAT}; LON=${LON}" > ~/.zen/GPS
|
2024-02-10 20:58:40 +01:00
|
|
|
|
2023-12-07 15:09:54 +01:00
|
|
|
## REFRESH TIMESTAMPING
|
|
|
|
echo "${MOATS}" > ~/.zen/tmp/${IPFSNODEID}/_MySwarm.moats
|
|
|
|
echo "$(date -u)" > ~/.zen/tmp/${IPFSNODEID}/_MySwarm.staom
|
|
|
|
|
2023-10-14 17:11:14 +02:00
|
|
|
echo "############################################ MY MAP "
|
|
|
|
ls ~/.zen/tmp/${IPFSNODEID}/
|
|
|
|
echo "############################################"
|
|
|
|
NSIZE=$(du -b ~/.zen/tmp/${IPFSNODEID} | tail -n 1 | cut -f 1)
|
|
|
|
ROUTING=$(ipfs add -rwHq ~/.zen/tmp/${IPFSNODEID}/* | tail -n 1 )
|
|
|
|
ipfs name publish /ipfs/${ROUTING}
|
|
|
|
echo ">> $NSIZE Bytes STATION BALISE > ${myIPFS}/ipns/${IPFSNODEID}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2024-02-15 18:07:23 +01:00
|
|
|
## CLEANING SWARM 3 DAYS OLD
|
|
|
|
find ~/.zen/tmp/swarm/ -mtime +3 -type d -exec rm -Rf '{}' \;
|
2024-01-11 00:18:46 +01:00
|
|
|
|
2023-10-14 17:11:14 +02:00
|
|
|
exit 0
|