#!/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 ######################################################################## 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 ) ######################################################################## ## TESSERACT DOUBLE ACTION ######################################################################## echo "Adding ~/.zen/ipfs/ to IPFS" # MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1) # OLDCHAIN=$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain) # echo "OLD: $OLDCHAIN != NEW:$MIPFS ?" # if [[ "$OLDCHAIN" != "$MIPFS" ]] # MODIFY CHAIN only if something was changed # then echo "$(date -u +%s%N | cut -b1-13)" > ~/.zen/ipfs/.${IPFSNODEID}/.timestamp echo $MIPFS > ~/.zen/ipfs/.${IPFSNODEID}/.chain MIPFS=$(ipfs add -rHq $(readlink ~/.zen/ipfs) | tail -n 1) NODEIPNS=$(ipfs --timeout=180s name publish --quieter /ipfs/$MIPFS) echo "$NODEIPNS:TIME:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.timestamp):CHAIN:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain)" # fi echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8080/ipns/$IPFSNODEID" ######################################################################## ## READ BLOCK CHAIN ## # TIME=$(ipfs cat /ipns/${IPFSNODEID}/.${IPFSNODEID}/.timestamp) # BLOCK=$(ipfs cat /ipns/${IPFSNODEID}/.${IPFSNODEID}/.chain) # while [[ $BLOCK ]] # do # TIME=$(ipfs cat /ipfs/$BLOCK/.${IPFSNODEID}/.timestamp) # BLOCK=$(ipfs cat /ipfs/$BLOCK/.${IPFSNODEID}/.chain) # echo $TIME:$BLOCK # done ########################################################################