Browse Source

wordpress stargate

pull/32/head
qo-op 8 months ago
parent
commit
a91f79d7fe
  1. 69
      zen/create_subkeys_for_my_friends.sh
  2. 51
      zen/wordpress_channel.sh

69
zen/create_subkeys_for_my_friends.sh

@ -0,0 +1,69 @@
#!/bin/bash
########################################################################
# Author:
# 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##*/}"
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='<id>\n')
########################################################################
# SCAN AND MANAGE KEYS BETWEEN MOVIES & FRIENDS
## Control IPNS key $MEDIAKEY.4FRIENDS + create, catch & spread MEDIAKEY to FRIENDS
########################################################################
echo "DEV MODE" && exit 0
read
########################################################################
for FRIEND in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); do
[[ "$FRIEND" == "index.html" ]] && continue
echo "$FRIEND ?"
for MEDIAKEY in $(ls ~/.zen/ipfs/.$IPFSNODEID/KEY); do
echo "MEDIAKEY=$MEDIAKEY"
## Do I have this IPNS key?
ISKEY=$(ipfs key list -l | grep "$MEDIAKEY.4FRIENDS" | cut -d ' ' -f 2)
echo "ISKEY=$ISKEY"
## Is there any key already from swarm for that MEDIAKEY
PREVKEY=$(ls ~/.zen/ipfs_swarm/.12D*/KEY/$MEDIAKEY/*/$G1PUB/ 2>/dev/null)
echo "PREVKEY=$ISKEY"
## A key is found in my swam
if [[ $PREVKEY ]]; then
echo "I found a MEDIAKEY for $MEDIAKEY : $PREVKEY"
## Do I have it localy available?
if [[ ! $ISKEY ]]; then
echo "don't have it local..."
# decrypting PREVKEY to my ipfs keystore
$MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "~/.zen/ipfs_swarm/.12D*/KEY/$MEDIAKEY/*/$G1PUB/$PREVKEY" -o "$HOME/.ipfs/keystore/${PREVKEY%.*}"
## Checking if ipfs deamon have it
ISKEY=$(ipfs key list -l | grep "$MEDIAKEY.4FRIENDS" | cut -d ' ' -f 2)
echo ".ipfs/keystore/${PREVKEY%.*} added..."
[[ ! $ISKEY ]] && echo "Restarting ipfs..." && sudo service ipfs restart
fi
## Station is Not spreading swarm key... just getting it back.
continue
fi
echo "~/.zen/ipfs/.$IPFSNODEID/KEY/$MEDIAKEY/$G1PUB/$FRIEND/"
## No swarm or local MEDIAKEY, we are the first $MEDIAKEY creator in the swarm
[[ ! $ISKEY ]] && echo "Creating $MEDIAKEY.4FRIENDS IPNS key" && IPNSKEY=$(ipfs key gen "$MEDIAKEY.4FRIENDS") && IPNSKEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1)
## Sending encrypted MEDIAKEY to my swarm (sign if you want more security, but code ipfs signature verification is enough and better)
if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/KEY/$MEDIAKEY/$G1PUB/$FRIEND/ ]]; then
echo "MEDIAKEY $MEDIAKEY is missing to my $FRIEND"
mkdir -p "~/.zen/ipfs/.$IPFSNODEID/KEY/$MEDIAKEY/$G1PUB/$FRIEND/"
$MY_PATH/tools/natools.py encrypt -p $FRIEND -i "~/.ipfs/keystore/$IPNSKEYFILE" -o "~/.zen/ipfs/.$IPFSNODEID/KEY/$MEDIAKEY/$G1PUB/$FRIEND/$IPNSKEYFILE.encrypt"
echo "Spreading ~/.zen/ipfs/.$IPFSNODEID/KEY/$MEDIAKEY/$G1PUB/$FRIEND/$IPNSKEYFILE.encrypt"
fi
## TODO : CHECK FOR DISAPEARED FRIENDS.
read
done
read
done

51
zen/wordpress_channel.sh

@ -0,0 +1,51 @@
#!/bin/bash
########################################################################
# Author:
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
[[ ! $(which wp) ]] && exit 0 # MUST RUN WORDPRESS and wp-cli
########################################################################
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='<id>\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
echo "$wpcall"
done=$(cat $wpcall/do) && [[ "$done" != "0" ]] && echo "DONE" && continue # Already DONE
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="<p><a href=\"https://$mynodename/ipns/$ipnsid\" target=\"_blank\" rel=\"noreferrer noopener\">$title</a></p>" --post_title="$title" --post_excerpt="Youtube" --post_category="1,7" --tags_input="youtube" --porcelain
# REPLY do=1
response="$(echo "$wpcall" | sed 's/ipfs_swarm/ipfs/g')"
echo "1" > $response
done
# REFRESH IPNS SELF PUBLISH
########################################################################
echo "******************************************************************"
echo "REFRESH IPNS SELF PUBLISH"
~/.zen/astrXbian/zen/ipns_self_publish.sh
########################################################################
Loading…
Cancel
Save