astroport/zen/ipfs_TASK.sh

39 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 1.0
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
###########################################################################################
# ipfs_TASK.sh SYNC SWARM PEERS AND RUN TASKS
IPFSNODEID=$(ipfs id -f='<id>\n')
########################################################################
### SYNC IPFS SWARM PEERS
count=0
for id in $(ipfs swarm peers | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
echo "REFRESH ~/.zen/wallets_swarm/.$id ..."
rm -Rf ~/.zen/wallets_swarm/.$id
./timeout.sh -t 10 ipfs get --output=~/.zen/wallets_swarm/ /ipns/$id > /dev/null 2>&1
done
echo "~/.zen/wallets_swarm/ RENEW from $count peers .........FINISH!!!"
########################################################################
# MAKE LOCAL ~/.zen/wallets/.$IPFSNODEID/TASK/ directory
[[ ! -d ~/.zen/wallets/.$IPFSNODEID/TASK/ ]] && mkdir -p ~/.zen/wallets/.$IPFSNODEID/TASK/
### SEARCH FOR RECEIVED TASK .todo FROM SWARM
for todo in $(ls ~/.zen/wallets_swarm/.$IPFSNODEID/TASK/*.todo 2>/dev/null);
do
TODO=$(cat $todo)
CMD=$(echo $TODO | cut -d ':' -f 1)
SUB=$(echo $TODO | cut -d ':' -f 2)
ACTION=$(echo $TODO | cut -d ':' -f 3)
done
# ./ipfs_PUBLISH.sh