From f2840ea42b494b2375a28b40f8d1c853b4878e18 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 20 Dec 2024 17:17:51 +0200 Subject: Fixes and new flags, see ak-fs --help --- bin/ak-fs | 6 +++++- lib/_ak_fs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/ak-fs b/bin/ak-fs index 74aedfa..800a9bb 100755 --- a/bin/ak-fs +++ b/bin/ak-fs @@ -28,6 +28,8 @@ ## --cat Concatenates from given hash ## --list Lists names and roots available ## --net-cat-from-map Concatenates from map via the network +## --cfm Concatenates from map +## --gfm Get file from map ## fullprogrampath="$(realpath $0)" PROGRAM=$(basename $0) @@ -42,13 +44,15 @@ then case $1 in -h | --help) _ak_usage; exit;; --add|--import) _ak_fs_import $2; exit;; - --get|--export) _ak_fs_export $2 $3; exit;; + --get|--export) shift; _ak_fs_export $1 $2; exit;; --cat) _ak_fs_cat $2; exit;; --net-cat) _ak_fs_net_cat $2; exit;; --net-get) _ak_fs_net_get $2; exit;; --net-cat-from-map) _ak_fs_net_cat_from_map_hash $2; exit;; --net-get-from-map) _ak_fs_net_get_from_map_hash $2; exit;; --list) _ak_fs_list; exit;; + --cfm) _ak_fs_cat_from_map_hash $2; exit;; + --gfm) _ak_fs_get_from_map_hash $2; exit;; * ) _ak_usage;; esac else diff --git a/lib/_ak_fs b/lib/_ak_fs index b2db396..bea850c 100755 --- a/lib/_ak_fs +++ b/lib/_ak_fs @@ -199,7 +199,7 @@ function _ak_fs_import(){ sha512sum level.1.map sha512sum level.1.map >> $TEMPDIR/3rd_gen_map else - echo error + ak_log_error "Got error an error, level.1.map is missing" exit 1 fi @@ -273,10 +273,10 @@ function _ak_fs_cat(){ echo "Please provide a SHA512 hash" exit 1 fi - echo $1 | grep "[0123456789abcdef]\{128\}" + echo $1 | grep "[0123456789abcdef]\{128\}" > /dev/null 2>&1 if [ $? -ne 0 ] then - echo "Look, I asked for a SHA512 hash, please try again" + _ak_log_error "Look, I asked for a SHA512 hash, please try again" exit 1 fi treeRootHash="$1" @@ -303,7 +303,7 @@ function _ak_fs_cat(){ nextLevel="$(expr $counter + 1)" if [ "$p" == "" ] then - echo hi + _ak_log_debug "Got empty line" else #expectedPath="$AK_LEAFSDIR/$(_ak_fs_return_hash_path $p)" expectedPath="$AK_LEAFSDIR/$p" @@ -342,13 +342,13 @@ function _ak_fs_export(){ exit 2 fi outputFilename="$2" - echo $1 | grep "[0123456789abcdef]\{128\}" + echo $1 | grep "[0123456789abcdef]\{128\}" > /dev/null 2>&1 if [ $? -ne 0 ] then _ak_log_error "Look, I asked for a SHA512 hash, please try again" exit 1 fi - _ak_fs_export "$1" > $outputFilename + _ak_fs_cat "$1" > $outputFilename } function _ak_fs_list(){ @@ -417,7 +417,7 @@ function _ak_fs_cat_from_map_hash(){ function _ak_fs_get_from_map_hash(){ if _ak_fs_verify_input_is_hash "$1" then - _ak_fs_get `_ak_fs_from_map_get_root_hash $1` "`_ak_fs_from_map_get_original_filename $1`" + _ak_fs_export `_ak_fs_from_map_get_root_hash $1` "$(basename `_ak_fs_from_map_get_original_filename $1`)" fi } @@ -549,7 +549,7 @@ function _ak_fs_net_cat(){ echo "Please provide a SHA512 hash" exit 1 fi - echo $1 | grep "[0123456789abcdef]\{128\}" + echo $1 | grep "[0123456789abcdef]\{128\}" > /dev/null 2>&1 if [ $? -ne 0 ] then echo "Look, I asked for a SHA512 hash, please try again" @@ -583,7 +583,7 @@ function _ak_fs_net_cat(){ nextLevel="$(expr $counter + 1)" if [ "$p" == "" ] then - echo hi + _ak_log_debug "Got empty line" else expectedPath="$AK_LEAFSDIR/$p" if [ -f $expectedPath ] -- cgit v1.2.3