From 4217dc0560bf40b4fa7ae6a6f964bd56b418712e Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 14 Jun 2024 22:36:12 +0300 Subject: Refactoring --- bin/ak-data-expand | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'bin/ak-data-expand') diff --git a/bin/ak-data-expand b/bin/ak-data-expand index 8ee54c9..be51d18 100755 --- a/bin/ak-data-expand +++ b/bin/ak-data-expand @@ -14,87 +14,87 @@ then echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null if [ "$?" -ne 0 ] then - logit "ERROR" "Invalid hash format for $1" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_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" + _ak_log_error "Could not get GPG key: $gpg" exit 1 fi _ak_gpg_key_import_from_file $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Could not import GPG key: $gpg" + _ak_log_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" + _ak_log_error "Error while getting signature: $DETACH for data: $DATA" exit 1 fi mv $DETACH $DATA.asc - logit "INFO" "Block signature downloaded" + _ak_log_info "Block signature downloaded" _ak_ipfs_get $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Error while getting data: $DATA" + _ak_log_error "Error while getting data: $DATA" exit 1 fi - logit "INFO" "Data downloaded: $DATA" + _ak_log_info "Data downloaded: $DATA" _ak_gpg_verify_signature $DATA.asc $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Error while verifying signature for $DATA" + _ak_log_error "Error while verifying signature for $DATA" exit 1 fi mv $DATA $AK_WORKDIR/ipfs - logit "INFO" "Block signature verified" + _ak_log_info "Block signature verified" echo -n '"data":"'$1'","'$1'":'$(_ak_ipfs_cat $1|jq -M -c)',' exit 0 else -- cgit v1.2.3