You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.9 KiB

#!/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)
# SEARCH FOR NEW TASK OTHER NODE "todo.timestamp"
echo "REWRITING AND CHECK NEDDED"
exit 1
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 2 ) # $NANODATE
echo "FOUND TASK FOR ME ($IPFSNODEID) : $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
# todo.NANODATE is from past: OK. DO IT
echo "DOING it...."
chmod +x /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/TASK/todo.$TNANO
cat /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/TASK/todo.$TNANO
echo "WRITE todo RESULT in done.$TNANO"
else
# TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish?
echo "KO.$tdiff" > /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/done.$TNANO
echo " .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
fi
fi
done
echo "REMOVE OLD TASK MARKED AS DONE"
for scan in /home/$YOU/.zen/ipfs_swarm/.12D3KooW*/TASK/done.*; do
lscan=$(echo $scan | sed s/_swarm//g ) ## Remove _swarm
lid=$(echo $scan | cut -d '/' -f 6 | cut -d '.' -f 2 ) ## Get matching IPFSNODEID
lnano=$(echo $scan | cut -d '/' -f 8 | cut -d '.' -f 2 ) ## Get done timestamp
if [[ "$lid" != "$IPFSNODEID" ]]; then
echo "CLEANING done OLD TASK ${lscan} SENT to $lid ($lnano.bin)"
rm -f ./wallets/.$lid/TASK/todo.$lnano
fi
done
else
echo ".$IPFSNODEID :: NO TASK ! "
############################################################################"
fi