aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/enter47
1 files changed, 45 insertions, 2 deletions
diff --git a/bin/enter b/bin/enter
index 74d1bcc..4bb7ede 100755
--- a/bin/enter
+++ b/bin/enter
@@ -137,7 +137,33 @@ do
# We concatenate the zblock's contents, pipe them through filter
# json2bash and output them to tmp-file
ipfs cat $zblock | json2bash > $TEMPASSIN/tmp-zblock
- logthis "[INFO]" "ZBLOCK $zblock READ"
+ if [ "$?" == 0 ]
+ then
+ logthis "[INFO]" "ZBLOCK $zblock READ"
+ else
+ logthis "[ERROR]" "ZBLOCK $zblock READ failed"
+ exit 1
+ fi
+
+ # Be sure that there are the expected values
+ # We need 'block' and 'block_signature' inside a 'zblock'
+ # Exit if any is missing
+ grep -e 'block_signature' $TEMPASSIN/tmp-zblock > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logthis "[INFO]" "ZBLOCK $zblock has block_signature"
+ else
+ logthis "[ERROR]" "ZBLOCK $zblock has no block_signature"
+ exit 1
+ fi
+ grep -e 'block=' $TEMPASSIN/tmp-zblock > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logthis "[INFO]" "ZBLOCK $zblock has block"
+ else
+ logthis "[ERROR]" "ZBLOCK $zblock has no block"
+ exit 1
+ fi
# Supposingly you are on a safe environment and you only have
# access to your chain, I would consider mild secure to source
@@ -150,6 +176,23 @@ do
# BLOCKS
echo '"block":"'$block'",'
ipfs cat $block | json2bash > $TEMPASSIN/tmp-block
+ if [ "$?" == 0 ]
+ then
+ logthis "[INFO]" "BLOCK $block READ"
+ else
+ logthis "[ERROR]" "BLOCK $block READ failed"
+ exit 1
+ fi
+
+ grep -e 'timestamp' -e 'gpg' -e 'data' -e 'action' -e 'detach' -e 'previous' $TEMPASSIN/tmp-block > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logthis "[INFO]" "BLOCK $block is a block"
+ else
+ logthis "[ERROR]" "BLOCK $block is NOT a valid block"
+ exit 1
+ fi
+
source $TEMPASSIN/tmp-block
logthis "[INFO]" "BLOCK $block SOURCED"
touch $BLOCKDIR/$block
@@ -184,7 +227,7 @@ do
logthis "[ERROR]" "Could not get GPG key: $gpg ."
exit 1
fi
- ipfs get $block_signature > /dev/null 2>&1
+ ipfs get $block_signature > /dev/null 2>&1
if [ "$?" == 0 ]
then
mv $block_signature $block.asc