diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-06-14 22:36:12 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-06-14 22:36:12 +0300 |
commit | 4217dc0560bf40b4fa7ae6a6f964bd56b418712e (patch) | |
tree | 020e304e23b29d0eb12199c2f605f1262a3beb04 /lib | |
parent | 7743751290bb4e7678940be65725a48386e7b986 (diff) | |
download | arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.tar.gz arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.tar.bz2 arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.zip |
Refactoring
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/_ak_fm | 10 | ||||
-rwxr-xr-x | lib/_ak_gpg | 6 | ||||
-rwxr-xr-x | lib/_ak_ipfs | 112 | ||||
-rwxr-xr-x | lib/_ak_script | 8 | ||||
-rwxr-xr-x | lib/_ak_zblock | 100 | ||||
-rwxr-xr-x | lib/_ak_zchain | 4 |
6 files changed, 120 insertions, 120 deletions
@@ -4,12 +4,12 @@ _ak_fm_remove_line_from_file(){ tempfile="$(mktemp)" if [ ! -f "$2" ] then - logit "ERROR" "$2 does not exist" + _ak_log_error "$2 does not exist" exit 1 fi grep "$1" "$2" > /dev/null 2>&1 if [ $? -ne 0 ] - logit "ERROR" "Could not find line: $1 in $2" + _ak_log_error "Could not find line: $1 in $2" exit 1 fi grep -v "$1" "$2" > $tempfile @@ -20,13 +20,13 @@ _ak_fm_remove_line_from_file(){ _ak_fm_sort_uniq_file(){ if [ ! -f "$1" ] then - logit "INFO" "No file to process" + _ak_log_info "No file to process" else - logit "INFO" "Sorting $1..." + _ak_log_info "Sorting $1..." tempfile="$(mktemp)" cat "$1" | sort | uniq > $tempfile cat $tempfile > $1 rm $tempfile - logit "INFO" "Sorting $1... Done!" + _ak_log_info "Sorting $1... Done!" fi } diff --git a/lib/_ak_gpg b/lib/_ak_gpg index b74d411..81229e1 100755 --- a/lib/_ak_gpg +++ b/lib/_ak_gpg @@ -9,17 +9,17 @@ _ak_gpg(){ _ak_gpg_key_import_from_file(){ if [ -z $1 ] then - logit "[ERROR]" "No argument given" + _ak_log_error "No argument given" exit 1 fi if [ ! -n "$1" ] then - logit "[ERROR]" "Empty argument given" + _ak_log_error "Empty argument given" exit 1 fi if [ ! -f "$1" ] then - logit "[ERROR]" "File not found" + _ak_log_error "File not found" exit 1 fi _ak_gpg --import $1 > /dev/null 2>&1 diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs index 1f2b5ce..35c38a5 100755 --- a/lib/_ak_ipfs +++ b/lib/_ak_ipfs @@ -71,7 +71,7 @@ _ak_ipfs_scanner(){ _ak_ipfs_add(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "no argument given" + _ak_log_error "no argument given" exit 1 fi # Receives a file @@ -79,7 +79,7 @@ _ak_ipfs_add(){ _ak_ipfs add -Qr "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to add $1" + _ak_log_error "Failed to add $1" exit 1 fi } @@ -87,13 +87,13 @@ _ak_ipfs_add(){ _ak_ipfs_block_stat(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "no argument given" + _ak_log_error "no argument given" exit 1 fi _ak_ipfs block stat "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to retrieve stat of block $1" + _ak_log_error "Failed to retrieve stat of block $1" exit 1 fi } @@ -101,13 +101,13 @@ _ak_ipfs_block_stat(){ _ak_ipfs_cat(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "no argument given" + _ak_log_error "no argument given" exit 1 fi _ak_ipfs --timeout=10s cat $1 if [ "$?" -ne "0" ] then - logit "ERROR" "Failed to cat $1" + _ak_log_error "Failed to cat $1" exit 1 fi @@ -116,18 +116,18 @@ _ak_ipfs_cat(){ _ak_ipfs_files_cp(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi if [ -z $2 ] || [ ! -n "$2" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs files cp "$1" "$2" if [ $? -ne 0 ] then - logit "ERROR" "Failed to copy $1 to $2" + _ak_log_error "Failed to copy $1 to $2" exit 1 fi } @@ -136,7 +136,7 @@ _ak_ipfs_files_ls(){ _ak_ipfs files ls "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to list $1" + _ak_log_error "Failed to list $1" exit 1 fi } @@ -144,13 +144,13 @@ _ak_ipfs_files_ls(){ _ak_ipfs_files_mkdir(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs files mkdir "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to mkdir $1" + _ak_log_error "Failed to mkdir $1" exit 1 fi } @@ -158,18 +158,18 @@ _ak_ipfs_files_mkdir(){ _ak_ipfs_files_mv(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi if [ -z $2 ] || [ ! -n "$2" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs files mv "$1" "$2" if [ $? -ne 0 ] then - logit "ERROR" "Failed to move $1 to $2" + _ak_log_error "Failed to move $1 to $2" exit 1 fi } @@ -177,13 +177,13 @@ _ak_ipfs_files_mv(){ _ak_ipfs_files_rm(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs files rm "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to remove $1" + _ak_log_error "Failed to remove $1" exit 1 fi } @@ -191,13 +191,13 @@ _ak_ipfs_files_rm(){ _ak_ipfs_files_stat(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs files stat "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to get file's stats $1" + _ak_log_error "Failed to get file's stats $1" exit 1 fi } @@ -205,13 +205,13 @@ _ak_ipfs_files_stat(){ _ak_ipfs_get(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs --timeout=10s get "$1" > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Failed to get $1" + _ak_log_error "Failed to get $1" exit 1 fi } @@ -219,13 +219,13 @@ _ak_ipfs_get(){ _ak_ipfs_key_gen(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs key gen "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to generate key $1" + _ak_log_error "Failed to generate key $1" exit 1 fi } @@ -234,7 +234,7 @@ _ak_ipfs_key_list(){ _ak_ipfs key list if [ $? -ne 0 ] then - logit "ERROR" "Failed to get key list" + _ak_log_error "Failed to get key list" exit 1 fi } @@ -243,7 +243,7 @@ _ak_ipfs_key_list_full(){ _ak_ipfs key list -l if [ $? -ne 0 ] then - logit "ERROR" "Failed to get key list" + _ak_log_error "Failed to get key list" exit 1 fi } @@ -251,18 +251,18 @@ _ak_ipfs_key_list_full(){ _ak_ipfs_name_publish(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi if [ -z $2 ] || [ ! -n "$2" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs name publish "$1" "$2" if [ $? -ne 0 ] then - logit "ERROR" "Failed to get $1" + _ak_log_error "Failed to get $1" exit 1 fi @@ -271,13 +271,13 @@ _ak_ipfs_name_publish(){ _ak_ipfs_name_resolve(){ if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi _ak_ipfs name resolve "$1" if [ $? -ne 0 ] then - logit "ERROR" "Failed to resolve $1" + _ak_log_error "Failed to resolve $1" exit 1 fi @@ -287,7 +287,7 @@ _ak_ipfs_swarm_peers(){ _ak_ipfs swarm peers if [ $? -ne 0 ] then - logit "ERROR" "Failed to get list of peers" + _ak_log_error "Failed to get list of peers" exit 1 fi } @@ -296,7 +296,7 @@ _ak_ipfs_starter(){ _ak_ipfs_daemon if [ $? -ne 0 ] then - logit "ERROR" "Failed to start IPFS daemon" + _ak_log_error "Failed to start IPFS daemon" exit 1 fi } @@ -307,11 +307,11 @@ _ak_ipns_resolve(){ rsld=$(_ak_ipfs_name_resolve $1) if [ $? -ne 0 ] then - logit "ERROR" "Failed to resolve $1" + _ak_log_error "Failed to resolve $1" exit 1 fi echo -n $rsld | sed -e 's/\/ipfs\///' - logit "INFO" "Resolved $1 to $rsld" + _ak_log_info "Resolved $1 to $rsld" else exit 1 fi @@ -321,43 +321,43 @@ _ak_ipfs_check(){ _ak_ipfs_files_ls /zarchive > /dev/null if [ $? != 0 ] then - logit "ERROR" "/zarchive is missing" + _ak_log_error "/zarchive is missing" else - logit "INFO" "/zarchive OK" + _ak_log_info "/zarchive OK" fi _ak_ipfs_files_ls /zlatest > /dev/null if [ $? != 0 ] then - logit "ERROR" "/zlatest is missing" + _ak_log_error "/zlatest is missing" else - logit "INFO" "/zlatest is OK" + _ak_log_info "/zlatest is OK" fi _ak_ipfs_key_list | grep zchain > /dev/null if [ $? != 0 ]; then - logit "WARNING" "zchain key is missing" + _ak_log_warning "zchain key is missing" _ak_ipfs_key_gen zchain > $ZCHAIN if [ $? != 0 ]; then - logit "ERROR" "zchain fails to create" + _ak_log_error "zchain fails to create" else - logit "INFO" "zchain created" + _ak_log_info "zchain created" fi else - logit "INFO" "zchain is there" + _ak_log_info "zchain is there" fi _ak_ipfs_key_list | grep ak-config > /dev/null if [ $? != 0 ]; then - logit "WARNING" "ak-config key is missing" + _ak_log_warning "ak-config key is missing" _ak_ipfs_key_gen ak-config if [ $? != 0 ]; then - logit "ERROR" "ak-config fails to create" + _ak_log_error "ak-config fails to create" else - logit "INFO" "ak-config created" + _ak_log_info "ak-config created" fi else - logit "INFO" "ak-config is there" + _ak_log_info "ak-config is there" fi } @@ -371,7 +371,7 @@ _ak_ipfs_init(){ } _ak_ipfs_download(){ - logit "INFO" "Attempting to install IPFS..." + _ak_log_info "Attempting to install IPFS..." IPFS_VERSION="$(curl \ --connect-timeout 3 \ -s https://dist.ipfs.tech/kubo/versions | tail -1)" @@ -387,12 +387,12 @@ _ak_ipfs_download(){ fi IPFS_TARGET_FILE="kubo_"$IPFS_VERSION"_linux-$ARCH.tar.gz" - logit "INFO" "Downloading ipfs $IPFS_VERSION" + _ak_log_info "Downloading ipfs $IPFS_VERSION" if [ ! -f $AK_ARCHIVESDIR/$IPFS_TARGET_FILE ] then wget -O $AK_ARCHIVESDIR/$IPFS_TARGET_FILE https://dist.ipfs.tech/kubo/$IPFS_VERSION/$IPFS_TARGET_FILE ; else - logit "INFO" "Already have the latest version" + _ak_log_info "Already have the latest version" exit 0 fi } @@ -400,16 +400,16 @@ _ak_ipfs_download(){ _ak_ipfs_cid_v0_check () { if [ -z $1 ] || [ ! -n "$1" ] then - logit "ERROR" "No argument given" + _ak_log_error "No argument given" exit 1 fi echo $1 | grep -e 'Qm.\{44\}' > /dev/null if [ "$?" -ne 0 ] then - logit "ERROR" "$1 is not an IPFS CIDv0 string" + _ak_log_error "$1 is not an IPFS CIDv0 string" exit 1 fi - logit "INFO" "$1 provided is an IPFS CIDv0 string" + _ak_log_info "$1 provided is an IPFS CIDv0 string" } _ak_ipfs_swarm_install() { @@ -417,13 +417,13 @@ _ak_ipfs_swarm_install() { if [ ! -f $AK_IPFS_REPO/swarm.key ] then - logit "INFO" "Downloading swarm key" + _ak_log_info "Downloading swarm key" wget -O $AK_IPFS_REPO/swarm.key https://arching-kaos.net/files/swarm.key elif [ -f $AK_IPFS_REPO/swarm.key ] && [ "$(sha512sum $AK_IPFS_REPO/swarm.key | awk '{ print $1 }')" == "$SWARMSHA512SUM" ] then - logit "INFO" "Congrats! You are already in our swarm" + _ak_log_info "Congrats! You are already in our swarm" else - logit "ERROR" "Found swarm.key but not ours" - logit "ERROR" "Visit https://arching-kaos.net/files/swarm.key and copy it to your ipfs folder" + _ak_log_error "Found swarm.key but not ours" + _ak_log_error "Visit https://arching-kaos.net/files/swarm.key and copy it to your ipfs folder" fi } diff --git a/lib/_ak_script b/lib/_ak_script index 3a7f635..9838c15 100755 --- a/lib/_ak_script +++ b/lib/_ak_script @@ -16,9 +16,9 @@ _ak_exit_program(){ # rm -rf $tempdir if [ $1 -ne 0 ] then - logit "ERROR" "$2 ($1)" + _ak_log_error "$2 ($1)" else - logit "EXIT" "$2" + _ak_log_message "EXIT" "$2" fi exit $1 } @@ -29,7 +29,7 @@ _ak_help(){ cat $fullprogrampath |grep '^##'| sed 's/^##//g;s/^ //g' 1>&2 exit 1 else - logit "ERROR" "fullprogrampath was not set" + _ak_log_error "fullprogrampath was not set" exit 1 fi } @@ -39,7 +39,7 @@ _ak_title_description(){ if [ ! -n "$descriptionString" ] then # Choose to exit with error to enforce standard - logit "ERROR" "No description string" + _ak_log_error "No description string" exit 1 # Alternative solution # full_title="$(printf '%s' "$PROGRAM")" diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 0095c3d..b9fb91a 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -20,7 +20,7 @@ _ak_zblock_show(){ echo $1 | grep -e 'Qm.\{44\}' >/dev/null if [ $? -ne 0 ] then - logit "ERROR" "Argument provided ($1) was not an IPFS CIDv0 string" + _ak_log_error "Argument provided ($1) was not an IPFS CIDv0 string" exit 1 fi entrance="$1" @@ -38,7 +38,7 @@ _ak_zblock_show(){ # Reset timestamp since it's introduced later timestamp='' # Announce to logs which ZBLOCK is being read at the moment - logit "INFO" "Examining $zblock" + _ak_log_info "Examining $zblock" _ak_ipfs_cid_v0_check "$zblock" @@ -46,10 +46,10 @@ _ak_zblock_show(){ _ak_ipfs_cat $zblock | jq -c -M > $AK_ZBLOCKDIR/$zblock if [ "$?" -ne 0 ] then - logit "ERROR" "ZBLOCK $zblock READ failed" + _ak_log_error "ZBLOCK $zblock READ failed" exit 1 fi - logit "INFO" "ZBLOCK $zblock READ" + _ak_log_info "ZBLOCK $zblock READ" echo -n '{' # echo -n '"id":"'$counter'",' echo -n '"zblock":"'$zblock'",' @@ -58,11 +58,11 @@ _ak_zblock_show(){ cat $AK_ZBLOCKDIR/$zblock | jq -M > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "ZBLOCK $zblock is not JSON" + _ak_log_error "ZBLOCK $zblock is not JSON" cat /dev/null > $AK_ZBLOCKDIR/$zblock > /dev/null 2>&1 exit 1 fi - logit "INFO" "ZBLOCK $zblock is JSON" + _ak_log_info "ZBLOCK $zblock is JSON" # Be sure that there are the expected values # We need 'block' and 'block_signature' inside a 'zblock' @@ -70,20 +70,20 @@ _ak_zblock_show(){ block="$(cat $AK_ZBLOCKDIR/$zblock | jq -M -r .block)" if [ "$block" == "null" ] then - logit "ERROR" "ZBLOCK $zblock has no block" + _ak_log_error "ZBLOCK $zblock has no block" exit 1 fi _ak_ipfs_cid_v0_check "$block" - logit "INFO" "ZBLOCK $zblock has block" + _ak_log_info "ZBLOCK $zblock has block" block_signature="$(cat $AK_ZBLOCKDIR/$zblock | jq -M -r .block_signature)" if [ "$block_signature" == "null" ] then - logit "ERROR" "ZBLOCK $zblock doesn't contain a block_signature" + _ak_log_error "ZBLOCK $zblock doesn't contain a block_signature" exit 1 fi _ak_ipfs_cid_v0_check "$block_signature" - logit "INFO" "ZBLOCK $zblock contains a block_signature" + _ak_log_info "ZBLOCK $zblock contains a block_signature" # Same as above applies to BLOCK and DATA subparts of each ZBLOCK # BLOCKS @@ -92,24 +92,24 @@ _ak_zblock_show(){ cat $AK_BLOCKDIR/$block | jq -M > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "BLOCK $block READ failed" + _ak_log_error "BLOCK $block READ failed" exit 1 fi grep -e 'timestamp' -e 'gpg' -e 'data' -e 'action' -e 'detach' -e 'previous' $AK_BLOCKDIR/$block > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "BLOCK $block is NOT a valid block" + _ak_log_error "BLOCK $block is NOT a valid block" exit 1 fi - logit "INFO" "BLOCK $block is a block" + _ak_log_info "BLOCK $block is a block" action="$(cat $AK_BLOCKDIR/$block | jq -M -r .action)" module="$(echo $action | sed -e 's/\// /g' | awk '{ print $1 }')" - logit "INFO" "DATA is $module module." + _ak_log_info "DATA is $module module." command="$(echo $action | sed -e 's/\// /g' | awk '{ print $2 }')" - logit "INFO" "COMMAND is $command" + _ak_log_info "COMMAND is $command" timestamp="$(cat $AK_BLOCKDIR/$block | jq -M -r .timestamp)" if [ "$timestamp" != "null" ] @@ -134,39 +134,39 @@ _ak_zblock_show(){ _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 $block_signature > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Error while getting $block_signature for $block" + _ak_log_error "Error while getting $block_signature for $block" exit 1 fi mv $block_signature $block.asc - logit "INFO" "Block signature downloaded" + _ak_log_info "Block signature downloaded" _ak_ipfs_get $block > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Could not get $block block" + _ak_log_error "Could not get $block block" exit 1 fi - logit "INFO" "Downloaded block $block." + _ak_log_info "Downloaded block $block." _ak_gpg_verify_signature $block.asc $block > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "ERROR" "Could not verify $block with GPG key $gpg." + _ak_log_error "Could not verify $block with GPG key $gpg." exit 1 fi - logit "GPG" "$gpg signature of $block is verified." + _ak_log_info "$gpg signature of $block is verified." fi data="$(cat $AK_BLOCKDIR/$block | jq -M -r .data)" @@ -174,7 +174,7 @@ _ak_zblock_show(){ ak-data-expand $data $gpg if [ "$?" -ne 0 ] then - logit "ERROR" "Failed on data signature verification [data: $data, gpg: $gpg, zblock: $zblock]" + _ak_log_error "Failed on data signature verification [data: $data, gpg: $gpg, zblock: $zblock]" exit 1 fi @@ -189,15 +189,15 @@ _ak_zblock_show(){ previous="$(cat $AK_BLOCKDIR/$block | jq -M -r .previous)" if [ -v $previous ] then - logit "WARNING" "Block $block has no previous zblock, appending pseudo genesis to exit with 2." + _ak_log_warning "Block $block has no previous zblock, appending pseudo genesis to exit with 2." echo -n '"previous":"'$seed'"},{"genesis":"genesis"}]' - logit "INFO" "Reached pseudo-genesis, counted $counter zblocks." + _ak_log_info "Reached pseudo-genesis, counted $counter zblocks." exit 2 # Otherwise, we inform of the sequence else #echo "$zblock after $previous" - logit "INFO" "Found a previous block for $zblock: $previous" + _ak_log_info "Found a previous block for $zblock: $previous" echo -n '"previous":"'$previous'"}' zblock=$previous fi @@ -207,7 +207,7 @@ _ak_zblock_show(){ elif [ "$zblock" == "$seed" ] then echo -n '{"genesis":"genesis"}]' - logit "INFO" "Reached $seed, counted $counter zblocks." + _ak_log_info "Reached $seed, counted $counter zblocks." exit 0 fi # And finally, if nothing is there exit with error @@ -265,7 +265,7 @@ _ak_zblock_show(){ # # main(){ # -# logit "INFO" "We are doing" $BLOCK_TO_ADD "with content" $PREVIOUS +# _ak_log_info "We are doing" $BLOCK_TO_ADD "with content" $PREVIOUS # # We add it to IPFS # MESSAGE_HASH=$(_ak_ipfs_add $MESSAGE) # @@ -369,7 +369,7 @@ _ak_zblock_gen_html(){ # Check if there are enough arguments if [ $# -lt 1 ] then - logit "ERROR" "Not enough arguments provided" + _ak_log_error "Not enough arguments provided" _ak_help exit 1 fi @@ -421,12 +421,12 @@ _ak_zblock_cache(){ # if [ "$(sha512sum $AK_ZBLOCKDIR/$1 | awk '{ print $1 }')" == "$(_ak_zblock_show $1 | sha512sum | awk '{ print $1 }')" ] if [ ! -f $FZBLOCKSDIR/$1 ] then - logit "INFO" "No cache found. Caching..." + _ak_log_info "No cache found. Caching..." _ak_zblock_show "$1" > $FZBLOCKSDIR/$1 fi if [ ! -f $FZBLOCKSDIR/$1 ] then - logit "INFO" "Caching failed..." + _ak_log_info "Caching failed..." exit 1 fi cat $FZBLOCKSDIR/$1 @@ -434,15 +434,15 @@ _ak_zblock_cache(){ _ak_zblock_show "$1" > $FZBLOCKSDIR/$1 if [ $? -ne "0" ] then - logit "ERROR" "_ak_zblock_show failed..." + _ak_log_error "_ak_zblock_show failed..." exit 2 fi - logit "ERROR" "Could not find zblock $1..." + _ak_log_error "Could not find zblock $1..." exit 1 fi exit 0 else - logit "ERROR" "No arguments..." + _ak_log_error "No arguments..." exit 1 fi @@ -462,13 +462,13 @@ _ak_zblock_pack(){ do if [ "$p" == "$TO_CHECK" ] then - logit "ERROR" "Value $TO_CHECK already mentioned on the zchain" + _ak_log_error "Value $TO_CHECK already mentioned on the zchain" exit 1 fi done < tempisalreadythere rm tempisalreadythere - logit "INFO" "We are doing $ACTION with content $MESSAGE" + _ak_log_info "We are doing $ACTION with content $MESSAGE" # We add it to IPFS MESSAGE_HASH=$(_ak_ipfs_add $MESSAGE) @@ -507,7 +507,7 @@ _ak_zblock_pack(){ ZBLOCK=$(_ak_ipfs_add $ZBL) echo $ZBLOCK else - logit "ERROR" "File does not exist. Aborting..." + _ak_log_error "File does not exist. Aborting..." exit 1 fi @@ -519,46 +519,46 @@ _ak_zblock_pack(){ _ak_ipfs_name_publish --key=zchain $ZBLOCK > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Failed publishing ZBLOCK: $ZBLOCK" + _ak_log_error "Failed publishing ZBLOCK: $ZBLOCK" exit 1 fi _ak_ipfs_files_ls /zarchive > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "WARNING" "/zarchive does not exist" + _ak_log_warning "/zarchive does not exist" _ak_ipfs_files_mkdir /zarchive > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Could not create /zarchive directory. Aborting." + _ak_log_error "Could not create /zarchive directory. Aborting." exit 1 fi fi _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1) > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Could not back up previous /zlatest" + _ak_log_error "Could not back up previous /zlatest" exit 1 fi _ak_ipfs_files_rm /zlatest > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Could not remove previous /zlatest" + _ak_log_error "Could not remove previous /zlatest" exit 1 fi _ak_ipfs_files_cp /ipfs/$ZBLOCK /zlatest > /dev/null 2>&1 if [ $? -ne 0 ] then - logit "ERROR" "Could not copy $ZBLOCK to /zlatest" + _ak_log_error "Could not copy $ZBLOCK to /zlatest" exit 1 fi ak-config --publish if [ $? -ne 0 ] then - logit "ERROR" "Could not publish new configuration" + _ak_log_error "Could not publish new configuration" exit 1 fi else - logit "ERROR" "Not enough arguments" + _ak_log_error "Not enough arguments" exit 1 fi @@ -575,9 +575,9 @@ _ak_zblock_announce(){ 2>/dev/null | jq -M -c > /dev/null if [ $? -ne 0 ] then - logit "ERROR" "zblock $zblock announcement failed" + _ak_log_error "zblock $zblock announcement failed" else - logit "INFO" "zblock $zblock announced" + _ak_log_info "zblock $zblock announced" fi else curl \ @@ -588,9 +588,9 @@ _ak_zblock_announce(){ 2>/dev/null | jq -M -c > /dev/null if [ $? -ne 0 ] then - logit "ERROR" "zblock $zblock announcement failed" + _ak_log_error "zblock $zblock announcement failed" else - logit "INFO" "zblock $zblock announced" + _ak_log_info "zblock $zblock announced" fi fi } diff --git a/lib/_ak_zchain b/lib/_ak_zchain index a652a31..87fa5cf 100755 --- a/lib/_ak_zchain +++ b/lib/_ak_zchain @@ -31,7 +31,7 @@ _ak_zchain_reset(){ ak-config --publish if [ "$?" -ne 0 ] then - logit "ERROR" "Could not publish new configuration" + _ak_log_error "Could not publish new configuration" exit 1 fi @@ -70,7 +70,7 @@ _ak_zchain_rebase(){ ak-config --publish if [ "$?" -ne 0 ] then - logit "ERROR" "Could not publish new configuration" + _ak_log_error "Could not publish new configuration" exit 1 fi echo "Rebase was successful" |