FRIENDS IPFS PINGing

This commit is contained in:
qo-op 2021-06-16 01:06:01 +02:00
parent c7e24e631f
commit cd53eeed62
2 changed files with 20 additions and 12 deletions

View File

@ -85,6 +85,10 @@ fi
echo "RUNTIME $runtime mn ($timebar)"
## CHECK & (RE)ACTIVATE ipfs p2p tunnels
# NextCloud FROM taurus TO oasis (https://taurus.copylaradio.com)
~/.zen/astrXbian/zen/ipfs_P2P_forward.sh
########################################################################
# STATION CAN MODIFY DEFCON (cool 5 to 1 war) - only 5 and 4 (fail2ban) are ready to use.
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # ADAPT $DEFCON scenario
@ -132,13 +136,13 @@ if [[ $(($minute % 15)) == 0 ]]; then
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
if [[ ! $isIPFSRunning ]]; then
[[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs
echo "ERROR! ipfs daemon is not running. EXIT"
echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1
fi
## (RE)ACTIVATE ipfs p2p tunnels
# NextCloud FROM taurus TO oasis (https://taurus.copylaradio.com)
$MY_PATH/zen/ipfs_P2P_forward.sh
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=7s -n 5 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
########## CHATON : OPEN OR CLOSE SSH ACCESS #################
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" == "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # OPEN-SSH
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH

View File

@ -28,7 +28,7 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
########################################################################
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=7s -n 5 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null); done
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=7s -n 5 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
########################################################################
# ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION
@ -81,7 +81,8 @@ do
MIMETYPE="video/${IPFSTUBELINK##*.}"
[[ "$MIMETYPE" == "video/avi" ]] && MIMETYPE="video/x-msvideo"
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM)
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM) # TODO : Use templating
### This index.html is ipns link root, 1st welcome page for MEDIAKEY -> *** Redirect to CONTRACTS processing HERE ***
echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"10;URL=https://tube.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/\">
<h1><a href='https://astroport.com'>ASTROPORT</a>/KODI</h1>
<a href=\"$IPFSTUBELINK\">LECTURE immédiate</a>! Lancement de la video dans 10 secondes ...<br>
@ -91,17 +92,19 @@ Bonne démonstration du service Video Club du Datacenter P2P Libre et Légal.<br
<img width=40 src=\"https://tube.copylaradio.com/ipns/$IPNSLINK/QR.png\"></a>" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/index.html
########################################################################
### ACTIVATE & EXECUTE HERE YOUR OWN SCENARIO
### Scenario are G1PUB subdivized. Thus each friend can establish own contract
# ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/index.html
########################################################################
# FRANCE COPIE PRIVEE - clear ipfs link no tracking
## Write KEY id (provide verification)
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/.id ]] && echo ${id} > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/.id
## LOCALHOST ASTROPORT STATION PAGE
## THIS MAKES FRENCH COPY RIGHT LAW RESPECT
## LOCALHOST REDIRECT FOR INTERNAL KODI DEFCON 3 (swarm.key) ASTROPORT STATION MODE
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=http://127.0.0.1:8181$(cat /tmp/${id}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/index.html
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=https://tube.copylaradio.com$(cat /tmp/${id}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/index.html
## DEMO PERIOD
## NICE FINAL STREAMING PAGE
echo "<!DOCTYPE html>
<html>
@ -156,6 +159,7 @@ Bonne démonstration du service Video Club du Datacenter P2P Libre et Légal.<br
# Message are sent to warn friends they have to manualy validate data conflict and merge back their mutual chain.
########################################################################
## CHAIN & IPNS REFRESH
########################################################################
# ipfs nanochain progression
I=$(ipfs add -qrH ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/ | tail -n 1)
@ -190,9 +194,9 @@ for ipnslink in $(ls ~/.zen/PIN/*/IPNSLINK);
[[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue
## GET ACTUAL IPNS .chain VALUE
actual=$(ipfs cat /ipns/$ipnsid/.chain)
actual=$(ipfs --timeout 10s cat /ipns/$ipnsid/.chain)
## PUBLISH IT
ipfs name publish -k ${mediakey} --quieter /ipfs/${actual}
ipfs --timeout 20s name publish -k ${mediakey} --quieter /ipfs/${actual}
echo "REFRESHED https://tube.copylaradio.com/ipns/$ipnsid TO /ipfs/$actual"
done