aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-data-expand
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2022-10-31 04:57:28 +0200
committerkaotisk <kaotisk@arching-kaos.org>2022-10-31 04:57:28 +0200
commit099326c77bf347a056f3168b800592675087643a (patch)
treee4da974ad92e4d09c04b047b5109342ae2bf6ce2 /bin/ak-data-expand
parent06c1e6bf576bd36f8fde0b5be6200c79a387cfa8 (diff)
downloadarching-kaos-tools-099326c77bf347a056f3168b800592675087643a.tar.gz
arching-kaos-tools-099326c77bf347a056f3168b800592675087643a.tar.bz2
arching-kaos-tools-099326c77bf347a056f3168b800592675087643a.zip
Updated the way to expand the data part of each block
Diffstat (limited to 'bin/ak-data-expand')
-rwxr-xr-xbin/ak-data-expand101
1 files changed, 101 insertions, 0 deletions
diff --git a/bin/ak-data-expand b/bin/ak-data-expand
new file mode 100755
index 0000000..25e4295
--- /dev/null
+++ b/bin/ak-data-expand
@@ -0,0 +1,101 @@
+#!/bin/bash
+PROGRAM="$(basename $0)"
+logit(){
+ logthis "<$PROGRAM>" "$1" "$2"
+}
+if [ ! -z "$1" ] && [ ! -z "$2" ]
+then
+ echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null
+ if [ "$?" == 0 ]
+ then
+ ipfs --timeout=10s cat $1 > /dev/null
+ if [ "$?" == 0 ]
+ then
+ ipfs --timeout=10s cat $1 | json_pp > /dev/null
+ if [ "$?" == 0 ]
+ then
+ ipfs --timeout=10s cat $1 | jq | grep ipfs > /dev/null
+ if [ "$?" == 0 ]
+ then
+ DATA="$(ipfs --timeout=10s cat $1 | jq | grep ipfs | sed -e 's/"ipfs": "//g; s/[",]//g; s/ //g')"
+ if [ "$?" == 0 ]
+ then
+ ipfs --timeout=10s cat $1 | jq | grep detach > /dev/null
+ if [ "$?" == 0 ]
+ then
+ DETACH="$(ipfs --timeout=10s cat $1 | jq | grep detach | sed -e 's/"detach": "//g; s/[",]//g; s/ //g')"
+ if [ "$?" == 0 ]
+ then
+ echo -n "$2" | grep -e 'Qm.\{44\}' >/dev/null
+ if [ "$?" == 0 ]
+ then
+ gpg="$2"
+ ipfs --timeout=10s get $gpg > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ gpg2 --import $gpg > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logit "[GPG]" "$gpg imported."
+ else
+ logit "[ERROR]" "Could not import GPG key: $gpg ."
+ exit 1
+ fi
+ else
+ logit "[ERROR]" "Could not get GPG key: $gpg ."
+ exit 1
+ fi
+ ipfs --timeout=10s get $DETACH > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ mv $DETACH $DATA.asc
+ logit "[INFO]" "Block signature downloaded"
+ else
+ logit "[ERROR]" "Error while getting $DETACH for $DATA"
+ exit 1
+ fi
+ ipfs --timeout=10s get $DATA > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logit "[INFO]" "Downloaded $DATA."
+ else
+ logit "[ERROR]" "Could not get $DATA"
+ exit 1
+ fi
+ gpg2 --verify $DATA.asc > /dev/null 2>&1
+ if [ "$?" == 0 ]
+ then
+ logit "[GPG]" "$gpg signature of $DATA is verified."
+ else
+ logit "[ERROR]" "Could not verify $DATA with GPG key $gpg."
+ exit 1
+ fi
+ echo '"'$1'":{"ipfs":"'$DATA'","detach":"'$DETACH'"},'
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+ else
+ echo "Crap! Thanks though"
+ fi
+else
+ echo "Useless without a thing to do."
+
+fi