Astroport.ONE/tools/PLAYER.refresh.sh

52 lines
1.8 KiB
Bash
Raw Normal View History

2022-08-25 17:21:39 +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)
############################################
echo "## PLAYER TW"
for PLAYER in $(ls ~/.zen/game/players/); do
echo "PLAYER : $PLAYER"
## REFRESH ASTRONAUTE TW
ASTRONAUTENS=$(ipfs key list -l | grep $PLAYER | cut -d ' ' -f1)
[[ ! $ASTRONAUTENS ]] && echo "Missing $PLAYER IPNS KEY -- EXIT --" && exit 1
rm -Rf ~/.zen/tmp/astro
mkdir -p ~/.zen/tmp/astro
ipfs --timeout 12s cat /ipns/$ASTRONAUTENS > ~/.zen/tmp/astro/index.html
2022-08-25 19:38:58 +02:00
2022-08-25 17:21:39 +02:00
if [ ! -s ~/.zen/tmp/astro/index.html ]; then
echo "ERROR IPNS TIMEOUT. Unchanged local backup..."
continue
else
2022-08-25 19:38:58 +02:00
## Replace tube links with downloaded video
$MY_PATH/TUBE.copy.sh ~/.zen/tmp/astro/index.html $PLAYER
2022-08-28 19:09:06 +02:00
echo "DIFFERENCE ?"
diff ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-08-25 17:21:39 +02:00
echo "Upgrade TW local copy..."
cp ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
fi
TW=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)
ipfs name publish --key=$PLAYER /ipfs/$TW
echo "$PLAYER : http://127.0.0.1:8080/ipns/$ASTRONAUTENS"
done
exit 0