g1sms
This commit is contained in:
parent
c1fb80f68b
commit
c1134cf127
|
@ -1,40 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
# BACKUP G1sms+ current Devlt code and push it with NODE_G1AUTHFILE encryption to IPFS
|
||||
################################################################################
|
||||
## GET LATEST DEV $ROOT
|
||||
source ./init.sh
|
||||
source ./functions.sh
|
||||
now=$(date +%Y-%m-%d)
|
||||
dir=$(pwd | awk 'BEGIN { FS = "/" } ; {print $4}')
|
||||
cd ..
|
||||
|
||||
publish=$(cat "./$dir/_official")
|
||||
maillon=$(cat "./$dir/_chain")
|
||||
if [[ "$publish" == "" ]]; then lev="ipfs"; hash="$maillon"; else lev="ipns"; hash="$publish"; fi
|
||||
|
||||
su $YOU -c "ipfs get --output=./ /$lev/$hash"
|
||||
|
||||
if [[ -f "./CODE/G1sms+.latest.tgz" ]]; then
|
||||
echo "TODAY CODE FOUND... UNTAR in ls ./TODAY"
|
||||
mkdir -p ./TODAY
|
||||
cd TODAY
|
||||
tar xvzf ../CODE/G1sms+.latest.tgz
|
||||
# KEEP LOCAL NODE init.sh
|
||||
if [[ ! -f "./$dir/shell/init.sh" ]]; then echo "backup restore problem..."; exit; fi
|
||||
echo "REMOVE DEFAULT INIT..."
|
||||
rm -f ./$dir/shell/init.sh
|
||||
|
||||
echo "DIFFERENCES ENTRE LES 2 VERSIONS:"
|
||||
diff ./$dir/ ../$dir/
|
||||
|
||||
echo "VOULEZ VOUS METTRE A JOUR? Saisissez OUI"
|
||||
read QUOI
|
||||
if [[ "$QUOI" == "OUI" ]]; then sudo cp -Rf . ..; else echo "ANNULATION UPDATE"; exit; fi
|
||||
|
||||
fi
|
||||
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
################################################################################
|
||||
# CE FICHIER cron_MINUTE.sh EST EXECUTE TOUTES LES MINUTES
|
||||
# IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME
|
||||
################################################################################
|
||||
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
|
||||
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
|
||||
|
||||
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
|
||||
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||
cd $GPATH
|
||||
source ./init.sh
|
||||
source ./functions.sh
|
||||
|
||||
timebar=$(date +%H:%M)
|
||||
|
||||
##################################################################
|
||||
if [[ "$1" == "" ]]; then
|
||||
##################################################################
|
||||
echo "It is $timebar in the morning, or in the night? It depends on your day..."
|
||||
exit
|
||||
fi
|
||||
##################################################################
|
||||
|
||||
##################################################################
|
||||
if [[ "$1" == "PRINT" ]]; then
|
||||
##################################################################
|
||||
##################################################################
|
||||
# Refresh All peers SWARM Wallets.
|
||||
##################################################################
|
||||
ipfs_swarm_wallets_refresh "SIMPLE"
|
||||
|
||||
################################################################################
|
||||
# PRINT G1Tag PRINTED FROM ANOTHER NODE (TODO: Correct BAD Cypher KEY + BUG why last image png layers are not printed???)
|
||||
# CREATE and REMOVE rr.bin -> done.rr
|
||||
if [[ -d "~/.zen/ipfs_swarm/.$IPFSNODEID/PRINT/" ]]; then
|
||||
log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID"
|
||||
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/PRINT/
|
||||
|
||||
for qrrtag in ~/.zen/ipfs_swarm/.$IPFSNODEID/PRINT/*.bin; do
|
||||
rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1)
|
||||
if [[ ! -f "~/.zen/ipfs/.$IPFSNODEID/PRINT/done.$rr" ]]; then
|
||||
log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)"
|
||||
./natools.py decrypt -k "$NODE_G1AUTHFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png"
|
||||
log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)"
|
||||
brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin"
|
||||
log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)"
|
||||
brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0
|
||||
log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)"
|
||||
# INFORM PRINT DONE
|
||||
echo "OK" > ~/.zen/ipfs/.$IPFSNODEID/PRINT/done.$rr
|
||||
I=$(ipfs_node_wallets_add)
|
||||
else
|
||||
lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g )
|
||||
log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ~/.zen/ipfs/.$IPFSNODEID/PRINT/done.$rr"
|
||||
rm -f "~/.zen/ipfs/.$IPFSNODEID/PRINT/done.$rr"
|
||||
rm -f "${lqrrtag}"
|
||||
I=$(ipfs_node_wallets_add)
|
||||
fi
|
||||
done
|
||||
|
||||
log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE"
|
||||
for scan in ~/.zen/g1sms_wallets_swarm/.Qm*/PRINT/done.*; do
|
||||
lscan=$(echo $scan | sed s/_swarm//g )
|
||||
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
||||
lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
||||
log "__SUB:cron_MINUTE.sh: REMOVE ~/.zen/g1sms_wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)"
|
||||
rm -f ~/.zen/g1sms_wallets/.$lid/PRINT/$lrr.bin
|
||||
rm -f "${lscan}"
|
||||
I=$(ipfs_node_wallets_add)
|
||||
done
|
||||
|
||||
rm "/tmp/G1Tag.bin"
|
||||
rm "/tmp/G1Tag.png"
|
||||
fi
|
||||
fi
|
||||
##################################################################
|
||||
|
||||
##################################################################
|
||||
if [[ "$1" == "KALKUN" ]]; then
|
||||
##################################################################
|
||||
for number in ~/.zen/g1sms_wallets/*; do
|
||||
member=""
|
||||
phone=$(echo $number | cut -d '/' -f 3);
|
||||
if [[ -f $number/$phone.uidname ]]; then member=$(cat $number/$phone.uidname); fi
|
||||
if [[ ! $member ]]; then member=$phone; fi
|
||||
if [[ $phone && $member ]]; then add_contact $phone $member; log "__SUB:cron_MINUTE.sh: KALKUN add_contact $phone $member"; fi
|
||||
done
|
||||
fi
|
||||
##################################################################
|
||||
|
||||
##################################################################
|
||||
if [[ "$1" == "TAG" ]]; then
|
||||
##################################################################
|
||||
for tag in ./TAG/*; do
|
||||
echo $tag
|
||||
done
|
||||
fi
|
||||
##################################################################
|
|
@ -106,101 +106,6 @@ find /tmp -ctime +1 -type f -name "sms_SPAM_*" -exec rm -f '{}' \;
|
|||
}
|
||||
|
||||
|
||||
#################################################################################################################################
|
||||
function ipfs_swarm_wallets_refresh (){
|
||||
|
||||
# Refresh CURRENT NODE wallets STATUS
|
||||
I=$(ipfs_node_wallets_add)
|
||||
|
||||
# REFRESH SWARM MEMORY
|
||||
mkdir -p "~/.zen/g1sms_wallets_swarm"
|
||||
chown -R $YOU "~/.zen/g1sms_wallets_swarm"
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: REFRESHING SWARM $PHONE shared memory..."
|
||||
if [[ $PHONE ]]; then rm -Rf ~/.zen/g1sms_wallets_swarm/$PHONE; fi
|
||||
|
||||
# GET IPNS published wallets from ALL SWARM NODES / TODO: IF NODES MISSING, check ~/.zen/g1sms_wallets_swarm/.QmNODES...
|
||||
#log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=~/.zen/g1sms_wallets_swarm/ /ipns/$IPFSNODEID"
|
||||
su $YOU -c "ipfs get --output=~/.zen/g1sms_wallets_swarm/ /ipns/$IPFSNODEID"
|
||||
count=1
|
||||
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
|
||||
#for id in ~/.zen/g1sms_wallets/.Qm*/;
|
||||
for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
|
||||
do
|
||||
count=$((count+1))
|
||||
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=~/.zen/g1sms_wallets_swarm/ /ipns/$id"
|
||||
rm -Rf ~/.zen/g1sms_wallets_swarm/.$id
|
||||
./timeout.sh -t 20 su $YOU -c "ipfs get --output=~/.zen/g1sms_wallets_swarm/ /ipns/$id"
|
||||
done
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: ~/.zen/g1sms_wallets_swarm/ RENEW from $count peers .........OK!!!"
|
||||
|
||||
|
||||
############################################################################"
|
||||
# TREAT move_g1cents Tasks in ~/.zen/ipfs/.$IPFSNODEID
|
||||
# IF NODE find in ~/.zen/ipfs_swarm/.$IPFSNODEID/TASK directory && Have it's G1 Wallet already (for natools crypto)
|
||||
if [[ "$1" != "SIMPLE" && -d ~/.zen/ipfs_swarm/.$IPFSNODEID/TASK && -f "~/.zen/ipfs/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" ]]; then
|
||||
############################################################################"
|
||||
for task in $(ls ~/.zen/ipfs_swarm/.$IPFSNODEID/TASK/*.move_g1cents.*); # ~/.zen/ipfs/.$IPFSNODEID/TASK/$NANODATE.move_g1cents.$DESTPHONE.NODEPUB.crypt OR "done.$NANODATE" FILES
|
||||
do
|
||||
FTASK=$( echo $task | cut -d '/' -f 5 ) # "$NANODATE.move_g1cents.$DESTPHONE.NODEPUB.crypt"
|
||||
TNANO=$( echo $FTASK | cut -d '.' -f 1) # $NANODATE
|
||||
TTYPE=$( echo $FTASK | cut -d '.' -f 2) # move_g1cents
|
||||
TDEST=$( echo $FTASK | cut -d '.' -f 3) # $DESTPHONE
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) FOUND TASK $TNANO:$TTYPE:$TDEST "
|
||||
# MAKE LOCAL .$IPFSNODEID directory
|
||||
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TASK/
|
||||
# TODO: CHECK BETTER NOT DONE YET and $NANODATE > $TNANO (=> detect NODES writing in the future!!)
|
||||
if [[ ! -f "~/.zen/ipfs/.$IPFSNODEID/TASK/done.$TNANO" ]]; then # NOT DONE YET: NEW TASK!
|
||||
tdiff=$(bc -l <<< "$NANODATE - $TNANO")
|
||||
if [[ $tdiff -gt 0 ]]; then
|
||||
# GET BACK MY NODE G1 Wallet authfile from my LOCAL ~/.zen/g1sms_wallets
|
||||
echo "${GPGPASS}" | gpg -q -d --output "./NODEG1Wallet.authfile" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/ipfs/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg"
|
||||
# DECRYPT and CAT move_g1cents VALUE
|
||||
./natools.py decrypt -k "./NODEG1Wallet.authfile" -i "$task" -o "/tmp/move_g1cents.$TDEST"
|
||||
ZENVAL=$(cat "/tmp/move_g1cents.$TDEST")
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: tdiff=$tdiff .$IPFSNODEID G1 = ./NODEG1Wallet.authfile :decrypt: Found $ZENVAL Zen to ADD"
|
||||
rm -f "./NODEG1Wallet.authfile"
|
||||
if [[ $ZENVAL -gt 0 ]]; then
|
||||
curvalue=$(cat ~/.zen/g1sms_wallets/$TDEST/$TDEST.g1cents)
|
||||
newvalue=$(bc -l <<< "$curvalue + $ZENVAL")
|
||||
echo $newvalue > ~/.zen/g1sms_wallets/$TDEST/$TDEST.g1cents
|
||||
echo "OK.$tdiff" > ~/.zen/ipfs/.$IPFSNODEID/TASK/done.$TNANO
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) DONE! OPERATION: ($curvalue + $ZENVAL) = $newvalue Zen <=> ~/.zen/g1sms_wallets/$TDEST/$TDEST.g1cents:: OK"
|
||||
# REFRESH ~/.zen/g1sms_wallets and PUBLISH
|
||||
I=$(ipfs_node_wallets_add)
|
||||
else
|
||||
echo "KO.$tdiff" > ~/.zen/ipfs/.$IPFSNODEID/TASK/done.$TNANO
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ~/.zen/g1sms_wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||
I=$(ipfs_node_wallets_add)
|
||||
sms_SEND "$ADMINPHONE" "ADMIN! TASK ERROR: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ~/.zen/g1sms_wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||
fi
|
||||
else
|
||||
# TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish?
|
||||
echo "KO.$tdiff" > ~/.zen/ipfs/.$IPFSNODEID/TASK/done.$TNANO
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
|
||||
I=$(ipfs_node_wallets_add)
|
||||
sms_SEND "$ADMINPHONE" "ADMIN! .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: REMOVE OLD TASK MARKED AS DONE"
|
||||
for scan in ~/.zen/g1sms_wallets_swarm/.Qm*/TASK/done.*; do
|
||||
lscan=$(echo $scan | sed s/_swarm//g )
|
||||
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
||||
lnano=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
||||
if [[ "$lid" != "$IPFSNODEID" ]]; then
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: CLEANING done OLD TASK ${lscan} SENT to $lid ($lnano.bin)"
|
||||
rm -f ~/.zen/g1sms_wallets/.$lid/TASK/$lnano.*
|
||||
I=$(ipfs_node_wallets_add)
|
||||
fi
|
||||
done
|
||||
else
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID :: NO TASK ! "
|
||||
############################################################################"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#################################################################################################################################
|
||||
function ipfs_node_wallets_add (){
|
||||
|
@ -332,7 +237,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
|||
DABUIDF="~/.zen/g1sms_wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
|
||||
# GET CURRENT NODE UIDNA (default DABUID)
|
||||
NODEUIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/$IPFSNODEID.uidna")
|
||||
[[ $NODEUIDNA == "" ]] && NODEUIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/_uidna")
|
||||
[[ $NODEUIDNA == "" ]] && NODEUIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna")
|
||||
######################################################################
|
||||
# (NO PIN) = FIRST ACCOUNT: Create wallet
|
||||
if [ ! -f "$PINFILE" ]; then
|
||||
|
@ -344,6 +249,8 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
|||
#######################
|
||||
mkdir -p "~/.zen/g1sms_wallets/$PHONE/"
|
||||
PIN=$(./diceware.sh | xargs)
|
||||
|
||||
python3 $MY_PATH/tools/key_create_dunikey.py "$PHONE" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey
|
||||
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$PHONE" -password="$PIN")
|
||||
|
||||
# BACKUP authfile available to authfile or PIN owner (DOUBLON AVEC PIN) TEST
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
duniter.moul.re:443
|
||||
g1.duniter.fr:443
|
||||
g1.duniter.org:443
|
||||
g1.le-sou.org:443
|
||||
g1.monnaielibreoccitanie.org:443
|
||||
g1.presles.fr:443
|
|
@ -60,7 +60,7 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
|
|||
log "__SUB:initkeys.sh: NODE G1WALLET CESIUM: $NODE_UIDNA / $NODE_PIN CREATED..."
|
||||
|
||||
# WRITE NODE_UIDNA
|
||||
echo "$NODE_UIDNA" > "~/.zen/ipfs/.$IPFSNODEID/_uidna" ################# _uidna
|
||||
echo "$NODE_UIDNA" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna" ################# _uidna
|
||||
|
||||
############ SYSTEM MODIFY hosts & hostname ################
|
||||
# WRITE NODE uidna NAME TO /etc/hosts & .Qm*/_uidna file
|
||||
|
@ -69,24 +69,24 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
|
|||
############################################################
|
||||
|
||||
# BACKUP AUTHFILE FOR FOR SWARM USE (TODO: Refine Swarm, Node access): GIVES SMARM WITHDRAW ACTION
|
||||
./natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "~/.zen/ipfs/.$IPFSNODEID/_authfile.swarm.crypt"
|
||||
./natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_authfile.swarm.crypt"
|
||||
|
||||
echo $NODE_G1PUBKEY > "~/.zen/ipfs/.$IPFSNODEID/_pub" ################# _pub
|
||||
echo $IPFSNODEID > "~/.zen/ipfs/.$IPFSNODEID/_ipfsid" ################# _ipfsid
|
||||
echo $NODE_G1PUBKEY > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pub" ################# _pub
|
||||
echo $IPFSNODEID > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsid" ################# _ipfsid
|
||||
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY "
|
||||
|
||||
# BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt : GIVES SMARM NODE RESTORE ACTION
|
||||
./natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "~/.zen/ipfs/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
|
||||
log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ~/.zen/ipfs/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
|
||||
./natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsconfig.swarm.crypt"
|
||||
log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ipfsconfig.swarm.crypt"
|
||||
|
||||
# Cyper & Empty PIN
|
||||
echo "${NODE_PIN}" > "~/.zen/ipfs/.$IPFSNODEID/_pin" ################# _pin / _pin.node.crypt / _pin.gpg
|
||||
./natools.py encrypt -p $NODE_G1PUBKEY -i "~/.zen/ipfs/.$IPFSNODEID/_pin" -o "~/.zen/ipfs/.$IPFSNODEID/_pin.node.crypt"
|
||||
echo "${GPGPASS}" | gpg -q --output "~/.zen/ipfs/.$IPFSNODEID/_pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/ipfs/.$IPFSNODEID/_pin"
|
||||
echo "" > "~/.zen/ipfs/.$IPFSNODEID/_pin"
|
||||
echo "${NODE_PIN}" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin" ################# _pin / _pin.node.crypt / _pin.gpg
|
||||
./natools.py encrypt -p $NODE_G1PUBKEY -i "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin" -o "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin.node.crypt"
|
||||
echo "${GPGPASS}" | gpg -q --output "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin"
|
||||
echo "" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pin"
|
||||
|
||||
echo "314" > "~/.zen/ipfs/.$IPFSNODEID/_g1cents" ################# _g1cents
|
||||
echo $NANODATE > "~/.zen/ipfs/.$IPFSNODEID/_nanodate" ################# _nanodate
|
||||
echo "314" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1cents" ################# _g1cents
|
||||
echo $NANODATE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate" ################# _nanodate
|
||||
|
||||
# SILKAJ INIT G1 NODE WALLET
|
||||
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=3.24 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID" -y)
|
||||
|
@ -101,15 +101,15 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
|
|||
echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key
|
||||
fi
|
||||
|
||||
NODE_UIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/_uidna")
|
||||
NODE_UIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna")
|
||||
## INIT NODE G1 PUB & PRIV KEY
|
||||
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
|
||||
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"
|
||||
|
||||
##########################################################
|
||||
# MEMORIZE NODE NANODATE EXECUTION TIME (for ntpdate regular sync)
|
||||
if [[ -f ~/.zen/ipfs/.$IPFSNODEID/_nanodate ]]; then
|
||||
last=$(cat ~/.zen/ipfs/.$IPFSNODEID/_nanodate)
|
||||
if [[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate ]]; then
|
||||
last=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate)
|
||||
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
|
||||
# NODE TIME SYNC 600 milliards de nanosecondes = 600 s = 10 mn
|
||||
if [[ $timediff -gt 600000000000 ]]; then
|
||||
|
@ -117,32 +117,32 @@ if [[ -f ~/.zen/ipfs/.$IPFSNODEID/_nanodate ]]; then
|
|||
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
|
||||
export NANODATE=$(date -u +%s%N)
|
||||
fi
|
||||
echo $NANODATE > ~/.zen/ipfs/.$IPFSNODEID/_nanodate
|
||||
echo $NANODATE > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_nanodate
|
||||
fi
|
||||
|
||||
################################################################
|
||||
#INFORM ABOUT NODE CAPACITIES
|
||||
export NODEPUB=$(cat "~/.zen/ipfs/.$IPFSNODEID/_pub")
|
||||
export NODEPUB=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_pub")
|
||||
|
||||
## IS IT A SMS NODE (gammu-smsd is installed)??
|
||||
if [[ $G1SMS ]]; then
|
||||
echo $MASTERPHONE > "~/.zen/ipfs/.$IPFSNODEID/_sms"
|
||||
echo $MASTERPHONE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_sms"
|
||||
else
|
||||
if [ -f "~/.zen/ipfs/.$IPFSNODEID/_sms" ]; then rm -f "~/.zen/ipfs/.$IPFSNODEID/_sms"; fi
|
||||
if [ -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_sms" ]; then rm -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_sms"; fi
|
||||
fi
|
||||
|
||||
## IS THERE USB PRINTER CONNECTED?
|
||||
if [[ -e "/dev/usb/lp0" ]]; then
|
||||
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
|
||||
echo $ADRESSE > "~/.zen/ipfs/.$IPFSNODEID/_where"
|
||||
echo $ADRESSE > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_where"
|
||||
fi
|
||||
|
||||
## IS THERE SERIAL QR CODE READER CONNECTED?
|
||||
if [[ -e "/dev/ttyACM0" ]]; then
|
||||
log "G1CORE: SCAN G1Tag ACTIF .............."
|
||||
export G1TX="YES"
|
||||
echo "/dev/ttyACM0" > "~/.zen/ipfs/.$IPFSNODEID/_scan"
|
||||
echo "/dev/ttyACM0" > "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan"
|
||||
else
|
||||
if [ -f "~/.zen/ipfs/.$IPFSNODEID/_scan" ]; then rm -f "~/.zen/ipfs/.$IPFSNODEID/_scan"; fi
|
||||
if [ -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan" ]; then rm -f "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_scan"; fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
duniter.moul.re:443
|
||||
duniter.dethegeek.eu.org:443
|
||||
g1.presles.fr:443
|
||||
g1.duniter.fr:443
|
||||
monit.g1.nordstrom.duniter.org:443
|
||||
g1.le-sou.org:443
|
||||
g1.duniter.org:443
|
||||
g1.monnaielibreoccitanie.org:443
|
||||
follow.the.white-rabbit.net:443
|
||||
g1.acostey.fr:443
|
||||
duniter.acostey.fr:443
|
|
@ -1,30 +1,8 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# SWARM de développement G1sms+.
|
||||
# PUBKEY G1 DU SWARMMASTER: 8qs69HriAdytcCLzvQGJ15XBwpjAVFx8JoVM2ahue1y7
|
||||
# ipfs ls /ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif
|
||||
#
|
||||
# G1sms+ est totalement décentralisé! Il peut être fait de multiples SWARM de Services dont les codes évoluent de façon décentralisé.
|
||||
# Puis se mettent à jour autour des $ADMINPHONE par consensus d'utilisateurs ;)
|
||||
#
|
||||
# Log => tail -f /tmp/g1sms.log -n 200
|
||||
# gammu => tail -f /tmp/smsd.log -n 200
|
||||
#
|
||||
# 2 commands needed to make the ramdisk if planning to run from ramdisk to gain some speed
|
||||
# sudo mkdir /mnt/ramdisk
|
||||
# sudo mount -t tmpfs -o size=50m tmpfs /mnt/ramdisk
|
||||
#
|
||||
# Utiliser la commande ./search fournie pour fouiller dans le code, mais tout est ordonnancé d'ici, donc vous êtes au bon endroit pour commencer à farfouiller.
|
||||
###############################################################################
|
||||
# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE
|
||||
# PHYSIQUE ET INFORMATIQUE DE VOTRE NOEUD ET NE PAS INTRODUIRE DE CODE MALVEILLANT
|
||||
# DANS LE GROUPE SI VOUS ETES AMENES A EN PROPOSER UNE MISE A JOUR.
|
||||
# UNE COMMISSION EST PERCU SUR CERTAINS TRANSFERTS.
|
||||
# ELLE EST PROVISION EN CAS DE FRAUDE ET SA REATRIBUTION POURRA EVOLUER...
|
||||
#
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Author: Fred (support@qo-op.com) & poka
|
||||
# Version: 0.1
|
||||
# License: GPL (http://www.google.com/search?q=GPL)
|
||||
# License: AGPL (http://www.google.com/search?q=AGPL)
|
||||
################################################################################
|
||||
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
|
@ -35,8 +13,10 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|||
|
||||
export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||
cd $MY_PATH
|
||||
source $MY_PATH/shell/init.sh
|
||||
source $MY_PATH/shell/functions.sh
|
||||
source ./init.sh
|
||||
source ./functions.sh
|
||||
|
||||
security
|
||||
|
||||
##################################################################
|
||||
# Get global variables from gammu-smsd
|
||||
|
@ -45,26 +25,6 @@ TEXT="$SMS_1_TEXT"
|
|||
# Extract Received Command (PUBLISH OFFICIALS in file sms_AIDE.sh)
|
||||
CMD=$(echo "$TEXT" | awk '{print toupper($1)}')
|
||||
|
||||
log "##########################################################################################"
|
||||
log "#############################################"
|
||||
log "#############################################"
|
||||
log "$(date)"
|
||||
log "SMS received $PHONE $TEXT"
|
||||
log "#############################################"
|
||||
log "NODE: ALL WALLETS: ipfs ls /ipns/$IPFSNODEID"
|
||||
log "NODE: G1wallet: cat ~/.zen/ipfs/.$IPFSNODEID/NODE.pub"
|
||||
log "#############################################"
|
||||
|
||||
##################################################################
|
||||
# BASIC SECURITY & ANTI SPAM
|
||||
##################################################################
|
||||
security
|
||||
|
||||
##################################################################
|
||||
# Refresh All peers SWARM Wallets.
|
||||
##################################################################
|
||||
ipfs_swarm_wallets_refresh
|
||||
|
||||
##################################################################
|
||||
# Check if PHONE is already registred in G1sms+ SWARM
|
||||
##################################################################
|
||||
|
|
|
@ -21,7 +21,7 @@ source ./functions.sh
|
|||
##############################################
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||
NODE_UIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/_uidna")
|
||||
NODE_UIDNA=$(cat "~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna")
|
||||
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
|
|
|
@ -15,86 +15,9 @@ ipfsnodeid=$(ipfs id -f='<id>\n')
|
|||
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
|
||||
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||
|
||||
CESIUM="https://g1.data.le-sou.org"
|
||||
# ipfs files ls /nextcloud
|
||||
# ipfs files stat /nextcloud/filename
|
||||
|
||||
curl -sk ${CESIUM}/user/profile/${g1pub} -o ~/.zen/cache/cesium_profile.json
|
||||
LON=$(cat ~/.zen/cache/cesium_profile.json | jq '._source.geoPoint.lon')
|
||||
LAT=$(cat ~/.zen/cache/cesium_profile.json | jq '._source.geoPoint.lat')
|
||||
|
||||
RAD="$1"
|
||||
[[ ! $RAD ]] && RAD="10km"
|
||||
|
||||
if [[ "$LON" != "null" ]]; then
|
||||
curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d '
|
||||
{
|
||||
"size": 200,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [{
|
||||
"geo_distance": {
|
||||
"distance": "'$RAD'",
|
||||
"geoPoint": {
|
||||
"lat": '$LAT',
|
||||
"lon": '$LON'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}' > /tmp/gchange.json || exit 1
|
||||
else
|
||||
echo "Aucune coordonnées geoPoint pour $g1pub" && exit 1
|
||||
fi
|
||||
TIMEBEFORE=$(date -u --date="-$DELAY" +"%s")
|
||||
TIMESTAMP=$(date -u +"%s")
|
||||
TOTAL=$(cat /tmp/gchange.json | jq .hits.total)
|
||||
echo 'tail -f ~/.zen/cache/gchange.txt'
|
||||
echo '# #GCHANGE-Market' > ~/.zen/cache/gchange.txt
|
||||
echo "Le profil géolocalisé de ce [portefeuille](https://demo.cesium.app/#/app/wot/$g1pub/)" >> ~/.zen/cache/gchange.txt
|
||||
echo "reçoit les annonces [situées dans un rayon de $RAD](https://www.openstreetmap.org/#map=10/$LAT/$LON) " >> ~/.zen/cache/gchange.txt
|
||||
chunk=0
|
||||
fullcount=0
|
||||
|
||||
DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh)
|
||||
DUNITERURL="https://$DUNITERNODE"
|
||||
LASTDU=$(curl -s ${DUNITERURL}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1);
|
||||
[[ $LASTDU != "" ]] && LASTDU=$(curl -s ${DUNITERURL}/blockchain/block/${LASTDU} | jq '.dividend')
|
||||
echo "DU = $LASTDU G1"
|
||||
|
||||
for gID in $(cat /tmp/gchange.json | jq -r .hits.hits[]._id); do
|
||||
|
||||
NEW=""
|
||||
|
||||
#[[ ! -f ~/.zen/cache/gchange/$gID.json ]] &&
|
||||
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 \
|
||||
&& sleep $((1 + RANDOM % 3))
|
||||
|
||||
type=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.type)
|
||||
# [[ $type == "need" ]] && continue
|
||||
creationTime=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.creationTime)
|
||||
title=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.title)
|
||||
|
||||
currency=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.currency)
|
||||
price=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.price)
|
||||
|
||||
categoryname=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.category.name)
|
||||
|
||||
[[ $price == null ]] && price="0"
|
||||
[[ $currency == "g1" ]] && love=$(bc -l <<< "scale=2; $price / $LASTDU * 100") || love="?.??"
|
||||
love="$love LOVE"
|
||||
price=$(bc -l <<< "scale=2; $price / 100")
|
||||
|
||||
fullcount=$((fullcount+1)) && echo "DEBUG : $fullcount - $type - $price $currency - $title "
|
||||
[[ $price == "0" ]] && love="OFFERT !?" && price="A débattre "
|
||||
|
||||
|
||||
[[ $NEW == "true" ]] \
|
||||
&& echo "- [$title](https://data.gchange.fr/market/record/$gID/_share) :heart: $love" >> ~/.zen/cache/gchange.txt \
|
||||
&& chunk=$((chunk+1)) && echo $chunk
|
||||
|
||||
done
|
||||
echo "$chunk nouvelles annonces ($TOTAL)" >> ~/.zen/cache/gchange.txt
|
||||
|
||||
## LOG INTO SSB ??? TODO
|
||||
# sbotc publish '{"type":"zenlog","text":"'"$ME"'"}'
|
||||
|
|
Loading…
Reference in New Issue