forked from axiom-team/astrXbian
ipfs p2p stuff
This commit is contained in:
parent
fcc0cb7e75
commit
6d5722fa94
|
@ -0,0 +1 @@
|
||||||
|
Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS
|
|
@ -1,27 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
################################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 0.1
|
|
||||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
||||||
################################################################################
|
|
||||||
# Activate SUPPORT MODE: open ssh over IPFS
|
|
||||||
MY_PATH="`dirname \"$0\"`" # relative
|
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
||||||
########################################################################
|
|
||||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
|
||||||
IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
|
|
||||||
WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
|
|
||||||
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
|
|
||||||
########################################################################
|
|
||||||
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
|
|
||||||
|
|
||||||
# Arrange local port forwarded to swarm
|
|
||||||
|
|
||||||
# GET _uidna (means g1sms/init.sh been run)
|
|
||||||
[[ -f /home/$YOU/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ]] && UIDNA=$(cat /home/$YOU/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid)
|
|
||||||
|
|
||||||
ipfs p2p close --all
|
|
||||||
ipfs p2p listen /x/ssh-$UIDNA /ip4/127.0.0.1/tcp/22
|
|
||||||
# ipfs p2p listen /x/http-$UIDNA /ip4/127.0.0.1/tcp/80
|
|
||||||
# ipfs p2p listen /x/https-$UIDNA /ip4/127.0.0.1/tcp/443
|
|
||||||
ipfs p2p ls
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Activate SUPPORT MODE: open ssh over IPFS
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
########################################################################
|
||||||
|
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
||||||
|
IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n') || er+=" ipfs id problem"
|
||||||
|
[[ "$YOU" == "" || "$IPFSNODEID" == "" ]] && echo "ERROR : $er " && exit 1
|
||||||
|
########################################################################
|
||||||
|
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
|
||||||
|
IPFSADMINID=$(cat ~/.zen/astrXbian/A_swarm_admin.txt)
|
||||||
|
|
||||||
|
## OASIS acts as nginx proxy WITH localhost:2443 => taurus:443 (NextCloud)
|
||||||
|
# OASIS : /etc/nginx/sites-available/taurus.copylaradio.com.conf
|
||||||
|
# server {
|
||||||
|
# server_name taurus.copylaradio.com;
|
||||||
|
#
|
||||||
|
# access_log /var/log/nginx/taurus-access.log;
|
||||||
|
# error_log /var/log/nginx/taurus-error.log;
|
||||||
|
#
|
||||||
|
# location / {
|
||||||
|
# proxy_pass https://127.0.0.1:2443;
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# + sudo certbot !!
|
||||||
|
|
||||||
|
if [[ "$IPFSNODEID" == "12D3KooWRstYPJSakosgnvvGpxDdUJd2xAncJB7fbBwLBaTAEJxp" ]]; then
|
||||||
|
ipfs p2p listen /x/https-taurus /ip4/127.0.0.1/tcp/443
|
||||||
|
fi
|
||||||
|
# OASIS /etc/nginx/sites-available/taurus.copylaradio.com.conf
|
||||||
|
if [[ "$IPFSNODEID" == "12D3KooWBYme2BsNUrtx4mEdNX6Yioa9AV7opWzQp6nrPs6ZKabN" ]]; then
|
||||||
|
ipfs p2p close -p /x/https-taurus
|
||||||
|
ipfs p2p forward /x/https-taurus /ip4/127.0.0.1/tcp/2443 /p2p/12D3KooWRstYPJSakosgnvvGpxDdUJd2xAncJB7fbBwLBaTAEJxp
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipfs p2p ls
|
|
@ -20,7 +20,7 @@ ME="${0##*/}"
|
||||||
########################################################################
|
########################################################################
|
||||||
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
|
||||||
########################################################################
|
########################################################################
|
||||||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n')
|
||||||
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
|
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
|
||||||
########################################################################
|
########################################################################
|
||||||
[[ ! -f ~/.zen/secret.dunikey ]] && exit 1
|
[[ ! -f ~/.zen/secret.dunikey ]] && exit 1
|
||||||
|
|
|
@ -23,8 +23,9 @@ then
|
||||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFLHW8P88C/B7622yXzdAn1ZcTBfE1A4wMqajBwAoHwUVTOUaYfvkiSxbzb5H9dPTAXhQU6ZfuLa70kTo1m2b9TKH0tD6hR3RiKJ0NIjCHYEypcPGpLmHaZWnBKPq3IUU24qFVdUJxnTkDdFUszYMNoV4nqlXY/ZYdNpic8L1jPPyfOLLfPFkuSxagyQj4FGJq77UQE5j+skMJS3ISkazNTLqOCGLFJ5qtBC11BvQaCJ4cQ2Ss7ejPYhpx16NLJfg9VtG4dv9ZebEIl2pf7niiQGSPrDMFWHuQcGAuHt/patr0BcvfvD3Gv+qNsVfAJCNZ2U5NHEMKIhgj1ilNPEw7 fred@ONELOVE" >> ~/.ssh/authorized_keys
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFLHW8P88C/B7622yXzdAn1ZcTBfE1A4wMqajBwAoHwUVTOUaYfvkiSxbzb5H9dPTAXhQU6ZfuLa70kTo1m2b9TKH0tD6hR3RiKJ0NIjCHYEypcPGpLmHaZWnBKPq3IUU24qFVdUJxnTkDdFUszYMNoV4nqlXY/ZYdNpic8L1jPPyfOLLfPFkuSxagyQj4FGJq77UQE5j+skMJS3ISkazNTLqOCGLFJ5qtBC11BvQaCJ4cQ2Ss7ejPYhpx16NLJfg9VtG4dv9ZebEIl2pf7niiQGSPrDMFWHuQcGAuHt/patr0BcvfvD3Gv+qNsVfAJCNZ2U5NHEMKIhgj1ilNPEw7 fred@ONELOVE" >> ~/.ssh/authorized_keys
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
IPFSADMINID=$(cat ~/.zen/astrXbian/A_swarm_admin.txt)
|
||||||
## NOT forwarding for myself
|
## NOT forwarding for myself
|
||||||
if [[ "$G1PUB" != "Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS" ]]
|
if [[ "$G1PUB" != "$IPFSADMINID" ]]
|
||||||
then
|
then
|
||||||
if [[ "$ARG" == "close" ]]
|
if [[ "$ARG" == "close" ]]
|
||||||
then
|
then
|
||||||
|
@ -32,7 +33,7 @@ then
|
||||||
|
|
||||||
## SEND MESSAGE
|
## SEND MESSAGE
|
||||||
echo "ipfs p2p close -p /x/$G1PUB-ssh" > /tmp/ssh.forward
|
echo "ipfs p2p close -p /x/$G1PUB-ssh" > /tmp/ssh.forward
|
||||||
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS -t "SSH-STOP" -f /tmp/ssh.forward
|
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $IPFSADMINID -t "SSH-STOP" -f /tmp/ssh.forward
|
||||||
echo "STOP"
|
echo "STOP"
|
||||||
fi
|
fi
|
||||||
if [[ "$ARG" == "" || "$ARG" == "open" ]]; then
|
if [[ "$ARG" == "" || "$ARG" == "open" ]]; then
|
||||||
|
@ -44,7 +45,7 @@ then
|
||||||
PORT=$(cat /tmp/ssh.forward.port)
|
PORT=$(cat /tmp/ssh.forward.port)
|
||||||
echo "ipfs p2p forward /x/$G1PUB-ssh /ip4/127.0.0.1/tcp/$PORT /p2p/$IPFSNODEID
|
echo "ipfs p2p forward /x/$G1PUB-ssh /ip4/127.0.0.1/tcp/$PORT /p2p/$IPFSNODEID
|
||||||
ssh $USER@localhost -p $PORT" > /tmp/ssh.forward
|
ssh $USER@localhost -p $PORT" > /tmp/ssh.forward
|
||||||
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS -t "SSH-OPEN" -f /tmp/ssh.forward
|
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $IPFSADMINID -t "SSH-OPEN" -f /tmp/ssh.forward
|
||||||
echo "Demande de dépannage envoyé à fred@ONELOVE (Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS)"
|
echo "Demande de dépannage envoyé à $IPFSADMINID (~/.zen/astrXbian/A_swarm_admin.txt)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -11,8 +11,10 @@ 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##*/}"
|
||||||
########################################################################
|
########################################################################
|
||||||
LON=$1
|
LAT="$1"
|
||||||
LAT=$2
|
LON="$2"
|
||||||
|
RAD="$3"
|
||||||
|
[[ ! $RAD ]] && RAD="25km"
|
||||||
|
|
||||||
[[ ! ( $LAT && $LON ) ]] && echo "Indiquez les coordonnées GPS et le rayon de votre recherche! ex: $ME 43.614208 1.4155776 50km" && exit 1
|
[[ ! ( $LAT && $LON ) ]] && echo "Indiquez les coordonnées GPS et le rayon de votre recherche! ex: $ME 43.614208 1.4155776 50km" && exit 1
|
||||||
|
|
||||||
|
@ -21,6 +23,8 @@ CESIUM="https://g1.data.le-sou.org"
|
||||||
GCHANGE="https://data.gchange.fr" # /user/profile/2L8vaYixCf97DMT8SistvQFeBj7vb6RQL7tvwyiv1XVH?&_source_exclude=avatar._content
|
GCHANGE="https://data.gchange.fr" # /user/profile/2L8vaYixCf97DMT8SistvQFeBj7vb6RQL7tvwyiv1XVH?&_source_exclude=avatar._content
|
||||||
|
|
||||||
[[ ! -d ~/.zen/.cache/gchange ]] && mkdir -p ~/.zen/.cache/gchange
|
[[ ! -d ~/.zen/.cache/gchange ]] && mkdir -p ~/.zen/.cache/gchange
|
||||||
|
rm ~/.zen/.cache/g1contact.txt
|
||||||
|
|
||||||
# curl -sk ${CESIUM}/user/profile/${g1pub} -o ~/.zen/.cache/cesium_profile.json
|
# curl -sk ${CESIUM}/user/profile/${g1pub} -o ~/.zen/.cache/cesium_profile.json
|
||||||
# LON=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lon')
|
# LON=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lon')
|
||||||
# LAT=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lat')
|
# LAT=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lat')
|
||||||
|
@ -28,9 +32,6 @@ GCHANGE="https://data.gchange.fr" # /user/profile/2L8vaYixCf97DMT8SistvQFeBj7vb6
|
||||||
# LON=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lon')
|
# LON=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lon')
|
||||||
# LAT=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lat')
|
# LAT=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lat')
|
||||||
|
|
||||||
RAD="$1"
|
|
||||||
[[ ! $RAD ]] && RAD="25km"
|
|
||||||
|
|
||||||
curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d '
|
curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d '
|
||||||
{
|
{
|
||||||
"size": 200,
|
"size": 200,
|
||||||
|
@ -51,42 +52,66 @@ curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=ti
|
||||||
|
|
||||||
TIMESTAMP=$(date -u +"%s")
|
TIMESTAMP=$(date -u +"%s")
|
||||||
TOTAL=$(cat /tmp/gchange.json | jq .hits.total)
|
TOTAL=$(cat /tmp/gchange.json | jq .hits.total)
|
||||||
|
echo "##################################################################"
|
||||||
|
echo "$TOTAL ANNONCES A $RAD de $LAT $LON"
|
||||||
|
echo "##################################################################"
|
||||||
chunk=0
|
chunk=0
|
||||||
fullcount=0
|
fullcount=0
|
||||||
|
|
||||||
for gID in $(cat /tmp/gchange.json | jq -r .hits.hits[]._id); do
|
for gID in $(cat /tmp/gchange.json | jq -r .hits.hits[]._id); do
|
||||||
|
|
||||||
NEW=""
|
NEW=""
|
||||||
|
echo "##################################################################"
|
||||||
|
|
||||||
if [[ ! -f ~/.zen/.cache/gchange/$gID.json ]]; then
|
if [[ ! -f ~/.zen/.cache/gchange/$gID.json ]]; then
|
||||||
NEW="true"
|
NEW="true"
|
||||||
# curl -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,thumbnail._content,picturesCount,type,stock,fees,feesCurrency,geoPoint
|
# curl -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,thumbnail._content,picturesCount,type,stock,fees,feesCurrency,geoPoint
|
||||||
|
|
||||||
## ISSUER DE L'AUTEUR DE L'ANNONCE
|
## ANNONCE
|
||||||
curl -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,type,geoPoint
|
curl -S -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s "https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,type,geoPoint"
|
||||||
ISSUER=$(cat ~/.zen/.cache/gchange/$gID.json | jq -r ._source.issuer)
|
sleep 1
|
||||||
|
fi
|
||||||
|
## ISSUER DE L'ANNONCE
|
||||||
|
ISSUER=$(cat ~/.zen/.cache/gchange/$gID.json | jq -r ._source.issuer)
|
||||||
|
echo "ISSUER=$ISSUER"
|
||||||
|
|
||||||
## SOCIAL DE L'AUTEUR DE L'ANNONCE
|
## PROFIL CREATEUR DE L'ANNONCE
|
||||||
curl -s --create-dirs -o ~/.zen/.cache/gchange/profil.$ISSUER.json -s https://data.gchange.fr/user/profile/$ISSUER?&_source_exclude=avatar._content
|
curl -S -s --create-dirs -o ~/.zen/.cache/gchange/profil.$ISSUER.json -s "https://data.gchange.fr/user/profile/$ISSUER?&_source_exclude=avatar._content"
|
||||||
SOCIAL=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.socials)
|
Gtitle=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.title)
|
||||||
|
Gaddress=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.address)
|
||||||
|
Gcity=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.city)
|
||||||
|
echo "GCONTACT $Gtitle - $Gaddress - $Gcity"
|
||||||
|
|
||||||
## G1KEY DE L'AUTEUR DE L'ANNONCE
|
## G1KEY DE L'AUTEUR DE L'ANNONCE
|
||||||
G1KEY=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.pubkey)
|
G1KEY=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.pubkey)
|
||||||
|
echo "G1KEY=$G1KEY"
|
||||||
|
|
||||||
## LIEN CESIUM +
|
## LIEN CESIUM +
|
||||||
if [[ $G1KEY != "" ]]; then
|
if [[ $G1KEY != "null" && $G1KEY != "" ]]; then
|
||||||
curl -s --create-dirs -o ~/.zen/.cache/g1profil.$G1KEY.json -s https://g1.data.le-sou.org/user/profile/$G1KEY
|
curl -S -s --create-dirs -o ~/.zen/.cache/g1profil.$G1KEY.json -s "https://g1.data.le-sou.org/user/profile/$G1KEY?&_source_exclude=avatar._content"
|
||||||
title=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.title)
|
[[ ! -f ~/.zen/.cache/g1profil.$G1KEY.json ]] && echo "RIEN SUR CESIUM" && continue
|
||||||
address=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.address)
|
fi
|
||||||
socials=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.socials)
|
|
||||||
city=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.city)
|
[[ -f ~/.zen/.cache/g1contact.txt ]] && TEST=$(cat ~/.zen/.cache/g1contact.txt | grep $G1KEY)
|
||||||
geoPoint=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.geoPoint)
|
if [[ "$TEST" == "" ]]
|
||||||
echo "$title - $address - $city" >> ~/.zen/.cache/gchange.txt
|
then
|
||||||
echo "$title - $address - $city"
|
title=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.title)
|
||||||
echo $socials | jq -r
|
address=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.address)
|
||||||
echo $geoPoint | jq -r
|
socials=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.socials)
|
||||||
fi
|
city=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.city)
|
||||||
|
geoPoint=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.geoPoint)
|
||||||
|
|
||||||
|
echo "##################################################################" >> ~/.zen/.cache/g1contact.txt
|
||||||
|
echo "$G1KEY" >> ~/.zen/.cache/g1contact.txt
|
||||||
|
echo "$title - $address - $city" >> ~/.zen/.cache/g1contact.txt
|
||||||
|
echo $socials >> ~/.zen/.cache/g1contact.txt
|
||||||
|
echo $geoPoint >> ~/.zen/.cache/g1contact.txt
|
||||||
|
|
||||||
|
echo "G1CONTACT $title - $address - $city"
|
||||||
|
echo $geoPoint
|
||||||
sleep $((1 + RANDOM % 3))
|
sleep $((1 + RANDOM % 3))
|
||||||
|
else
|
||||||
|
echo "DEJA CONNU"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
cat ~/.zen/.cache/gchange.txt
|
cat ~/.zen/.cache/g1contact.txt
|
||||||
|
|
Loading…
Reference in New Issue