ipfs task todo/done system + sbotc basic dialog
This commit is contained in:
parent
afd7c29b7c
commit
1d709d2c38
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
########################################################################
|
||||
# AJAX REQUEST TRACKER : ASTROPORT ON BOARDING
|
||||
# GETTING : PHONE + PARRAIN + NAISSANCE
|
||||
#
|
||||
# DataFlow : index.html + ajaxform.js + zen_loveland_entrance.php
|
||||
########################################################################
|
||||
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);
|
||||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||
NANODATE=$(date -u +%s%N)
|
||||
|
||||
if [[ -d /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/TASK ]]; then
|
||||
############################################################################"
|
||||
for task in $( ls /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/TASK/todo.*); # "done.$NANODATE" FILES
|
||||
do
|
||||
FTASK=$( echo $task | cut -d '/' -f 8 ) # todo.$NANODATE
|
||||
TNANO=$( echo $FTASK | cut -d '.' -f 1 ) # $NANODATE
|
||||
echo " .$IPFSNODEID FOUND TASK : $FTASK "
|
||||
# MAKE LOCAL .$IPFSNODEID directory
|
||||
mkdir -p /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/
|
||||
# TODO: CHECK BETTER NOT DONE YET and $NANODATE > $TNANO (=> detect NODES writing in the future!!)
|
||||
if [[ ! -f /home/$YOU/.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 ./wallets
|
||||
echo "${GPGPASS}" | gpg -q -d --output "./NODEG1Wallet.authfile" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg"
|
||||
# DECRYPT and CAT move_g1cents VALUE
|
||||
./shell/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 ./wallets/$TDEST/$TDEST.g1cents)
|
||||
newvalue=$(bc -l <<< "$curvalue + $ZENVAL")
|
||||
echo $newvalue > ./wallets/$TDEST/$TDEST.g1cents
|
||||
echo "OK.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) DONE! OPERATION: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents:: OK"
|
||||
# REFRESH ./wallets and PUBLISH
|
||||
I=$(ipfs_node_wallets_add)
|
||||
else
|
||||
echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||
I=$(ipfs_node_wallets_add)
|
||||
sms_SEND "$ADMINPHONE" "ADMIN! TASK ERROR: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO"
|
||||
fi
|
||||
else
|
||||
# TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish?
|
||||
echo "KO.$tdiff" > ./wallets/.$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 ./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 ./wallets/.$lid/TASK/$lnano.*
|
||||
I=$(ipfs_node_wallets_add)
|
||||
fi
|
||||
done
|
||||
else
|
||||
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID :: NO TASK ! "
|
||||
############################################################################"
|
||||
fi
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
# Author @f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519
|
||||
|
||||
invite="${1?invite}"
|
||||
code="${invite##*~}"
|
||||
addr="${invite%%~*}"
|
||||
feed="${addr##*:}"
|
||||
hostname="${addr%:*}"
|
||||
host="${hostname%:*}"
|
||||
port="${hostname##*:}"
|
||||
|
||||
out="$(sbotc -s "$host" -p "$port" -k "$feed" -K "$code" -t async invite.use {} 2>&1)"
|
||||
if echo "$out" | grep -q 'feed to follow is missing'
|
||||
then
|
||||
echo success
|
||||
elif echo "$out" | grep -q 'method:invite,use is not in list of allowed methods'
|
||||
then
|
||||
echo invalid/expired
|
||||
exit 1
|
||||
else
|
||||
echo fail
|
||||
echo "$out"
|
||||
echo trying another method:
|
||||
sbotc -s "$host" -p "$port" -k "$feed" -K "$code" -t source blobs.get ''
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
#recps='@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519 @5XaVcAJ5DklwuuIkjGz4lwm2rOnMHHovhNg7BFFnyJ8=.ed25519'
|
||||
recps=$1
|
||||
file=$2
|
||||
|
||||
name=${file##*/}
|
||||
link="$(sblob encrypt "$file")"
|
||||
type="$(file -b --mime-type "$file")"
|
||||
id=${link%?unbox=*}
|
||||
key=${link#*?unbox=}
|
||||
size="$(sbotc -e blobs.size "$id")"
|
||||
recps_array="[$(for recp in $recps; do printf '"%s"\n' "$recp"; done | paste -sd,)]"
|
||||
sbotc private.publish '{"type":"post","text":"['"$name"']('"$link"')","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'","query":{"unbox":"'"$key"'"}}],"recps":'"$recps_array"'}' "$recps_array"
|
||||
|
Loading…
Reference in New Issue