diff options
Diffstat (limited to 'bin/ak-data-expand')
-rwxr-xr-x | bin/ak-data-expand | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/bin/ak-data-expand b/bin/ak-data-expand index 862fa75..d13233d 100755 --- a/bin/ak-data-expand +++ b/bin/ak-data-expand @@ -5,94 +5,94 @@ then mkdir $AK_WORKDIR/ipfs fi logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -z "$1" ] && [ ! -z "$2" ] then echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Invalid hash format for $1" + logit "ERROR" "Invalid hash format for $1" exit 1 fi ak-ipfs-cat $1 > /dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while reading $1" + logit "ERROR" "Error while reading $1" exit 1 fi ak-ipfs-cat $1 | jq -M > /dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while parsing JSON for $1" + logit "ERROR" "Error while parsing JSON for $1" exit 1 fi ak-ipfs-cat $1 | jq | grep ipfs > /dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while extracting data from JSON for $1" + logit "ERROR" "Error while extracting data from JSON for $1" exit 1 fi DATA="$(ak-ipfs-cat $1 | jq | grep ipfs | sed -e 's/"ipfs": "//g; s/[",]//g; s/ //g')" if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while extracting data from JSON for $1" + logit "ERROR" "Error while extracting data from JSON for $1" exit 1 fi ak-ipfs-cat $1 | jq | grep detach > /dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while extracting data from JSON for $1" + logit "ERROR" "Error while extracting data from JSON for $1" exit 1 fi DETACH="$(ak-ipfs-cat $1 | jq | grep detach | sed -e 's/"detach": "//g; s/[",]//g; s/ //g')" if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while extracting data from JSON for $1" + logit "ERROR" "Error while extracting data from JSON for $1" exit 1 fi echo -n "$2" | grep -e 'Qm.\{44\}' >/dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Invalid hash format for $2" + logit "ERROR" "Invalid hash format for $2" exit 1 fi gpg="$2" ak-ipfs-get $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not get GPG key: $gpg" + logit "ERROR" "Could not get GPG key: $gpg" exit 1 fi gpg2 --homedir $AK_GPGHOME --import $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not import GPG key: $gpg" + logit "ERROR" "Could not import GPG key: $gpg" exit 1 fi ak-ipfs-get $DETACH > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while getting signature: $DETACH for data: $DATA" + logit "ERROR" "Error while getting signature: $DETACH for data: $DATA" exit 1 fi mv $DETACH $DATA.asc - logit "[INFO]" "Block signature downloaded" + logit "INFO" "Block signature downloaded" ak-ipfs-get $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while getting data: $DATA" + logit "ERROR" "Error while getting data: $DATA" exit 1 fi - logit "[INFO]" "Data downloaded: $DATA" + logit "INFO" "Data downloaded: $DATA" gpg2 --homedir $AK_GPGHOME --verify $DATA.asc $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while verifying signature for $DATA" + logit "ERROR" "Error while verifying signature for $DATA" exit 1 fi mv $DATA $AK_WORKDIR/ipfs - logit "[INFO]" "Block signature verified" + logit "INFO" "Block signature verified" echo -n '"data":"'$1'","'$1'":'$(ak-ipfs-cat $1|jq -M -c)',' exit 0 else |