#!/bin/bash ######################################################################## # Author: # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## # Take care about Astroport/Wordpress "do/done" publication process ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1 IPFSNODEID=$(ipfs id -f='\n') [[ -f ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid ]] && AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid); [[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title) ## CREATION DE LA ZONE DE DIALOGUE IPFS SWARM for wpcall in $(ls -d ~/.zen/ipfs_swarm/.12D*/astroport/wordpress/*); do ls $wpcall [[ -f $wpcall/do ]] && istodo=$(cat $wpcall/do) [[ -f $wpcall/done ]] && isdone=$(cat $wpcall/done) [[ ! $isdone && ! $istodo ]] && continue ipfnodesource=$(echo "$wpcall" | cut -d '/' -f 6 | cut -d '.' -f 2 ) g1pubsource=$($MY_PATH/tools/ipfs_to_g1.py $ipfnodesource) mediakey=$(echo "$wpcall" | cut -d '/' -f 9 ) if [[ "$ipfsnodeid" != "$IPFSNODEID" ]]; then [[ ! $(which wp) ]] && continue # MUST RUN WORDPRESS and wp-cli if [[ $istodo && ! $isdone ]]; then ## I am the destination of that "todo / not done" wpcall echo "$ipfnodesource wants to publish $mediakey" ## GET ipns link + title + xzuid ipnsid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.ipns.link) title=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.title) xzuid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/_xbian.zuid) mynodename=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/G1SSB/_nodename) genres="$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/ajouter_video.txt | cut -d ';' -f 6 | sed s/|/,/g)" # 1=DIY, Habiter=2, Guerir=3, Divertir=4, Déplacer=5, Energie=6, Cultiver=7 cd /var/www/wordpress/ isWPuser=$(wp user list | grep "$xzuid") wp post create --post_author="$xzuid" --post_content="

$title

" --post_title="$title" --post_excerpt="$g1pubsource" --tags_input="$genres" --porcelain # REPLY done=1 responsedir="$(echo "$wpcall" | sed 's/ipfs_swarm/ipfs/g')" mkdir -p $responsedir echo "1" > $responsedir/done fi ## I am the destination of that "done / not todo" wpcall [[ $isdone && ! $istodo ]] && echo rm -Rf ~/.zen/ipfs/.$ipfnodesource/astroport/wordpress/$mediakey/done else ## I am the source of that "done" wpcall remove "do" [[ $isdone ]] && echo rm -f ~/.zen/ipfs/.$ipfnodesource/astroport/wordpress/$mediakey/do fi done # REFRESH IPNS SELF PUBLISH ######################################################################## echo "******************************************************************" echo "REFRESH IPNS SELF PUBLISH" ~/.zen/astrXbian/zen/ipns_self_publish.sh ########################################################################