forked from axiom-team/astrXbian
85 lines
3.5 KiB
Bash
Executable File
85 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
||
########################################################################
|
||
# Author: Fred (support@qo-op.com)
|
||
# Version: 2020.04.28
|
||
# 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##*/}"
|
||
|
||
########################################################################
|
||
# \\///
|
||
# qo-op
|
||
############# '$MY_PATH/$ME'
|
||
########################################################################
|
||
# ex: ./'$ME'
|
||
# SYNC IPFS SWARM PEERS SHARED DATA .12D3KooW****
|
||
########################################################################'
|
||
|
||
########################################################################
|
||
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
||
########################################################################
|
||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
||
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
|
||
########################################################################
|
||
[[ ! -f ~/.zen/secret.dunikey ]] && exit 1
|
||
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||
########################################################################
|
||
|
||
echo '
|
||
|
||
_ _ _ _
|
||
/ \ / \ / \ / \
|
||
( I | P | N | S )
|
||
\_/ \_/ \_/ \_/
|
||
|
||
ZENTAG KEY REFRESH
|
||
'
|
||
echo "I am /ipns/$IPFSNODEID controling and refreshing my KEY ZenTag"
|
||
|
||
count=0
|
||
[[ ! -d ~/.zen/KEY/ ]] && exit 1
|
||
|
||
for id in $(ls ~/.zen/KEY/); # Alternative search
|
||
do
|
||
count=$((count+1))
|
||
IPNSLINK=$(ipfs key list -l | grep ${id} | cut -d ' ' -f 1)
|
||
|
||
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM)
|
||
echo "<meta http-equiv=\"Refresh\" content=\"10;URL=https://aries.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/\">
|
||
<h1>Rejoignez <a href='https://astroport.com'>ASTROPORT</a></h1><br>Installez <a href='https://copylaradio.com'>astrXbian</a>..." > ~/.zen/KEY/${id}/index.html
|
||
|
||
### CHANGE FILE ACCESS
|
||
# echo "<meta http-equiv=\"Refresh\" content=\"0;URL=http://localhost:8181/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME\">" > ~/.zen/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/index.html
|
||
|
||
## DEBUG, decode natools to discover ipns link
|
||
[[ -f ~/.zen/KEY/${id}/${G1PUB}/.ipfs.filelink.natools.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/KEY/${id}/${G1PUB}/.ipfs.filelink.natools.encrypt" -o "/tmp/filelink.txt" && cat /tmp/filelink.txt && rm /tmp/filelink.txt
|
||
## Write KEY id
|
||
[[ ! -f ~/.zen/KEY/${id}/${G1PUB}/.id ]] && echo ${id} > ~/.zen/KEY/${id}/${G1PUB}/.id
|
||
|
||
I=$(ipfs add -qrH ~/.zen/KEY/${id}/ | tail -n 1)
|
||
|
||
OLDCHAIN=$(cat ~/.zen/KEY/.chain)
|
||
if [[ "$OLDCHAIN" != "$I" ]] # MODIFY CHAIN only if something was changed
|
||
then
|
||
echo "$(date -u +%s%N | cut -b1-13)" > ~/.zen/KEY/.timestamp
|
||
echo $MIPFS > ~/.zen/KEY/.chain
|
||
fi
|
||
|
||
# KEY ZenTag IPNS name publish
|
||
J=$(ipfs name publish -k ${id} --quieter /ipfs/${I})
|
||
|
||
echo "$count $id REFRESHED https://aries.copylaradio.com/ipns/$J"
|
||
|
||
done
|
||
|
||
# echo "Ajouter une ML en relatif DU :
|
||
# DU(t+1)=(DU+c²)/r
|
||
# S(t+1)=(S+DU)/r
|
||
# M(t+1)=N (et oui, si vous regardez les formules, on n’a pas besoin de M :slight_smile: On a donc pas besoin de stocker M !)
|
||
# r=(1+DU)*N/N(t+1) (diviser par r, c’est multiplier par [N(t+1)/N]/(1+DU), qui prend en compte la variation de N)
|
||
|
||
# https://forum.monnaie-libre.fr/t/etude-commencer-a-la-moyenne/15231/34?u=qoop
|
||
# "
|