diff --git a/zen/ipns_MOA_publish.sh b/zen/ipns_MOA_publish.sh new file mode 100755 index 0000000..efabde8 --- /dev/null +++ b/zen/ipns_MOA_publish.sh @@ -0,0 +1,33 @@ +#!/bin/bash +######################################################################## +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +ME="${0##*/}" +countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) +[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 +######################################################################## +MOATS=$(date -u +"%Y%m%d%H%M%S%4N") + +PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) +PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) +G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) +IPFSNODEID=$(cat ~/.zen/game/players/.current/.ipfsnodeid 2>/dev/null) || ( echo "noipfsnodeid" && exit 1 ) +PLAYERNS=$(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 ) +MOANS=$(cat ~/.zen/game/players/.current/.moans 2>/dev/null) || ( echo "noplayermoans" && exit 1 ) +QOOPNS=$(cat ~/.zen/game/players/.current/.qoopns 2>/dev/null) || ( echo "noplayerqoopns" && exit 1 ) + + +ipfs --timeout=3s ls /ipns/$MOANS +if [ $? != 0 ]; then + #echo "## PUBLISHING moa_${PLAYER} /ipns/$MOANS" + ls ~/.zen/game/players/$PLAYER/moa/* + IPUSH=$(ipfs add -rwHq ~/.zen/game/players/$PLAYER/moa/* | tail -n 1) + echo $IPUSH > ~/.zen/game/players/$PLAYER/moa/$PLAYER.moa.chain + echo $MOATS > ~/.zen/game/players/$PLAYER/moa/$PLAYER.moa.ts + echo 1 > ~/.zen/game/players/$PLAYER/moa/$PLAYER.moa.n + ipfs name publish --key=moa_${PLAYER} /ipfs/$IPUSH 2>/dev/null +else +## MISE A JOUR CACHE + ipfs get -o ~/.zen/game/players/$PLAYER/moa/ /ipns/$MOANS +fi +echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8080/ipns/$QOOPNS" diff --git a/zen/ipns_PLAYER_publish.sh b/zen/ipns_PLAYER_publish.sh new file mode 100755 index 0000000..2a9f7b4 --- /dev/null +++ b/zen/ipns_PLAYER_publish.sh @@ -0,0 +1,31 @@ +#!/bin/bash +######################################################################## +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +ME="${0##*/}" +countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) +[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 +######################################################################## +MOATS=$(date -u +"%Y%m%d%H%M%S%4N") + +PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) +PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) +G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) +IPFSNODEID=$(cat ~/.zen/game/players/.current/.ipfsnodeid 2>/dev/null) || ( echo "noipfsnodeid" && exit 1 ) +PLAYERNS=$(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 ) +MOANS=$(cat ~/.zen/game/players/.current/.moans 2>/dev/null) || ( echo "noplayermoans" && exit 1 ) +QOOPNS=$(cat ~/.zen/game/players/.current/.qoopns 2>/dev/null) || ( echo "noplayerqoopns" && exit 1 ) + + +ipfs --timeout=3s ls /ipns/$PLAYERNS +if [ $? != 0 ]; then + IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/index.html | tail -n 1) + echo $IPUSH > ~/.zen/game/players/$PLAYER/$PLAYER.chain + echo $MOATS > ~/.zen/game/players/$PLAYER/$PLAYER.ts + echo 1 > ~/.zen/game/players/$PLAYER/$PLAYER.n + ipfs name publish --key=${PLAYER} /ipfs/$IPUSH 2>/dev/null +else +## MISE A JOUR CACHE (TODO : ADD CHAIN TO BE ABLE TO REVERSE TIME) - "Activate archive.org" + ipfs get -o ~/.zen/game/players/$PLAYER/index.html /ipns/$PLAYERNS +fi +echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8080/ipns/$PLAYERNS" diff --git a/zen/ipns_TW5_publish.sh b/zen/ipns_TW5_publish.sh new file mode 100755 index 0000000..f94ef31 --- /dev/null +++ b/zen/ipns_TW5_publish.sh @@ -0,0 +1,32 @@ +#!/bin/bash +######################################################################## +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +ME="${0##*/}" +countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) +[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 +######################################################################## +MOATS=$(date -u +"%Y%m%d%H%M%S%4N") + +PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) +PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) +G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) +IPFSNODEID=$(cat ~/.zen/game/players/.current/.ipfsnodeid 2>/dev/null) || ( echo "noipfsnodeid" && exit 1 ) +PLAYERNS=$(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 ) +MOANS=$(cat ~/.zen/game/players/.current/.moans 2>/dev/null) || ( echo "noplayermoans" && exit 1 ) +QOOPNS=$(cat ~/.zen/game/players/.current/.qoopns 2>/dev/null) || ( echo "noplayerqoopns" && exit 1 ) + + +ipfs --timeout=3s ls /ipns/$QOOPNS +if [ $? != 0 ]; then + IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/.$IPFSNODEID/index.html | tail -n 1) + echo $IPUSH > ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/$PLAYER.qo-op.chain + echo $MOATS > ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/$PLAYER.qo-op.ts + echo 1 > ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/$PLAYER.qo-op.n + ipfs name publish --key=qo-op_${PLAYER} /ipfs/$IPUSH 2>/dev/null +else +## MISE A JOUR CACHE + ipfs get -o ~/.zen/game/players/$PLAYER/ipfs/.$IPFSNODEID/index.html /ipns/$QOOPNS + +fi +echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8080/ipns/$QOOPNS"