aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-24 18:29:57 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-24 18:29:57 +0300
commit00f3e970c39adb28e24a6ac0cdbfffc8bac8ac67 (patch)
tree986ffc6255442aa8e11fa66e636ad06a79ed2cd7 /lib
parentec93522a295b9ee74f7fa8cbbd7752f2c1ef6ce6 (diff)
downloadarching-kaos-tools-00f3e970c39adb28e24a6ac0cdbfffc8bac8ac67.tar.gz
arching-kaos-tools-00f3e970c39adb28e24a6ac0cdbfffc8bac8ac67.tar.bz2
arching-kaos-tools-00f3e970c39adb28e24a6ac0cdbfffc8bac8ac67.zip
fixes
Diffstat (limited to 'lib')
-rwxr-xr-xlib/_ak_gpg1
-rwxr-xr-xlib/_ak_ipfs7
-rwxr-xr-xlib/_ak_zblock15
3 files changed, 22 insertions, 1 deletions
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
index bd949f9..af65fcb 100755
--- a/lib/_ak_gpg
+++ b/lib/_ak_gpg
@@ -99,6 +99,7 @@ _ak_gpg_sign_detached(){
then
_ak_gpg --detach-sign --sign-with $AK_FINGERPRINT --armor --output $1 $2
else
+ _ak_log_error "Not enough arguments"
exit 1
fi
}
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs
index 2adb8ce..db0019c 100755
--- a/lib/_ak_ipfs
+++ b/lib/_ak_ipfs
@@ -9,6 +9,11 @@ fi
_ak_ipfs(){
export IPFS_PATH=$AK_IPFS_REPO; ipfs $*
+ if [ $? -ne 0 ]
+ then
+ _ak_log_error "Some error occured when running: ipfs $*"
+ exit 1
+ fi
}
_ak_ipfs_daemon(){
@@ -41,6 +46,7 @@ _ak_ipfs_scanner(){
_ak_ipfs_get_peers
if [ $? -ne 0 ]
then
+ _ak_log_error "Failed to get IPFS peers"
exit 1
fi
fi
@@ -351,6 +357,7 @@ _ak_ipns_resolve(){
echo -n $rsld | sed -e 's/\/ipfs\///'
_ak_log_info "Resolved $1 to $rsld"
else
+ _ak_log_error "No argument given to resolve"
exit 1
fi
}
diff --git a/lib/_ak_zblock b/lib/_ak_zblock
index 817a19e..73f5f9e 100755
--- a/lib/_ak_zblock
+++ b/lib/_ak_zblock
@@ -583,6 +583,11 @@ _ak_zblock_repack(){
fi
data="$(_ak_zblock_show $zblock_to_repack | jq -r '.data')"
+ if [ ! -f $AK_IPFS_ARTIFACTS/$data ]
+ then
+ _ak_log_error "$data file doesn't exist"
+ exit 1
+ fi
_ak_log_info "We are repacking $ACTION with content $MESSAGE at $zblock_to_repack_at"
@@ -591,17 +596,21 @@ _ak_zblock_repack(){
# We create a detached and armor signature of it
MESSAGE_SIGN_FILE="$data.asc"
_ak_gpg_sign_detached $MESSAGE_SIGN_FILE $AK_IPFS_ARTIFACTS/$data
+ _ak_log_debug "Signature made for $data"
# We add the signature to IPFS
MESSAGE_SIGNATURE=$(_ak_ipfs_add $MESSAGE_SIGN_FILE)
+ _ak_log_debug "Hash made for $data: $MESSAGE_SIGNATURE"
# We will be using our public key also to put it in the block later
KEY="self.pub"
_ak_gpg_key_self_export $KEY
GPG_PUB_KEY=$(_ak_ipfs_add $KEY)
+ _ak_log_debug "Key: $GPG_PUB_KEY"
# Acquire last block of information, to chain this one with previous posted
PREVIOUS="$zblock_to_repack_at"
+ _ak_log_debug "Previous: $PREVIOUS"
# We create a block of json like this:
printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' $(date -u +%s) $ACTION $MESSAGE_HASH $MESSAGE_SIGNATURE $GPG_PUB_KEY $PREVIOUS > block
@@ -609,12 +618,15 @@ _ak_zblock_repack(){
BLOCK_SIG=$BLOCK".asc"
# We have a block now, so we sign it
_ak_gpg_sign_detached $BLOCK_SIG $BLOCK
+ _ak_log_debug "Signature made for block"
# We now add the signature to IPFS
BLOCK_SIGNATURE=$(_ak_ipfs_add $BLOCK_SIG)
+ _ak_log_debug "Block signature hash: $BLOCK_SIGNATURE"
# We also add the block!
BLOCK=$(_ak_ipfs_add $BLOCK)
+ _ak_log_debug "Block hash: $BLOCK"
# So we now do the think almost again
printf '{"block":"%s","block_signature":"%s"}' $BLOCK $BLOCK_SIGNATURE > zblock
@@ -622,13 +634,14 @@ _ak_zblock_repack(){
# and we add it on IPFS
ZBLOCK=$(_ak_ipfs_add $ZBL)
echo $ZBLOCK
+ _ak_log_debug "Zblock hash: $ZBLOCK"
# cat $PWD/zblock | jq -M
# Optional or extending with
# python send_as_ak_tx $ZBLOCK
# or for "offline" use
echo $ZBLOCK > $AK_ZLATEST
- _ak_ipfs_name_publish --key=zchain $ZBLOCK > /dev/null 2>&1
+ _ak_ipfs_name_publish zchain /ipfs/$ZBLOCK #> /dev/null 2>&1
if [ $? -ne 0 ]
then
_ak_log_error "Failed publishing ZBLOCK: $ZBLOCK"