Skip to content

Instantly share code, notes, and snippets.

@tak1827
Last active July 18, 2019 03:34
Show Gist options
  • Save tak1827/33404559007229d70b5d894286ef4b21 to your computer and use it in GitHub Desktop.
Save tak1827/33404559007229d70b5d894286ef4b21 to your computer and use it in GitHub Desktop.
Ipfs pinned check
#!/bin/sh
# **************************************************
# IPFS Pinning Checker
# **************************************************
# Constants
PINNING_FILE_PATH="./bancor_recent_trading_logs.txt"
PINNED_FILE_PATH="./pinned_list.txt"
PINNED_CHECK_RESULT_PATH="./pinned_check_result.txt"
######################
# Main
######################
echo "************* Start ${0##*/} *************"
# Read pinned list line by line
COUNT=1
while read line
do
hash=`echo $line | awk '{print $2}'`
# Retrieve fist line from ipfs
index=`ipfs cat -l 6 $hash | head -n 1`
# The first line should be equal to count
if [ $index = $COUNT ]; then
echo "OK ${COUNT} ${hash}" >> $PINNED_CHECK_RESULT_PATH
else
echo "NG!!! ${COUNT} ${hash}"
echo "NG ${COUNT} ${hash}" >> $PINNED_CHECK_RESULT_PATH
fi
COUNT=$((COUNT + 1))
done < $PINNED_FILE_PATH
echo "************* End ${0##*/} *************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment