diff --git a/zen/new_file_in_astroport.sh b/zen/new_file_in_astroport.sh index bbeb6df..be3fcd5 100755 --- a/zen/new_file_in_astroport.sh +++ b/zen/new_file_in_astroport.sh @@ -275,7 +275,7 @@ then ## CREATE astroport call to Astroport/Wordpress stations if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE} ]]; then mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE} - echo "0" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE}/do + echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE}/do fi fi diff --git a/zen/wordpress_channel.sh b/zen/wordpress_channel.sh index c27552f..c9867a5 100755 --- a/zen/wordpress_channel.sh +++ b/zen/wordpress_channel.sh @@ -4,7 +4,7 @@ # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## -[[ ! $(which wp) ]] && exit 0 # MUST RUN WORDPRESS and wp-cli +# Take care about Astroport/Wordpress "do/done" publication process ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized @@ -16,30 +16,47 @@ IPFSNODEID=$(ipfs id -f='\n') [[ -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/*/); +for wpcall in $(ls -d ~/.zen/ipfs_swarm/.12D*/astroport/wordpress/*); do - echo "$wpcall" - done=$(cat $wpcall/do) && [[ "$done" != "0" ]] && echo "DONE" && continue # Already DONE + 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 ) - 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 - wp post create --post_author='$xzuid' --post_content="

$title

" --post_title="$title" --post_excerpt="Youtube" --post_category="1,7" --tags_input="youtube" --porcelain + if [[ "$ipfsnodeid" != "$IPFSNODEID" ]]; then + [[ ! $(which wp) ]] && continue # MUST RUN WORDPRESS and wp-cli - # REPLY do=1 - response="$(echo "$wpcall" | sed 's/ipfs_swarm/ipfs/g')" - echo "1" > $response + 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