Astroport.ONE/ASTROBOT/VOEUX.refresh.sh

87 lines
3.0 KiB
Bash
Raw Normal View History

2022-08-23 13:38:37 +02:00
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# 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
ME="${0##*/}"
################################################################################
# Inspect game wishes, refresh latest IPNS version
# Backup and chain
[[ $PLAYER == "" ]] && PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null)
2022-08-23 19:27:38 +02:00
############################################
2022-08-23 20:02:37 +02:00
echo "## WORLD VOEUX"
2022-08-23 19:27:38 +02:00
2022-08-25 17:21:39 +02:00
for v in $(cat ~/.zen/game/players/*/voeux/*/.title); do echo $v ;done
2022-08-23 13:38:37 +02:00
for voeu in $(ls ~/.zen/game/world/);
do
echo "VOEU : $voeu"
voeuns=$(ipfs key list -l | grep $voeu | cut -d ' ' -f1)
2022-08-23 13:38:37 +02:00
echo "http://127.0.0.1:8080/ipns/$voeuns"
echo
W=$(cat ~/.zen/game/world/$voeu/.pepper 2>/dev/null)
echo $W
2022-08-25 17:21:39 +02:00
rm -Rf ~/.zen/tmp/work
2022-08-23 13:38:37 +02:00
mkdir -p ~/.zen/tmp/work
echo "Getting latest online TW..."
2022-08-24 11:40:49 +02:00
ipfs --timeout 12s cat /ipns/$voeuns > ~/.zen/tmp/work/index.html
2022-08-23 13:38:37 +02:00
2022-08-25 17:21:39 +02:00
if [[ ! -s ~/.zen/tmp/work/index.html ]]; then
2022-08-23 19:34:47 +02:00
echo "UNAVAILABLE WISH! If you want to remove $W $voeu"
echo "ipfs key rm $voeu && rm -Rf ~/.zen/game/world/$voeu"
2022-09-23 12:09:30 +02:00
echo "============================================="
echo "ipfs name publish -t 72h /ipfs/$(cat ~/.zen/game/world/$voeu/.chain)"
2022-08-23 13:38:37 +02:00
continue
2022-08-24 11:40:49 +02:00
else
2022-08-25 19:38:58 +02:00
## Replace tube links with downloaded video
$MY_PATH/../tools/TUBE.copy.sh ~/.zen/tmp/work/index.html $voeu
2022-08-25 17:21:39 +02:00
2022-08-28 19:09:06 +02:00
echo "DIFFERENCE ?"
2022-08-28 19:18:46 +02:00
DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$voeu/index.html)
if [[ $DIFF ]]; then
echo "Backup & Upgrade TW local copy..."
cp -f ~/.zen/game/world/$voeu/index.html ~/.zen/game/world/$voeu/index.backup.html
cp ~/.zen/tmp/work/index.html ~/.zen/game/world/$voeu/index.html
else
echo "No change since last Refresh"
fi
2022-08-23 13:38:37 +02:00
fi
# RECORDING BLOCKCHAIN TIC
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
2022-08-29 17:33:07 +02:00
[[ $DIFF ]] && cp ~/.zen/game/world/$voeu/.chain ~/.zen/game/world/$voeu/.chain.$MOATS
2022-08-28 19:18:46 +02:00
2022-08-24 11:40:49 +02:00
IPUSH=$(ipfs add -Hq ~/.zen/game/world/$voeu/index.html | tail -n 1)
2022-09-23 12:09:30 +02:00
ipfs name publish -t 72h --key=${voeu} /ipfs/$IPUSH 2>/dev/null
2022-08-24 11:40:49 +02:00
2022-08-28 19:18:46 +02:00
[[ $DIFF ]] && echo $IPUSH > ~/.zen/game/world/$voeu/.chain
2022-08-23 13:38:37 +02:00
echo $MOATS > ~/.zen/game/world/$voeu/.moats
rm -Rf ~/.zen/tmp/work
2022-08-28 19:18:46 +02:00
# if [[ -d ~/.zen/game/players/$PLAYER/voeux/$voeu ]]; then
# echo "==========================="
# echo "Voeu$W : commande de suppression"
# echo "ipfs key rm $voeu
# rm -Rf ~/.zen/game/world/$voeu
# rm -Rf ~/.zen/game/players/$PLAYER/voeux/$voeu"
# echo "==========================="
# fi
2022-08-23 19:27:38 +02:00
2022-08-28 19:18:46 +02:00
echo "================================================"
2022-08-23 20:02:37 +02:00
echo "$W : http://127.0.0.1:8080/ipns/$voeuns"
2022-08-28 19:18:46 +02:00
echo "================================================"
2022-08-23 19:27:38 +02:00
done
exit 0