CORRECT ISSUE : #25

This commit is contained in:
qo-op 2021-06-14 16:35:38 +02:00
parent 58771c0b59
commit 1ef4032893
3 changed files with 77 additions and 32 deletions

View File

@ -55,6 +55,7 @@ echo "I am /ipns/$IPFSNODEID controling and refreshing my MEDIAKEY IPNS"
count=0
[[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/ ]] && exit 0
## TAKE CARE OF MY KEY
for id in $(ls ~/.zen/ipfs/.${IPFSNODEID}/KEY/); # Alternative search
do
count=$((count+1)) && echo "$count) "
@ -132,6 +133,22 @@ Apprenez à programmer le BLOB et ajoutez de nouveaux services au Datacenter Vir
done
## TAKE CARE OF PIN CREATED THROUGH autoPINfriends.sh
## Then refresh MEDIAKEY IPNS/IPFS RELATION
## CORRECT ISSUE : https://git.p2p.legal/axiom-team/astrXbian/issues/25
for ipnslink in $(ls ~/.zen/PIN/*/IPNSLINK);
ipnsid=$(cat $ipnslink)
ipfsid=$(echo $ipnslink | cut -d '/' -f 6)
mediakey=$(cat~/.zen/PIN/${ipfsid}/MEDIAKEY)
[[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue
## GET ACTUAL IPNS .chain VALUE
actual=$(ipfs cat /ipns/$ipnsid/.chain)
## PUBLISH IT
ipfs name publish -k ${mediakey} --quieter /ipfs/${actual}
echo "REFRESHED https://tube.copylaradio.com/ipns/$ipnsid TO /ipfs/$actual"
done
# ACTIVATION MONNAIES LIBRES EQUIBIBREES
# En relatif M/N :

View File

@ -197,10 +197,16 @@ echo "ASK AUTOPIN to $PINnode"
## ENCRYPT .ipfsid & .ipfs.filelink
$MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfs.filelink -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipfs.filelink.encrypt"
$MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfsid -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipfsid.encrypt"
#####################################################################
## natools can convert IPNS MEDIAKEY into .dunikey file (Pubsec (echo sec | base58 -d) = seed(32 char)+pubkey )
## GREAT natools can convert IPNS MEDIAKEY into .dunikey file
## $MY_PATH/tools/natools.py privkey -f ipfs-keystore -k ~/.ipfs/keystore/$KEYFILE -F pubsec -o /tmp/${INDEXPREFIX}${REFERENCE}.dunikey
## natools can convert... ;)
## NB : PubFromDunikey=$(cat ~/.zen/secret.dunikey | grep "sec" | cut -d ' ' -f2 | base58 -d | tail -c+33 | base58)
########################################################################
########################################################################
## CREATE .ipns.mediakey.encrypt FOR PINnode FOR IT TO REFRESH MEDIAKEY (used in ipns_TAG_refresh.sh & autoPINfriends.sh)
########################################################################
$MY_PATH/tools/natools.py encrypt -p $PINnode -i ~/.ipfs/keystore/$KEYFILE -o ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipns.mediakey.encrypt
## Init zen, views counters & visitor

View File

@ -13,7 +13,8 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
# This script is called to manage SWARM autoPIN
# Actual behaviour is to accept anything from
# SOURCE: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${g1node}/.ipfsid.encrypt (new_file_in_astroport.sh)
# SOURCE: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipfsid.encrypt (new_file_in_astroport.sh)
# MEDIAKEY: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipns.mediakey.encrypt
## AUTO PIN FRIENDS ACTIVATION
for astrofile in $(ls -dt ~/.zen/ipfs_swarm/.12D*/KEY/*/*/${G1PUB}/.ipfsid.encrypt | shuf);
@ -23,8 +24,10 @@ do
keytype=$(echo "$mediakey" | cut -d '_' -f 1 )
mediaid=$(echo "$mediakey" | cut -d '_' -f 2 )
source=$(echo "$astrofile" | cut -d '/' -f 9 )
echo "$mediakey PINNING ASKED BY $source"
g1source=$(echo "$astrofile" | cut -d '/' -f 9 )
ipfsnodesource=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1source)
echo "$mediakey PINNING ASKED BY $g1source"
## VERIFY CONTRACT... TODO
$MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofile" -o "/tmp/ipfslink.txt"
astrofile=$(cat /tmp/ipfslink.txt)
@ -34,8 +37,26 @@ do
then
echo "PIN : $astrofile"
ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/
echo "PUBLISHING MY PIN"
echo "RECORDING MY PIN ~/.zen/PIN/"
[[ -d ~/.zen/PIN/${astrofile} ]] && echo "0" > ~/.zen/PIN/${astrofile}/$G1PUB
echo "ADD ${mediakey} to my local keystore (SO I CAN UPDATE IPNS LINK LATER with ipns_TAG_refresh.sh)"
if [[ -f $HOME/.zen/ipfs_swarm/.${ipfsnodesource}/KEY/${mediakey}/${g1source}/${G1PUB}/.ipns.mediakey.encrypt ]]; then
$MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/ipfs_swarm/.${ipfsnodesource}/KEY/${mediakey}/${g1source}/${G1PUB}/.ipns.mediakey.encrypt" -o "/tmp/ipns.mediakey"
if [[ -f /tmp/ipns.mediakey ]]; then
## FIND ipns key file name
KEYFILE=$(ipfs key list | grep "${mediakey}")
if [[ ! $KEYFILE ]]; then
KEY=$(ipfs key gen "${mediakey}")
KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1)
fi
## REPLACE with GOOD MEDIAKEY FILE into ~/.ipfs/keystore/
rm -f ~/.ipfs/keystore/$KEYFILE
mv /tmp/ipns.mediakey ~/.ipfs/keystore/$KEYFILE
echo "${mediakey}" > ~/.zen/PIN/${astrofile}/MEDIAKEY
echo "$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)" > ~/.zen/PIN/${astrofile}/IPNSLINK
fi
fi
else
echo "ALREADY PINNED"
continue
@ -50,3 +71,4 @@ do
[[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break
done
exit 0