CORRECT ISSUE : #25
This commit is contained in:
parent
58771c0b59
commit
1ef4032893
|
@ -55,13 +55,14 @@ 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) "
|
||||
IPNSLINK=$(ipfs key list -l | grep ${id} | cut -d ' ' -f 1)
|
||||
FILE_NAME=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/.ipfs.filename)
|
||||
TITLE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/.title)
|
||||
|
||||
|
||||
source=$(echo $id | cut -d '_' -f 1)
|
||||
|
||||
ANNONCE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/.gchange.ad)
|
||||
|
@ -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 :
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,40 +13,62 @@ 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);
|
||||
do
|
||||
# decrypt $astrofile
|
||||
mediakey=$(echo "$astrofile" | cut -d '/' -f 8 )
|
||||
keytype=$(echo "$mediakey" | cut -d '_' -f 1 )
|
||||
mediaid=$(echo "$mediakey" | cut -d '_' -f 2 )
|
||||
# decrypt $astrofile
|
||||
mediakey=$(echo "$astrofile" | cut -d '/' -f 8 )
|
||||
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"
|
||||
## 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)
|
||||
# PINNING NEW FILE
|
||||
echo "SHOULD I PIN ~/.zen/PIN/${astrofile} ??"
|
||||
if [[ ! -d ~/.zen/PIN/${astrofile} ]];
|
||||
then
|
||||
echo "PIN : $astrofile"
|
||||
ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/
|
||||
echo "PUBLISHING MY PIN"
|
||||
[[ -d ~/.zen/PIN/${astrofile} ]] && echo "0" > ~/.zen/PIN/${astrofile}/$G1PUB
|
||||
else
|
||||
echo "ALREADY PINNED"
|
||||
continue
|
||||
fi
|
||||
|
||||
## TOOD : DECIDE TO ACTIVATE THIS BEHAVIOUR OR NOT ?
|
||||
## Copy FASTRXBIAN index (makes movies available for ALL)
|
||||
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN ]] && echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
|
||||
[[ "$keytype" == "TMDB" ]] && cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/FASTRXBIAN | grep ";$mediaid;" | tail -n 1 >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
|
||||
g1source=$(echo "$astrofile" | cut -d '/' -f 9 )
|
||||
ipfsnodesource=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1source)
|
||||
|
||||
# EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time)
|
||||
[[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break
|
||||
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)
|
||||
# PINNING NEW FILE
|
||||
echo "SHOULD I PIN ~/.zen/PIN/${astrofile} ??"
|
||||
if [[ ! -d ~/.zen/PIN/${astrofile} ]];
|
||||
then
|
||||
echo "PIN : $astrofile"
|
||||
ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/
|
||||
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
|
||||
fi
|
||||
|
||||
## TOOD : DECIDE TO ACTIVATE THIS BEHAVIOUR OR NOT ?
|
||||
## Copy FASTRXBIAN index (makes movies available for ALL)
|
||||
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN ]] && echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
|
||||
[[ "$keytype" == "TMDB" ]] && cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/FASTRXBIAN | grep ";$mediaid;" | tail -n 1 >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
|
||||
|
||||
# EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time)
|
||||
[[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue