forked from axiom-team/astrXbian
Merge pull request 'master' (#1) from axiom-team/astrXbian:master into master
Reviewed-on: #1
This commit is contained in:
commit
71eb36fdba
|
@ -1,3 +1,3 @@
|
||||||
|
# CONTAINS G1PUB of bootstrap PUB Station
|
||||||
|
# oasis.astroport.com
|
||||||
2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS
|
2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS
|
||||||
|
|
||||||
#csmld
|
|
||||||
|
|
41
ISOconfig.sh
41
ISOconfig.sh
|
@ -15,34 +15,23 @@
|
||||||
# ~/.zen/ipfs.sync
|
# ~/.zen/ipfs.sync
|
||||||
########################################################################
|
########################################################################
|
||||||
# CHECK INTERNET CONNECTIVITY & git pull !!
|
# CHECK INTERNET CONNECTIVITY & git pull !!
|
||||||
|
rm -f /tmp/A_booting_log.txt
|
||||||
ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || (echo "NO INTERNET CONNEXION" && exit 1)
|
ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || (echo "NO INTERNET CONNEXION" && exit 1)
|
||||||
[[ -d ~/.zen/astrXbian ]] && cd ~/.zen/astrXbian && git pull || exit 1
|
[[ -d ~/.zen/astrXbian ]] && cd ~/.zen/astrXbian && git pull || exit 1
|
||||||
|
|
||||||
# CHECK IF CONFIG ALREADY DONE !! Remove ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync
|
# CHECK IF CONFIG ALREADY DONE !! Remove ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync
|
||||||
if [[ -f ~/.zen/ipfs.sync ]]; then
|
if [[ -f ~/.zen/ipfs.sync ]]; then
|
||||||
echo "CONFIG ALREADY DONE"
|
echo "CONFIG ALREADY DONE.... logging init in /tmp/A_booting_log.txt"
|
||||||
source ~/.zen/ipfs.sync
|
source ~/.zen/ipfs.sync
|
||||||
|
|
||||||
# Wait for ipfs to connect to its swarm, then send ipfstryme to $friend_of_mine
|
# Wait for ipfs to connect to its swarm
|
||||||
sleep 30
|
sleep 20
|
||||||
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr # ERASE
|
~/.zen/astrXbian/zen/gchange_INIT.sh >> /tmp/A_booting_log.txt
|
||||||
for tryme in $(ipfs id | jq -r .Addresses[]);
|
sleep 10
|
||||||
do
|
~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh >> /tmp/A_booting_log.txt
|
||||||
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
sleep 10
|
||||||
[[ ! $isLAN && $tryme != "" ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
|
~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh >> /tmp/A_booting_log.txt
|
||||||
done
|
|
||||||
|
|
||||||
# NEW BOOT! SEND ipfstryme message to my friends...
|
|
||||||
cd ~/.zen/astrXbian/zen/jaklis
|
|
||||||
# GET LIST of issuer(s) who likes me
|
|
||||||
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
|
||||||
do
|
|
||||||
# CHECk if I am liking him either
|
|
||||||
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
|
||||||
echo "Sending IPFSTRYME message to $liking_me"
|
|
||||||
[[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
done
|
|
||||||
cd -
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -124,15 +113,15 @@ echo "$XZUID" > ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid
|
||||||
########################################################################
|
########################################################################
|
||||||
echo "CREATE + profile"
|
echo "CREATE + profile"
|
||||||
########################################################################
|
########################################################################
|
||||||
~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.e-is.pro" set --name "$XZUID" --avatar "/home/xbian/.zen/astrXbian/logo.png" #CESIUM+
|
~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.e-is.pro" set --name "$XZUID" --avatar "/home/$USER/.zen/astrXbian/logo.png" #CESIUM+
|
||||||
~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://data.gchange.fr" set --name "$XZUID" --avatar "/home/xbian/.zen/astrXbian/logo.png" #GCHANGE+
|
~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://data.gchange.fr" set --name "$XZUID" --avatar "/home/$USER/.zen/astrXbian/logo.png" #GCHANGE+
|
||||||
### REVERT
|
### REVERT
|
||||||
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.e-is.pro" erase
|
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.e-is.pro" erase
|
||||||
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://data.gchange.fr" erase
|
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://data.gchange.fr" erase
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
########################################################################
|
########################################################################
|
||||||
echo "BECOME FRIEND with oasis (1st bootstrap)"
|
echo "BECOME FRIEND with A_boostrap_nodes.txt (1st bootstrap)"
|
||||||
########################################################################
|
########################################################################
|
||||||
for g1node in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
for g1node in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
||||||
do
|
do
|
||||||
|
@ -160,10 +149,12 @@ echo 'EXTEND ~/.bashrc'
|
||||||
########################################################################
|
########################################################################
|
||||||
~/.zen/astrXbian/.install/update_bashrc.sh
|
~/.zen/astrXbian/.install/update_bashrc.sh
|
||||||
|
|
||||||
echo "Configure .kodi/addons/plugin.video.vstream/resources/sites/astroport.py"
|
echo "COPY .kodi template "
|
||||||
cp -f ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py \
|
cp -Rf ~/.zen/astrXbian/.install/.kodi ~/
|
||||||
|
# cp -f ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py \
|
||||||
~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py
|
~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py
|
||||||
|
|
||||||
|
echo "Configure .kodi/addons/plugin.video.vstream/resources/sites/astroport.py"
|
||||||
# CREATE xbian IPNSKEY used to publish ~/.zen/ipfs_swarm/xbian (contains all XZUID pastebin files)
|
# CREATE xbian IPNSKEY used to publish ~/.zen/ipfs_swarm/xbian (contains all XZUID pastebin files)
|
||||||
ipfs key rm xbian
|
ipfs key rm xbian
|
||||||
IPNSKEY=$(ipfs key gen xbian)
|
IPNSKEY=$(ipfs key gen xbian)
|
||||||
|
|
|
@ -75,6 +75,8 @@ fi
|
||||||
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/
|
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/
|
||||||
#
|
#
|
||||||
##################################################################
|
##################################################################
|
||||||
|
#
|
||||||
|
[[ "$minute" == "01" ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/gchange_INIT.sh &
|
||||||
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
|
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
|
||||||
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/gchange_IPFS_swarm.sh &
|
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/gchange_IPFS_swarm.sh &
|
||||||
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh &
|
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh &
|
||||||
|
|
|
@ -49,9 +49,9 @@ sudo fail2ban restart
|
||||||
### Install astrxbian & NGINX config
|
### Install astrxbian & NGINX config
|
||||||
sudo rm -Rf /var/www/astrxbian
|
sudo rm -Rf /var/www/astrxbian
|
||||||
sudo mkdir -p /var/www/astrxbian
|
sudo mkdir -p /var/www/astrxbian
|
||||||
sudo cp -Rf /home/xbian/.zen/astrXbian/www/xbian/* /var/www/astrxbian
|
sudo cp -Rf /home/$USER/.zen/astrXbian/www/xbian/* /var/www/astrxbian
|
||||||
sudo chown -R xbian:xbian /var/www/astrxbian
|
sudo chown -R $USER:$USER /var/www/astrxbian
|
||||||
sudo cp -f /home/xbian/.zen/astrXbian/.install/templates/nginx/astrxbian.conf /etc/nginx/conf.d/
|
sudo cp -f /home/$USER/.zen/astrXbian/.install/templates/nginx/astrxbian.conf /etc/nginx/conf.d/
|
||||||
|
|
||||||
# TODO #######################################################################
|
# TODO #######################################################################
|
||||||
# echo "Install JUKEBOOX"
|
# echo "Install JUKEBOOX"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
########################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 2020.12.25
|
||||||
|
# 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);
|
||||||
|
IPFSNODEID=$(ipfs id -f='<id>\n')
|
|
@ -1,115 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
########################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 2020.11.30
|
|
||||||
# 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##*/}"
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
|
||||||
########################################################################
|
|
||||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
|
||||||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
|
||||||
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! EXIT" && exit 1
|
|
||||||
########################################################################
|
|
||||||
[[ ! -f ~/.zen/secret.dunikey ]] && echo "Missing ~/.zen/secret.dunikey. EXIT" && exit 1
|
|
||||||
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
|
||||||
[[ $G1PUB == "" ]] && echo "ERROR G1PUB empty !! EXIT" && exit 1
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
# GET NODE disk performance. TODO, publish and use as IPFS repartition
|
|
||||||
echo "DISK SIZE AVAILABLE & PERFORMANCE TESTING"
|
|
||||||
[[ -f ~/.ipfs/test.disk ]] && rm -f ~/.ipfs/test.disk
|
|
||||||
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
|
|
||||||
# echo $diskperf
|
|
||||||
|
|
||||||
# IPFS LOCAL REPOSITORY for Node Identity
|
|
||||||
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
|
||||||
|
|
||||||
# find IPFSTRYME public address
|
|
||||||
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
for tryme in $(ipfs id | jq -r .Addresses[]);
|
|
||||||
do
|
|
||||||
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
|
||||||
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
done
|
|
||||||
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
|
|
||||||
|
|
||||||
################################
|
|
||||||
# ADD Cesium+ informations
|
|
||||||
CESIUMPLUS="https://g1.data.le-sou.org"
|
|
||||||
|
|
||||||
# PREPARE title
|
|
||||||
# Made from Gchange+ profile tittle and city OR user@hostname
|
|
||||||
title=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.title')
|
|
||||||
[[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && uidna=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
|
|
||||||
|
|
||||||
# Put in .$IPFSNODEID INDEX: _g1.uidna & _g1.cesium_name (used by Minetest flavour and others)
|
|
||||||
[[ $uidna ]] && echo "$uidna" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.uidna
|
|
||||||
[[ $title ]] && echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.cesium_name
|
|
||||||
|
|
||||||
[[ $uidna ]] && [[ "$title" == "null" ]] && title="Station $uidna"
|
|
||||||
[[ "$title" == "null" ]] && title="Station $USER@$(cat /etc/hostname)"
|
|
||||||
|
|
||||||
city=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.city')
|
|
||||||
[[ "$city" != "null" ]] && title="$title in $city"
|
|
||||||
|
|
||||||
# ADD "cesium_geoPoint.lat" AND "cesium_geoPoint.lon" messages in SSB feed
|
|
||||||
# This way any SSB account is connected to its Cesium+ Geolocalisation.
|
|
||||||
geopointlat=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq '._source.geoPoint.lat')
|
|
||||||
geopointlon=$(curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq '._source.geoPoint.lon')
|
|
||||||
|
|
||||||
# REFRESH Cesium+ Avatar image
|
|
||||||
curl -s ${CESIUMPLUS}/user/profile/${G1PUB} | jq -r '._source.avatar._content' | base64 -d > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.cesium.avatar.png"
|
|
||||||
|
|
||||||
# Get nodename
|
|
||||||
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename ]] && nodename=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename)
|
|
||||||
if [[ $nodename == "" ]]; then
|
|
||||||
nodename=$(cat /etc/hostname)
|
|
||||||
extension=$(echo $nodename | cut -d '.' -f 2)
|
|
||||||
if [[ $extension == $nodename ]]; then
|
|
||||||
nodename=$nodename.home
|
|
||||||
fi
|
|
||||||
echo "$nodename" > /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename
|
|
||||||
fi
|
|
||||||
########################################################################
|
|
||||||
# DUNITER G1 Wallet balance
|
|
||||||
export LC_ALL=C.UTF-8 #attipix
|
|
||||||
export LANG=C.UTF-8 #attipix
|
|
||||||
|
|
||||||
# COPY NODE G1SSB ID to IPFS
|
|
||||||
echo "$G1PUB" > ~/.zen/ipfs/.${IPFSNODEID}/G1SSB/_g1.pubkey
|
|
||||||
|
|
||||||
# IPFS Node PUBLISH Adresses so Pub can become bootstrap for ${g1author}
|
|
||||||
ipfs id | jq -r .Addresses[] > ~/.zen/ipfs/.${IPFSNODEID}/Addresses
|
|
||||||
|
|
||||||
# IPFS Node PUBLISH AgentVersion & repo.stat
|
|
||||||
ipfs id | jq -r .AgentVersion > ~/.zen/ipfs/.${IPFSNODEID}/AgentVersion
|
|
||||||
ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat
|
|
||||||
|
|
||||||
echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf
|
|
||||||
echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes
|
|
||||||
|
|
||||||
|
|
||||||
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
|
|
||||||
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
|
|
||||||
|
|
||||||
###
|
|
||||||
# GET ALL MY CESIUMPLUS FRIENDS AND SEND THEM my IPFS Address
|
|
||||||
|
|
||||||
cd ~/.zen/astrXbian/zen/jaklis
|
|
||||||
# GET LIST of issuer(s) who likes me
|
|
||||||
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
|
||||||
do
|
|
||||||
# CHECk if I am liking him either
|
|
||||||
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
|
||||||
echo "Sending IPFSTRYME message to $liking_me"
|
|
||||||
[[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
done
|
|
||||||
cd -
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,118 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
########################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 2020.12.03
|
|
||||||
# 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##*/}"
|
|
||||||
|
|
||||||
# Connect to IPFS peers with bidirectionnal "like" (Cesium+ friends)
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# \\///
|
|
||||||
# qo-op
|
|
||||||
############# '$MY_PATH/$ME'
|
|
||||||
########################################################################
|
|
||||||
# ex: ./'$ME'
|
|
||||||
# GET CESIUM FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
|
|
||||||
########################################################################'
|
|
||||||
|
|
||||||
## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0 (use natools to sign messages?)
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# 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
|
|
||||||
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
|
|
||||||
[[ ! $isIPFSRunning ]] && echo "ERROR! ipfs daemon is not running. EXIT" && exit 1
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
# Force Strict #swarm0 !!?
|
|
||||||
# ipfs bootstrap rm --all
|
|
||||||
echo "" > ~/.zen/A_allow_ip.txt
|
|
||||||
|
|
||||||
echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message
|
|
||||||
liking_me_count=0
|
|
||||||
friend_of_mine_count=0
|
|
||||||
########################################################################
|
|
||||||
# Let's look for Friends and "IPFS swarm connect" with them
|
|
||||||
########################################################################
|
|
||||||
cd ~/.zen/astrXbian/zen/jaklis
|
|
||||||
rm -f ~/.zen/A_allow_ipfsid.txt ~/.zen/A_allow_ip.txt
|
|
||||||
|
|
||||||
# 1. Get C+ "liking_me" people list
|
|
||||||
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
|
||||||
do
|
|
||||||
# Check if my like is reverse
|
|
||||||
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
|
||||||
|
|
||||||
[[ $friend_of_mine != null ]] && echo "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
|
|
||||||
&& for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
|
|
||||||
# 2. Searching "ipfstryme" message from friend_of_mine
|
|
||||||
do
|
|
||||||
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
|
|
||||||
# Fill a file with friend of mine ip
|
|
||||||
echo $ip >> ~/.zen/A_allow_ip.txt
|
|
||||||
# Get its ipfsnodeid
|
|
||||||
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $8}')
|
|
||||||
echo $ipfsnodeid >> ~/.zen/A_allow_ipfsid.txt
|
|
||||||
|
|
||||||
g1id=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py "$ipfsnodeid")
|
|
||||||
if [[ "$g1id" == "$friend_of_mine" ]]; then
|
|
||||||
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
|
|
||||||
ipfs swarm connect $peer;
|
|
||||||
ipfs bootstrap add $peer;
|
|
||||||
|
|
||||||
ipfsadd=$((ipfsadd+1))
|
|
||||||
else
|
|
||||||
echo "ALERT!!! $friend_of_mine spoofing is happening"
|
|
||||||
fi
|
|
||||||
done;
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $friend_of_mine != null ]]; then
|
|
||||||
if [[ $ipfsadd == 0 ]]; then
|
|
||||||
# Friend of mine with no ipfstryme message (did not install astroport?)
|
|
||||||
echo "No 'ipfstryme' message... from $liking_me"
|
|
||||||
echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt
|
|
||||||
|
|
||||||
else
|
|
||||||
# REMOVING DUPLICATES OLD ipfstryme MESSAGES
|
|
||||||
nbmessage=0
|
|
||||||
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
|
|
||||||
do
|
|
||||||
nbmessage=$((nbmessage+1))
|
|
||||||
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
|
|
||||||
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
|
|
||||||
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
|
|
||||||
echo "__________________________________________"
|
|
||||||
liking_me_count=$((liking_me_count+1))
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
echo "####################################################
|
|
||||||
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
|
|
||||||
__________________________________________
|
|
||||||
My actual #SWARM0"
|
|
||||||
ipfs swarm peers
|
|
||||||
echo "__________________________________________"
|
|
||||||
echo
|
|
||||||
## Could send message to friends with 'ipfstryme' message
|
|
||||||
for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
|
|
||||||
echo "Liking each other, but no ipfstryme received..."
|
|
||||||
echo "cd ~/.zen/astrXbian/zen/jaklis"
|
|
||||||
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
|
|
||||||
done
|
|
||||||
|
|
||||||
cd -
|
|
|
@ -21,21 +21,14 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
# GET NODE disk performance. TODO, publish and use as IPFS repartition
|
# GET NODE disk performance. TODO, publish and use as IPFS repartition
|
||||||
echo "DISK SIZE AVAILABLE & PERFORMANCE TESTING"
|
|
||||||
[[ -f ~/.ipfs/test.disk ]] && rm -f ~/.ipfs/test.disk
|
[[ -f ~/.ipfs/test.disk ]] && rm -f ~/.ipfs/test.disk
|
||||||
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
|
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
|
||||||
# echo $diskperf
|
echo "DISK PERFORMANCE TESTING : $diskperf"
|
||||||
|
|
||||||
# IPFS LOCAL REPOSITORY for Node Identity
|
# IPFS LOCAL REPOSITORY for Node Identity
|
||||||
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
||||||
|
|
||||||
# find IPFSTRYME public address
|
# create IPFSTRYME public address file
|
||||||
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
for tryme in $(ipfs id | jq -r .Addresses[]);
|
|
||||||
do
|
|
||||||
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
|
||||||
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
done
|
|
||||||
~/.zen/astrXbian/zen/tools/add_externIP_to_ipfstryme.sh
|
~/.zen/astrXbian/zen/tools/add_externIP_to_ipfstryme.sh
|
||||||
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
|
||||||
|
@ -103,16 +96,17 @@ NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
|
||||||
|
|
||||||
###
|
###
|
||||||
# GET ALL MY GCHANGE FRIENDS AND SEND THEM my IPFS Address
|
# GET ALL MY GCHANGE FRIENDS AND SEND THEM my IPFS Address
|
||||||
|
########################################################################
|
||||||
cd ~/.zen/astrXbian/zen/jaklis
|
|
||||||
# GET LIST of issuer(s) who likes me
|
# GET LIST of issuer(s) who likes me
|
||||||
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
for liking_me in $(~/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer');
|
||||||
do
|
do
|
||||||
# CHECk if I am liking him either
|
# CHECk if I am liking him either
|
||||||
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py like -p $liking_me | jq -r '.yours');
|
||||||
echo "Sending IPFSTRYME message to $liking_me"
|
echo "Sending IPFSTRYME message to $liking_me"
|
||||||
[[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
[[ $friend_of_mine != null ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
sleep 3 # SLOW DOWN
|
||||||
done
|
done
|
||||||
|
|
||||||
echo 'SEND ipfstryme to A_boostrap_nodes.txt listed PUBs' # Add your bootstrap Pub here
|
echo 'SEND ipfstryme to A_boostrap_nodes.txt listed PUBs' # Add your bootstrap Pub here
|
||||||
for g1node in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
for g1node in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
|
||||||
do
|
do
|
||||||
|
@ -120,11 +114,16 @@ if [[ $g1node != "" ]]; then
|
||||||
echo "LIKING my BOOTSTRAP node : $g1node"
|
echo "LIKING my BOOTSTRAP node : $g1node"
|
||||||
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.le-sou.org" send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -n "https://g1.data.le-sou.org" send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
|
||||||
|
isG1PUBoot=$(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep "$G1PUB") # search my G1PUB ?
|
||||||
|
if [[ $isG1PUBoot == "$G1PUB" ]]; then
|
||||||
|
for liking_me in $(/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer')
|
||||||
|
do
|
||||||
|
echo "SENDING 3 STARS to $liking_me"
|
||||||
|
/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py like -p $liking_me -s 3
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
cd -
|
|
||||||
|
|
||||||
# SHOW RESULT
|
|
||||||
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -8,20 +8,9 @@ MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
ME="${0##*/}"
|
ME="${0##*/}"
|
||||||
|
|
||||||
# Connect to IPFS peers with bidirectionnal "like" (Gchange or Cesium+ friends)
|
# create swarm_map and my_swam files
|
||||||
# configured in jaklis/.env
|
echo "" > ~/.zen/A_my_swarm.txt
|
||||||
|
echo "" > ~/.zen/A_swarm_map.txt
|
||||||
########################################################################
|
|
||||||
# \\///
|
|
||||||
# qo-op
|
|
||||||
############# '$MY_PATH/$ME'
|
|
||||||
########################################################################
|
|
||||||
# ex: ./'$ME'
|
|
||||||
# GET GCHANGE FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
|
|
||||||
########################################################################'
|
|
||||||
|
|
||||||
## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
||||||
|
@ -34,86 +23,65 @@ isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|gr
|
||||||
|
|
||||||
# Force Strict #swarm0 !!?
|
# Force Strict #swarm0 !!?
|
||||||
# ipfs bootstrap rm --all
|
# ipfs bootstrap rm --all
|
||||||
echo "" > ~/.zen/A_allow_ip.txt
|
|
||||||
|
|
||||||
echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message
|
|
||||||
liking_me_count=0
|
liking_me_count=0
|
||||||
friend_of_mine_count=0
|
friend_of_mine_count=0
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Let's look for Friends and "IPFS swarm connect" with them
|
# Let's look for Friends and "IPFS swarm connect" with them
|
||||||
########################################################################
|
########################################################################
|
||||||
cd ~/.zen/astrXbian/zen/jaklis
|
|
||||||
rm -f ~/.zen/A_allow_ipfsid.txt ~/.zen/A_allow_ip.txt
|
|
||||||
|
|
||||||
# 1. Get Gchange "liking_me" people list
|
# 1. Get Gchange "liking_me" people list
|
||||||
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
for liking_me in $(~/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer');
|
||||||
do
|
do
|
||||||
|
[[ "$liking_me" == "" ]] && continue
|
||||||
|
# DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter les ipfstryme vers ~/.zen/A_swarm_map.txt
|
||||||
|
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
|
||||||
# Check if my like is reverse
|
# Check if my like is reverse
|
||||||
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
liking_me_count=$((liking_me_count+1))
|
||||||
|
echo ">>>>>> CHECKING my friend n° $liking_me_count"
|
||||||
[[ $friend_of_mine != null ]] && echo "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
|
echo "READING 'ipfstryme' message from $liking_me"
|
||||||
&& for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
|
for peerline in $(~/.zen/astrXbian/zen/jaklis/jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
|
||||||
# 2. Searching "ipfstryme" message from friend_of_mine
|
|
||||||
do
|
do
|
||||||
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
|
echo "PEERLINE: $peerline"
|
||||||
# Fill a file with friend of mine ip
|
# KEEP A_swarm_map.txt uniq "$peerline" line
|
||||||
echo $ip >> ~/.zen/A_allow_ip.txt
|
echo $peerline >> ~/.zen/A_swarm_map.txt
|
||||||
# Get its ipfsnodeid
|
cat ~/.zen/A_swarm_map.txt | uniq > /tmp/A_swarm_map.txt
|
||||||
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $7}')
|
cp -f /tmp/A_swarm_map.txt ~/.zen/A_swarm_map.txt
|
||||||
echo $ipfsnodeid >> ~/.zen/A_allow_ipfsid.txt
|
|
||||||
|
|
||||||
g1id=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py "$ipfsnodeid")
|
# Get ipfsnodeid
|
||||||
if [[ "$g1id" == "$friend_of_mine" ]]; then
|
ipfsnodeid=$(echo "$peerline" | awk -F '/' '{print $8}')
|
||||||
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
|
[[ "$ipfsnodeid" == "" ]] && continue
|
||||||
ipfs swarm connect $peer;
|
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
|
||||||
ipfs bootstrap add $peer;
|
echo "Am I friend whith $whoisg1 ?"
|
||||||
|
friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py like -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
|
||||||
ipfsadd=$((ipfsadd+1))
|
if [[ "$friend_of_mine" != "" ]]; then
|
||||||
else
|
friend_of_mine_count=$((friend_of_mine_count+1))
|
||||||
echo "ALERT!!! $friend_of_mine spoofing is happening"
|
echo "YEAH FRIEND ° $friend_of_mine_count !!!"
|
||||||
|
echo $peerline >> ~/.zen/A_my_swarm.txt
|
||||||
|
# REMOVING OLD ipfstryme MESSAGES
|
||||||
|
nbmessage=0
|
||||||
|
for messageid in $(~/.zen/astrXbian/zen/jaklis/jaklis.py read -n50 -j | jq -r --arg friendKEY "$whoisg1" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
|
||||||
|
do
|
||||||
|
nbmessage=$((nbmessage+1))
|
||||||
|
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $whoisg1" && ~/.zen/astrXbian/zen/jaklis/jaklis.py delete -i $messageid
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
|
||||||
if [[ $friend_of_mine != null ]]; then
|
|
||||||
if [[ $ipfsadd == 0 ]]; then
|
|
||||||
# Friend of mine with no ipfstryme message (did not install astroport)
|
|
||||||
echo "No 'ipfstryme' message... from $liking_me"
|
|
||||||
echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt
|
|
||||||
|
|
||||||
else
|
|
||||||
# REMOVING DUPLICATES OLD ipfstryme MESSAGES
|
|
||||||
nbmessage=0
|
|
||||||
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
|
|
||||||
do
|
|
||||||
nbmessage=$((nbmessage+1))
|
|
||||||
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
|
|
||||||
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
|
|
||||||
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
|
|
||||||
echo "__________________________________________"
|
echo "__________________________________________"
|
||||||
liking_me_count=$((liking_me_count+1))
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# UNIQ file
|
||||||
|
cat ~/.zen/A_my_swarm.txt | uniq > /tmp/A_my_swarm.txt
|
||||||
|
cp -f /tmp/A_my_swarm.txt ~/.zen/A_my_swarm.txt
|
||||||
|
|
||||||
echo "####################################################
|
echo "####################################################
|
||||||
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
|
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
|
||||||
__________________________________________
|
__________________________________________
|
||||||
My actual #SWARM0"
|
My actual #SWARM0"
|
||||||
ipfs swarm peers
|
ipfs swarm peers
|
||||||
echo "__________________________________________"
|
|
||||||
echo
|
|
||||||
## Could send message to friends with 'ipfstryme' message
|
|
||||||
for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
|
|
||||||
echo "Liking each other, but no ipfstryme received..."
|
|
||||||
echo "cd ~/.zen/astrXbian/zen/jaklis"
|
|
||||||
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
|
|
||||||
done
|
|
||||||
|
|
||||||
cd -
|
# HONTO SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
########################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 2020.12.22
|
|
||||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
||||||
########################################################################
|
|
||||||
# Auto maticaly accept incoming frendship sending back 3 stars like
|
|
||||||
# AstrXbian NODE running it starts acting like a "SSB" PUB
|
|
||||||
# Best using 24/24 public IP node + 1 TB
|
|
||||||
|
|
||||||
# GET XZUID
|
|
||||||
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ]] && echo "ERROR no _xbian.zuid" && exit 1
|
|
||||||
XZUID=$(cat ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid) # Should be hostname... but like that can be changed...
|
|
||||||
|
|
||||||
isG1PUBoot=$(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep "$G1PUB") # search my G1PUB ?
|
|
||||||
|
|
||||||
if [[ $isG1PUBoot == "$G1PUB" ]]; then
|
|
||||||
for liking_me in $(/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py like | jq -r '.likes[].issuer')
|
|
||||||
do
|
|
||||||
echo "SENDING 3 STARS to $liking_me"
|
|
||||||
/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py like -p $liking_me -s 3
|
|
||||||
echo "Our SWARM will join during ipfs_SWARM_refresh.sh RUN"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh
|
|
||||||
|
|
||||||
echo "Share collected indexes as mine"
|
|
||||||
cp /var/www/astrxbian/FASTRXBIAN ~/.zen/ipfs/xbian/F${XZUID}
|
|
||||||
|
|
|
@ -37,48 +37,44 @@ rm -Rf /home/$YOU/.zen/ipfs_swarm/.Qm*
|
||||||
rm -Rf /home/$YOU/.zen/ipfs_swarm/*
|
rm -Rf /home/$YOU/.zen/ipfs_swarm/*
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
for peer in $(ipfs swarm peers);
|
for peerline in $(ipfs swarm peers && cat ~/.zen/A_swarm_map.txt);
|
||||||
do
|
do
|
||||||
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $8}')
|
ipfsnodeid=$(echo "$peerline" | awk -F '/' '{print $8}')
|
||||||
ip=$(echo "$peer" | awk -F '/' '{print $3}')
|
[[ "$ipfsnodeid" == "" ]] && continue
|
||||||
|
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
|
||||||
|
|
||||||
|
ip=$(echo "$peerline" | awk -F '/' '{print $3}')
|
||||||
|
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
||||||
|
|
||||||
nowdate=$(date)
|
nowdate=$(date)
|
||||||
timestamp=$(date -u +%s%N | cut -b1-13)
|
timestamp=$(date -u +%s%N | cut -b1-13)
|
||||||
|
|
||||||
echo "$nowdate - $ipfsnodeid - $ip"
|
echo "### $nowdate ### whoisg1 : $ipfsnodeid - $ip"
|
||||||
foundIp=$(cat ~/.zen/A_allow_ip.txt | grep "$ip")
|
echo "${peerline}"
|
||||||
foundIpfs=$(cat ~/.zen/A_allow_ipfsid.txt | grep "$ipfsnodeid")
|
myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid )
|
||||||
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
if [[ "$myfriendpeer" != "" ]]; then
|
||||||
|
[[ ! $(ipfs swarm peers | grep $ipfsnodeid) ]] && ipfs swarm connect "$peerline" && ipfs bootstrap add "$peerline"
|
||||||
if [[ ! $foundIpfs && ! $isLAN ]] ; then
|
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
|
||||||
echo "${ip} of peer ${id} is not in the authorized ip list."
|
$MY_PATH/tools/timeout.sh -t 20 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
|
||||||
echo "${peer} will be removed from the swarm"
|
else
|
||||||
|
echo "KO ___________________ # YOU CAN ACTIVATE FAIL2BAN"
|
||||||
ipfs swarm disconnect $peer
|
# PLEASE ADD $USER NOPASSWD:ALL for fail2ban-client in /etc/sudoers
|
||||||
ipfs bootstrap rm $peer
|
|
||||||
|
|
||||||
echo "# FAIL2BAN # $USER must activate no password sudo (Rpi & Xbian OK)"
|
|
||||||
if [[ $USER == "pi" || $USER == "xbian" ]]; then
|
|
||||||
echo "TODO BAN $ip ($ipfsnodeid)"
|
|
||||||
# sudo fail2ban-client add recidive 2>/dev/null 1>&2
|
# sudo fail2ban-client add recidive 2>/dev/null 1>&2
|
||||||
# sudo fail2ban-client start recidive
|
# sudo fail2ban-client start recidive
|
||||||
# sudo fail2ban-client set recidive banip $ip
|
# sudo fail2ban-client set recidive banip $ip
|
||||||
# Show banned IP
|
# Show banned IP
|
||||||
# sudo fail2ban-client status recidive
|
# sudo fail2ban-client status recidive
|
||||||
|
echo "?? BAN $ip ($ipfsnodeid)"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "${peer}"
|
|
||||||
echo "REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
|
|
||||||
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
########################################################################
|
||||||
|
########################################################################
|
||||||
echo "$IPFSNODEID PUBLISHING /home/$YOU/.zen/ipfs/ to SWARM"
|
echo "$IPFSNODEID PUBLISHING /home/$YOU/.zen/ipfs/ to SWARM"
|
||||||
[[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
|
[[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
|
||||||
IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
|
IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
|
||||||
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
||||||
|
|
||||||
# Retrieve my own data in /home/$YOU/.zen/ipfs_swarm/
|
# Retrieve my own data in /home/$YOU/.zen/ipfs_swarm/
|
||||||
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
|
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
########################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 2020.03.18
|
|
||||||
# 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
|
|
||||||
########################################################################
|
|
||||||
# \\///
|
|
||||||
# qo-op
|
|
||||||
#############
|
|
||||||
##########################
|
|
||||||
#######################################
|
|
||||||
####################################################
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# check /tmp/cmd_received_$SOURCEH and /tmp/cmd_SPAM_$SOURCEH within 1mn
|
|
||||||
|
|
||||||
# Remove older than a minute received COMMAND
|
|
||||||
find /tmp -cmin +1 -type f -name "cmd_received_*" -exec rm -f '{}' \; 2>/dev/null
|
|
||||||
# Filter Acknowlegement
|
|
||||||
if [[ "$CMD" != "ACK" && "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then
|
|
||||||
# Still less than a minute with same $SOURCEH
|
|
||||||
if [[ -f "/tmp/cmd_received_$SOURCEH" ]]; then
|
|
||||||
# Create SPAM file => Stop answering
|
|
||||||
if [[ ! -f "/tmp/cmd_SPAM_$SOURCEH" ]]; then
|
|
||||||
echo $(date) > "/tmp/cmd_SPAM_$SOURCEH"
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
echo "$COMMAND" > "/tmp/cmd_received_$SOURCEH"
|
|
||||||
# Remove SPAM flag older than one day
|
|
||||||
find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null
|
|
||||||
else
|
|
||||||
# THIS IS AN AKNOWLEGEMENT
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Remove SPAM flag older than one day
|
|
||||||
find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,32 @@ ME="${0##*/}"
|
||||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
|
|
||||||
EXTERNIP=$(curl -s http://whatismyip.akamai.com/)
|
#EXTERNIP=$(curl -s http://whatismyip.akamai.com/)
|
||||||
########################################################################
|
########################################################################
|
||||||
echo "ADD $EXTERNIP to /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr"
|
echo "ADDING KNOWN Adresses to /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr"
|
||||||
########################################################################
|
########################################################################
|
||||||
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}
|
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}
|
||||||
echo "/ip4/$EXTERNIP/udp/4001/astro/p2p/${IPFSNODEID}" >> /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
# echo "/ip4/$EXTERNIP/udp/4001/astro/p2p/${IPFSNODEID}" >> /home/$YOU/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
# Doesn't have the right NATed port, so pretty useless...
|
||||||
|
|
||||||
|
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
for tryme in $(ipfs id | jq -r .Addresses[]);
|
||||||
|
do
|
||||||
|
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
||||||
|
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "ME = $tryme"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Now adding "ipfs swarm peers" to ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
for tryme in $(ipfs swarm peers);
|
||||||
|
do
|
||||||
|
echo "___________________________________________"
|
||||||
|
echo "$tryme"
|
||||||
|
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
||||||
|
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "___________________________________________ADDING"
|
||||||
|
done
|
||||||
|
# UNIQ TOUT CA
|
||||||
|
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | uniq > /tmp/tryme.addr
|
||||||
|
cp -f /tmp/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
rm -f /tmp/tryme.addr
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue