aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-05 00:32:55 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-05 00:32:55 +0300
commit681358adcfc8d1471ca53c3af246bf80a885ef98 (patch)
tree1b339d01f5ed5bee99c5c1be4403a6d23b7c05c4 /bin
parentc0dbfc8dc7cf7af278de1d233d87ffbe481ba704 (diff)
downloadarching-kaos-tools-681358adcfc8d1471ca53c3af246bf80a885ef98.tar.gz
arching-kaos-tools-681358adcfc8d1471ca53c3af246bf80a885ef98.tar.bz2
arching-kaos-tools-681358adcfc8d1471ca53c3af246bf80a885ef98.zip
Refactoring
- Edited log messages and types - IPFS `cat` is now calling `get` which in turn searches for already gotten file, otherwise fetches it. - ak-data-expand is now a function of _ak_zblock lib (_ak_data_expand) - Removed ak-sm-hash-to-path as it lives in _ak_fs lib now - Removed _ak_title_description and _ak_help from ak in favor of _ak_usage - Tweaks around native FS over IPFS strategy Note that we are preparing the ground for migration to AKFS as well
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak9
-rwxr-xr-xbin/ak-data-expand104
-rwxr-xr-xbin/ak-sm-hash-to-path41
3 files changed, 7 insertions, 147 deletions
diff --git a/bin/ak b/bin/ak
index 92bf097..7ca3f3c 100755
--- a/bin/ak
+++ b/bin/ak
@@ -42,13 +42,18 @@ if [ $# -eq 1 ]
then
case "$1" in
-h|--help)
- _ak_title_description
- _ak_help
+ _ak_usage
exit 1
;;
esac
fi
+if [ ! -n "$(echo -n $1 | sed 's/[0-9]//g')" ] && [ "$(( $(echo -n $1 | xxd -p) - 2100))" == "1337" ]
+then
+ AK_DEBUG="no"
+ echo -n efb8bbe294b3e383863de4b880 | xxd -r -p
+fi
+
subcmd="$(echo $* | sed -e 's/ /-/g')"
# Add functionality for separate modules directory
diff --git a/bin/ak-data-expand b/bin/ak-data-expand
deleted file mode 100755
index 09b5377..0000000
--- a/bin/ak-data-expand
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/bash
-PROGRAM="$(basename $0)"
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_ipfs
-source $AK_LIBDIR/_ak_gpg
-
-if [ ! -d $AK_WORKDIR/ipfs ]
-then
- mkdir $AK_WORKDIR/ipfs
-fi
-
-if [ ! -z $1 ] && [ ! -z $2 ]
-then
- echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null
- if [ $? -ne 0 ]
- then
- _ak_log_error "Invalid hash format for $1"
- exit 1
- fi
- _ak_ipfs_cat $1 > /dev/null
- if [ $? -ne 0 ]
- then
- _ak_log_error "Error while reading $1"
- exit 1
- fi
- _ak_ipfs_cat $1 | jq -M > /dev/null
- if [ $? -ne 0 ]
- then
- _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
- _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
- _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
- _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
- _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
- _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
- _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
- _ak_log_error "Could not import GPG key: $gpg"
- exit 1
- fi
- _ak_ipfs_get $DETACH > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- _ak_log_error "Error while getting signature: $DETACH for data: $DATA"
- exit 1
- fi
- mv $DETACH $DATA.asc
- _ak_log_info "Block signature downloaded"
- _ak_ipfs_get $DATA > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- _ak_log_error "Error while getting data: $DATA"
- exit 1
- fi
- _ak_log_info "Data downloaded: $DATA"
- _ak_gpg_verify_signature $DATA.asc $DATA > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- _ak_log_error "Error while verifying signature for $DATA"
- exit 1
- fi
- mv $DATA $AK_WORKDIR/ipfs
- _ak_log_info "Block signature verified"
- echo -n '"data":"'$1'","'$1'":'$(_ak_ipfs_cat $1|jq -M -c)','
- exit 0
-else
- echo "Usage: $PROGRAM HASH GPG"
- exit 1
-fi
-
diff --git a/bin/ak-sm-hash-to-path b/bin/ak-sm-hash-to-path
deleted file mode 100755
index b114b1b..0000000
--- a/bin/ak-sm-hash-to-path
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-##
-## With this tool you give a SHA512 and take the following:
-##
-## -h, --help This help message
-##
-## -d, --dir <base path> <hash> Directory that the hashed file would be
-## hosted
-##
-## -p, --path <base path> <hash> Full path that the hashed file would be
-## saved
-##
-
-fullprogrampath="$(realpath $0)"
-PROGRAM="$(basename $0)"
-descriptionString="Simple driver for hashes/chunks/branches"
-source $AK_LIBDIR/_ak_fs
-source $AK_LIBDIR/_ak_script
-
-case "$1" in
- -h | --help)
- _ak_usage
- exit 1
- ;;
- -d | --dir)
- _ak_fs_verify_input_is_hash $2
- _ak_fs_return_hash_dir $2
- exit 0
- ;;
- -p | --path)
- _ak_fs_verify_input_is_hash $2
- _ak_fs_return_hash_path $2
- exit 0
- ;;
- *)
- echo "no option?!" >&2
- exit 1
- ;;
-esac
-
-exit 0