From f8d2236e55e5c369b218017d1de1058d6a8ee361 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 1 Mar 2024 19:26:24 +0200 Subject: Log formatting adjustment --- bin/ak-articles | 27 +++++++++++++++-- bin/ak-data-expand | 34 ++++++++++----------- bin/ak-enter | 60 ++++++++++++++++++------------------- bin/ak-files | 66 ++++++++++++++++++++--------------------- bin/ak-find-latest-mined-sblock | 22 +++++++------- bin/ak-folders | 28 +++++++++-------- bin/ak-ipfs-add | 2 +- bin/ak-ipfs-block-stat | 2 +- bin/ak-ipfs-cat | 2 +- bin/ak-ipfs-check | 26 ++++++++-------- bin/ak-ipfs-files-cp | 2 +- bin/ak-ipfs-files-ls | 2 +- bin/ak-ipfs-files-mkdir | 2 +- bin/ak-ipfs-files-mv | 2 +- bin/ak-ipfs-files-rm | 2 +- bin/ak-ipfs-files-stat | 2 +- bin/ak-ipfs-get | 4 +-- bin/ak-ipfs-key-gen | 2 +- bin/ak-ipfs-key-list | 2 +- bin/ak-ipfs-key-list-full | 2 +- bin/ak-ipfs-name-publish | 2 +- bin/ak-ipfs-name-resolve | 2 +- bin/ak-ipfs-starter | 2 +- bin/ak-ipfs-swarm-peers | 2 +- bin/ak-ipns-resolve | 6 ++-- bin/ak-profile | 2 +- bin/ak-sm-filejoiner | 2 +- bin/ak-sm-files | 14 ++++----- bin/ak-sm-filesplitter | 28 ++++++++--------- bin/ak-sm-merkle-tree | 40 ++++++++++++------------- bin/ak-stellar-get-participants | 10 +++---- bin/ak-tempassin | 8 ++--- bin/ak-transactions | 4 +-- bin/ak-unfollow | 4 +-- bin/ak-zblock-cache | 14 ++++----- bin/ak-zblock-pack | 24 +++++++-------- bin/ak-zblock-show | 4 +-- bin/ak-zchain-rebase | 2 +- bin/ak-zchain-reset | 4 +-- 39 files changed, 244 insertions(+), 221 deletions(-) diff --git a/bin/ak-articles b/bin/ak-articles index e6c45c4..9e7c7b4 100755 --- a/bin/ak-articles +++ b/bin/ak-articles @@ -1,7 +1,29 @@ #!/bin/bash + +PROGRAM=$(basename $0) +descriptionString="Articles module for Arching Kaos" + +logit(){ + ak-logthis "$PROGRAM" "$1" "$2" +} +new_line(){ + printf '\n' +} +description(){ + full_title="$(printf '%s - %s' "$PROGRAM" "$descriptionString")" + delimiter_count=`echo -n $full_title | wc -c` + printf '%s' "$full_title" + new_line + while [ $delimiter_count -gt 0 ] + do + printf '=' + delimiter_count=$(($delimiter_count-1)) + done + new_line +} + ZARTICLESDIR="$AK_WORKDIR/articles" TEMP="/tmp/aktmp" -echo $ZARTICLESDIR if [ ! -d $ZARTICLESDIR ]; then mkdir $ZARTICLESDIR cd $ZARTICLESDIR @@ -47,8 +69,7 @@ _ak_modules_articles_index(){ done } _ak_modules_articles_title(){ - echo ak-articles-cli - echo "--------------" + description } _ak_modules_articles_import(){ echo "#TODO" diff --git a/bin/ak-data-expand b/bin/ak-data-expand index 862fa75..d13233d 100755 --- a/bin/ak-data-expand +++ b/bin/ak-data-expand @@ -5,94 +5,94 @@ then mkdir $AK_WORKDIR/ipfs fi logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -z "$1" ] && [ ! -z "$2" ] then echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Invalid hash format for $1" + logit "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" + logit "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" + logit "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" + logit "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" + logit "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" + logit "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" + logit "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" + logit "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" + logit "ERROR" "Could not get GPG key: $gpg" exit 1 fi gpg2 --homedir $AK_GPGHOME --import $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not import GPG key: $gpg" + logit "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" + logit "ERROR" "Error while getting signature: $DETACH for data: $DATA" exit 1 fi mv $DETACH $DATA.asc - logit "[INFO]" "Block signature downloaded" + logit "INFO" "Block signature downloaded" ak-ipfs-get $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while getting data: $DATA" + logit "ERROR" "Error while getting data: $DATA" exit 1 fi - logit "[INFO]" "Data downloaded: $DATA" + logit "INFO" "Data downloaded: $DATA" gpg2 --homedir $AK_GPGHOME --verify $DATA.asc $DATA > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Error while verifying signature for $DATA" + logit "ERROR" "Error while verifying signature for $DATA" exit 1 fi mv $DATA $AK_WORKDIR/ipfs - logit "[INFO]" "Block signature verified" + logit "INFO" "Block signature verified" echo -n '"data":"'$1'","'$1'":'$(ak-ipfs-cat $1|jq -M -c)',' exit 0 else diff --git a/bin/ak-enter b/bin/ak-enter index 3313329..92a434d 100755 --- a/bin/ak-enter +++ b/bin/ak-enter @@ -20,7 +20,7 @@ PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } usage(){ @@ -45,7 +45,7 @@ isIPFSv0 () { echo $1 | grep -e 'Qm.\{44\}' > /dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Argument provided was not an IPFS CIDv0 string" + logit "ERROR" "Argument provided was not an IPFS CIDv0 string" exit 1 fi else @@ -84,7 +84,7 @@ while [ "$#" ]; do entrance="$(ak-ipns-resolve $1)" if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not resolve IPNS name" + logit "ERROR" "Could not resolve IPNS name" exit 1 fi shift @@ -135,7 +135,7 @@ do # Reset timestamp since it's introduced later timestamp='' # Announce to logs which ZBLOCK is being read at the moment - logit "[INFO]" "Examining $zblock" + logit "INFO" "Examining $zblock" isIPFSv0 "$zblock" @@ -143,23 +143,23 @@ do ak-ipfs-cat $zblock | jq -c -M > $AK_ZBLOCKDIR/$zblock if [ "$?" -ne 0 ] then - logit "[ERROR]" "ZBLOCK $zblock READ failed" + logit "ERROR" "ZBLOCK $zblock READ failed" exit 1 fi - logit "[INFO]" "ZBLOCK $zblock READ" + logit "INFO" "ZBLOCK $zblock READ" echo -n '{' # echo -n '"id":"'$counter'",' echo -n '"zblock":"'$zblock'",' - + # If it's JSON formated cat $AK_ZBLOCKDIR/$zblock | jq -M > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "ZBLOCK $zblock is not JSON" + logit "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" + logit "INFO" "ZBLOCK $zblock is JSON" # Be sure that there are the expected values # We need 'block' and 'block_signature' inside a 'zblock' @@ -167,20 +167,20 @@ do block="$(cat $AK_ZBLOCKDIR/$zblock | jq -M -r .block)" if [ "$block" == "null" ] then - logit "[ERROR]" "ZBLOCK $zblock has no block" + logit "ERROR" "ZBLOCK $zblock has no block" exit 1 fi isIPFSv0 "$block" - logit "[INFO]" "ZBLOCK $zblock has block" + logit "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" + logit "ERROR" "ZBLOCK $zblock doesn't contain a block_signature" exit 1 fi isIPFSv0 "$block_signature" - logit "[INFO]" "ZBLOCK $zblock contains a block_signature" + logit "INFO" "ZBLOCK $zblock contains a block_signature" # Same as above applies to BLOCK and DATA subparts of each ZBLOCK # BLOCKS @@ -189,24 +189,24 @@ do cat $AK_BLOCKDIR/$block | jq -M > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "BLOCK $block READ failed" + logit "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" + logit "ERROR" "BLOCK $block is NOT a valid block" exit 1 fi - logit "[INFO]" "BLOCK $block is a block" + logit "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." + logit "INFO" "DATA is $module module." command="$(echo $action | sed -e 's/\// /g' | awk '{ print $2 }')" - logit "[INFO]" "COMMAND is $command" + logit "INFO" "COMMAND is $command" timestamp="$(cat $AK_BLOCKDIR/$block | jq -M -r .timestamp)" if [ "$timestamp" != "null" ] @@ -231,36 +231,36 @@ do ak-ipfs-get $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not get GPG key: $gpg ." + logit "ERROR" "Could not get GPG key: $gpg ." exit 1 fi gpg2 --homedir $AK_GPGHOME --import $gpg > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not import GPG key: $gpg ." + logit "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" + logit "ERROR" "Error while getting $block_signature for $block" exit 1 fi mv $block_signature $block.asc - logit "[INFO]" "Block signature downloaded" + logit "INFO" "Block signature downloaded" ak-ipfs-get $block > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not get $block block" + logit "ERROR" "Could not get $block block" exit 1 fi - logit "[INFO]" "Downloaded block $block." + logit "INFO" "Downloaded block $block." gpg2 --homedir $AK_GPGHOME --verify $block.asc > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not verify $block with GPG key $gpg." + logit "ERROR" "Could not verify $block with GPG key $gpg." exit 1 fi logit "[GPG]" "$gpg signature of $block is verified." @@ -271,7 +271,7 @@ do ak-data-expand $data $gpg if [ "$?" -ne 0 ] then - logit "[ERROR]" "Failed on data signature verification [data: $data, gpg: $gpg, zblock: $zblock]" + logit "ERROR" "Failed on data signature verification [data: $data, gpg: $gpg, zblock: $zblock]" exit 1 fi @@ -286,15 +286,15 @@ do 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." + logit "WARNING" "Block $block has no previous zblock, appending pseudo genesis to exit with 2." echo -n '"previous":"genesis"},{"genesis":"genesis"}]' - logit "[INFO]" "Reached pseudo-genesis, counted $counter zblocks." + logit "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" + logit "INFO" "Found a previous block for $zblock: $previous" echo -n '"previous":"'$previous'"}' zblock=$previous fi @@ -311,7 +311,7 @@ do elif [ "$zblock" == "$seed" ] then echo -n '{"genesis":"genesis"}]' - logit "[INFO]" "Reached $seed, counted $counter zblocks." + logit "INFO" "Reached $seed, counted $counter zblocks." exit 0 fi # And finally, if nothing is there exit with error diff --git a/bin/ak-files b/bin/ak-files index 20083ab..299bf4a 100755 --- a/bin/ak-files +++ b/bin/ak-files @@ -4,21 +4,21 @@ ZFILESDIR="$AK_WORKDIR/files" TEMP="/tmp/aktmp" PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -d $ZFILESDIR ]; then - mkdir $ZFILESDIR - if [ $? == 0 ] - then - logit "[INFO]" "Folder $ZFILESDIR created!" - else - logit "[ERROR]" "Failed to create $ZFILESDIR folder" - exit 1 - fi - cd $ZFILESDIR - git init + mkdir $ZFILESDIR + if [ $? == 0 ] + then + logit "INFO" "Folder $ZFILESDIR created!" + else + logit "ERROR" "Failed to create $ZFILESDIR folder" + exit 1 + fi + cd $ZFILESDIR + git init else - logit "[INFO]" "$ZFILESDIR found!" + logit "INFO" "$ZFILESDIR found!" fi _ak_modules_files_usage(){ @@ -35,47 +35,47 @@ main(){ FILENAME="$1" CRP="$2" echo "Adding $FILENAME" - logit "[INFO]" "Switching to tmp folder..." + logit "INFO" "Switching to tmp folder..." TEMPASSIN="$(ak-tempassin)" cd $TEMPASSIN if [ $? == 0 ]; then - logit "[INFO]" "Success" + logit "INFO" "Success" else - logit "[ERROR]" "Error with tmp folder" - exit 5 + logit "ERROR" "Error with tmp folder" + exit 5 fi - logit "[INFO]" "Copying $1 to $TEMPASSIN" + logit "INFO" "Copying $1 to $TEMPASSIN" cp $2/$1 $TEMPASSIN/$1 if [ $? == 0 ]; then - logit "[INFO]" "Copied successfully" + logit "INFO" "Copied successfully" else - logit "[ERROR]" "Error copying..." + logit "ERROR" "Error copying..." fi FILE="$TEMPASSIN/$1" - logit "[INFO]" "Adding $FILE to IPFS..." + logit "INFO" "Adding $FILE to IPFS..." FILE_IPFS_HASH=$(ak-ipfs-add $FILE) if [ $? == 0 ]; then - logit "[INFO]" "Added $FILE to IPFS" + logit "INFO" "Added $FILE to IPFS" else - logit "[ERROR]" "Error in adding the $FILE to IPFS" + logit "ERROR" "Error in adding the $FILE to IPFS" fi - logit "[INFO]" "Signing..." + logit "INFO" "Signing..." SIGN_FILE=$FILENAME".asc" gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $SIGN_FILE $FILE if [ $? == 0 ]; then - logit "[INFO]" "Signed" + logit "INFO" "Signed" else - logit "[ERROR]" "Error while signing" + logit "ERROR" "Error while signing" fi - logit "[INFO]" "Adding signature to IPFS" + logit "INFO" "Adding signature to IPFS" SIGNATURE=$(ak-ipfs-add $TEMPASSIN/$SIGN_FILE) if [ $? == 0 ]; then - logit "[INFO]" "Added" + logit "INFO" "Added" else - logit "[ERROR]" "Error while adding" + logit "ERROR" "Error while adding" fi cat > $TEMPASSIN/data <" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } further(){ - # logitnowint "[INFO]" "Diving into $1" + # logitnowint "INFO" "Diving into $1" lookfor $1 } lookfor(){ - echo -n $1 | grep -e '[0-9a-f]\{128\}' > /dev/null + echo -n $1 | grep -e '[0-9a-f]\{128\}' > /dev/null if [ ! $? = 0 ] then - logitnowint "[ERROR]" "Oops!!! The argument passed, does not match the regular expression!" + logitnowint "ERROR" "Oops!!! The argument passed, does not match the regular expression!" else counters[$CHAIN_PARENT]="$(expr ${counters[$CHAIN_PARENT]} + 1)" if [ ! $? = 0 ] @@ -23,22 +23,22 @@ lookfor(){ echo "$1, $counters[$1]" exit 1 fi - logitnowint "[INFO]" "Accessing file: $1" + logitnowint "INFO" "Accessing file: $1" # echo "$1 file:" # cat "$1" | jq NEXT_TARGET="$(cat "$1" | jq | grep previous | tr -d ' ' | sed -e 's/previous//g; s/[",:]//g;')" if [ ! "$NEXT_TARGET" = "" ] then - logitnowint "[INFO]" "Found previous: $NEXT_TARGET" + logitnowint "INFO" "Found previous: $NEXT_TARGET" if [ ! -f "$NEXT_TARGET" ] then - logitnowint "[WARNING]" "Could not find $NEXT_TARGET" + logitnowint "WARNING" "Could not find $NEXT_TARGET" else further "$NEXT_TARGET" fi else - logitnowint "[WARNING]" "No next target found. So long for $1" + logitnowint "WARNING" "No next target found. So long for $1" fi fi } @@ -50,12 +50,12 @@ do # if [ ! "$p" = "" ] && [ ! "$p" = "tmplistblock" ] if [ "$(echo $p | tr -d '\n' | wc -c)" = 128 ] then - logitnowint "[INFO]" "Investigating $p..." + logitnowint "INFO" "Investigating $p..." export CHAIN_PARENT="$p" counters[$CHAIN_PARENT]=1 lookfor "$p" else - logitnowint "[WARNING]" "Nothing to do with $p" + logitnowint "WARNING" "Nothing to do with $p" fi done < tmplistblock rm tmplistblock @@ -68,7 +68,7 @@ do then max="${counters[${value}]}" max_holder="${value}" - logitnowint "[INFO]" "New MAX $max on $max_holder" + logitnowint "INFO" "New MAX $max on $max_holder" fi diff --git a/bin/ak-folders b/bin/ak-folders index 2a28dd9..280af2b 100755 --- a/bin/ak-folders +++ b/bin/ak-folders @@ -5,21 +5,24 @@ ZFOLDERSDIR="$AK_WORKDIR/folders" TEMP="/tmp/aktmp" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -d $ZFOLDERSDIR ]; then mkdir $ZFOLDERSDIR - cd $ZFOLDERSDIR + logit "ERROR" "error $ZFOLDERSDIR not found or/and could not be created" else - logit "[ERROR]" "error $ZFOLDERSDIR not found or/and could not be created" + logit "INFO" "Found $ZFOLDERSDIR" + exit 1 fi TEMPASSIN="$(ak-tempassin)" cd $TEMPASSIN _ak_modules_folders_usage(){ _ak_modules_folders_title - echo "$PROGRAM - folder" + echo "" + echo " -h, --help Show this message" + echo " add Try ak-folders add " } _ak_modules_folders_add(){ @@ -33,24 +36,24 @@ _ak_modules_folders_main(){ FOLDERNAME="$1" CRP="$2" echo "Adding $FOLDERNAME" - logit "[INFO]" "Copying $1 to temporary folder" + logit "INFO" "Copying $1 to temporary folder" cp -r $2/$1 $1 if [ $? == 0 ]; then - logit "[INFO]" "Copied successfully" + logit "INFO" "Copied successfully" else - logit "[ERROR]" "Error copying..." + logit "ERROR" "Error copying..." fi FOLDER="$1" - logit "[INFO]" "Adding $FOLDER to IPFS..." + logit "INFO" "Adding $FOLDER to IPFS..." FOLDER_IPFS_HASH=$(ak-ipfs-add $FOLDER) if [ $? == 0 ]; then - logit "[INFO]" "done" + logit "INFO" "done" else - logit "[ERROR]" "error" + logit "ERROR" "error" fi - logit "[WARNING]" "Folders are not signing..." + logit "WARNING" "Folders are not signing..." printf '{"timestamp":"%s","foldername":"%s","ipfs":"%s"}' $(date -u +%s) $FOLDERNAME $FOLDER_IPFS_HASH @@ -69,8 +72,7 @@ _ak_modules_folders_main(){ } _ak_modules_folders_title(){ - echo "$PROGRAM" - echo "Folder block creator" + echo "$PROGRAM - Folder block creator" } diff --git a/bin/ak-ipfs-add b/bin/ak-ipfs-add index 63862b7..4cedcec 100755 --- a/bin/ak-ipfs-add +++ b/bin/ak-ipfs-add @@ -5,6 +5,6 @@ PROGRAM="$(basename $0)" ipfs add -Qr "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to add $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to add $1" exit 1 fi diff --git a/bin/ak-ipfs-block-stat b/bin/ak-ipfs-block-stat index 144523d..b049a70 100755 --- a/bin/ak-ipfs-block-stat +++ b/bin/ak-ipfs-block-stat @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs block stat "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to retrieve stat of block $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to retrieve stat of block $1" exit 1 fi diff --git a/bin/ak-ipfs-cat b/bin/ak-ipfs-cat index d2415e4..2adf00e 100755 --- a/bin/ak-ipfs-cat +++ b/bin/ak-ipfs-cat @@ -3,7 +3,7 @@ PROGRAM="$(basename $0)" ipfs --timeout=10s cat $1 if [ "$?" -ne "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to cat $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to cat $1" exit 1 fi diff --git a/bin/ak-ipfs-check b/bin/ak-ipfs-check index d54f5fc..30ebf4d 100755 --- a/bin/ak-ipfs-check +++ b/bin/ak-ipfs-check @@ -1,38 +1,38 @@ #!/bin/bash PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } ak-ipfs-files-ls /zarchive > /dev/null if [ $? != 0 ] then - logit "[ERROR]" "/zarchive is missing" -else - logit "[INFO]" "/zarchive OK" + logit "ERROR" "/zarchive is missing" +else + logit "INFO" "/zarchive OK" fi ak-ipfs-files-ls /zlatest > /dev/null if [ $? != 0 ] then - logit "[ERROR]" "/zlatest is missing" + logit "ERROR" "/zlatest is missing" else - logit "[INFO]" "/zlatest is OK" + logit "INFO" "/zlatest is OK" fi ak-ipfs-key-list | grep zchain > /dev/null if [ $? != 0 ]; then - logit "[WARNING]" "zchain key is missing" + logit "WARNING" "zchain key is missing" ak-ipfs-key-gen zchain > $ZCHAIN if [ $? != 0 ]; then - logit "[ERROR]" "zchain fails to create" + logit "ERROR" "zchain fails to create" else - logit "[INFO]" "zchain created" + logit "INFO" "zchain created" fi else - logit "[INFO]" "zchain is there" + logit "INFO" "zchain is there" fi ak-ipfs-key-list | grep ak-config > /dev/null @@ -40,10 +40,10 @@ if [ $? != 0 ]; then logit "WARNING" "ak-config key is missing" ak-ipfs-key-gen ak-config if [ $? != 0 ]; then - logit "[ERROR]" "ak-config fails to create" + logit "ERROR" "ak-config fails to create" else - logit "[INFO]" "ak-config created" + logit "INFO" "ak-config created" fi else - logit "[INFO]" "ak-config is there" + logit "INFO" "ak-config is there" fi diff --git a/bin/ak-ipfs-files-cp b/bin/ak-ipfs-files-cp index 6ae766e..37a878a 100755 --- a/bin/ak-ipfs-files-cp +++ b/bin/ak-ipfs-files-cp @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files cp "$1" "$2" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to copy $1 to $2" + ak-logthis "$PROGRAM" "ERROR" "Failed to copy $1 to $2" exit 1 fi diff --git a/bin/ak-ipfs-files-ls b/bin/ak-ipfs-files-ls index 26a3313..80fc899 100755 --- a/bin/ak-ipfs-files-ls +++ b/bin/ak-ipfs-files-ls @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files ls "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to list $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to list $1" exit 1 fi diff --git a/bin/ak-ipfs-files-mkdir b/bin/ak-ipfs-files-mkdir index 6406b33..d6fb298 100755 --- a/bin/ak-ipfs-files-mkdir +++ b/bin/ak-ipfs-files-mkdir @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files mkdir "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to mkdir $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to mkdir $1" exit 1 fi diff --git a/bin/ak-ipfs-files-mv b/bin/ak-ipfs-files-mv index 8b64dba..67fa9b0 100755 --- a/bin/ak-ipfs-files-mv +++ b/bin/ak-ipfs-files-mv @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files mv "$1" "$2" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to move $1 to $2" + ak-logthis "$PROGRAM" "ERROR" "Failed to move $1 to $2" exit 1 fi diff --git a/bin/ak-ipfs-files-rm b/bin/ak-ipfs-files-rm index 490103e..cd5cb02 100755 --- a/bin/ak-ipfs-files-rm +++ b/bin/ak-ipfs-files-rm @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files rm "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to remove $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to remove $1" exit 1 fi diff --git a/bin/ak-ipfs-files-stat b/bin/ak-ipfs-files-stat index 5e3e537..09fda0f 100755 --- a/bin/ak-ipfs-files-stat +++ b/bin/ak-ipfs-files-stat @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs files stat "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get file's stats $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to get file's stats $1" exit 1 fi diff --git a/bin/ak-ipfs-get b/bin/ak-ipfs-get index ef8ba94..dedf503 100755 --- a/bin/ak-ipfs-get +++ b/bin/ak-ipfs-get @@ -1,8 +1,8 @@ #!/bin/bash PROGRAM="$(basename $0)" -ipfs --timeout=10s get "$1" +ipfs --timeout=10s get "$1" > /dev/null 2>&1 if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to get $1" exit 1 fi diff --git a/bin/ak-ipfs-key-gen b/bin/ak-ipfs-key-gen index e30ce8d..0ef5fe8 100755 --- a/bin/ak-ipfs-key-gen +++ b/bin/ak-ipfs-key-gen @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs key gen "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to generate key $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to generate key $1" exit 1 fi diff --git a/bin/ak-ipfs-key-list b/bin/ak-ipfs-key-list index 1106b40..b36cba1 100755 --- a/bin/ak-ipfs-key-list +++ b/bin/ak-ipfs-key-list @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs key list if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get key list" + ak-logthis "$PROGRAM" "ERROR" "Failed to get key list" exit 1 fi diff --git a/bin/ak-ipfs-key-list-full b/bin/ak-ipfs-key-list-full index 1c19c00..9ee3347 100755 --- a/bin/ak-ipfs-key-list-full +++ b/bin/ak-ipfs-key-list-full @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs key list -l if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get key list" + ak-logthis "$PROGRAM" "ERROR" "Failed to get key list" exit 1 fi diff --git a/bin/ak-ipfs-name-publish b/bin/ak-ipfs-name-publish index d1a938c..60169ed 100755 --- a/bin/ak-ipfs-name-publish +++ b/bin/ak-ipfs-name-publish @@ -3,7 +3,7 @@ PROGRAM="$(basename $0)" ipfs name publish "$1" "$2" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to get $1" exit 1 fi diff --git a/bin/ak-ipfs-name-resolve b/bin/ak-ipfs-name-resolve index 6368e19..32172c0 100755 --- a/bin/ak-ipfs-name-resolve +++ b/bin/ak-ipfs-name-resolve @@ -3,7 +3,7 @@ PROGRAM="$(basename $0)" ipfs name resolve "$1" if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to resolve $1" + ak-logthis "$PROGRAM" "ERROR" "Failed to resolve $1" exit 1 fi diff --git a/bin/ak-ipfs-starter b/bin/ak-ipfs-starter index 35b9168..c16424f 100755 --- a/bin/ak-ipfs-starter +++ b/bin/ak-ipfs-starter @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" screen -dmS ipfs-daemon ipfs daemon if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to start IPFS daemon" + ak-logthis "$PROGRAM" "ERROR" "Failed to start IPFS daemon" exit 1 fi diff --git a/bin/ak-ipfs-swarm-peers b/bin/ak-ipfs-swarm-peers index b1890be..eb67346 100755 --- a/bin/ak-ipfs-swarm-peers +++ b/bin/ak-ipfs-swarm-peers @@ -3,6 +3,6 @@ PROGRAM="$(basename $0)" ipfs swarm peers if [ "$?" != "0" ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "Failed to get list of peers" + ak-logthis "$PROGRAM" "ERROR" "Failed to get list of peers" exit 1 fi diff --git a/bin/ak-ipns-resolve b/bin/ak-ipns-resolve index e93218e..c01e822 100755 --- a/bin/ak-ipns-resolve +++ b/bin/ak-ipns-resolve @@ -9,18 +9,18 @@ usage(){ echo "Returns the resolved IPFS CIDv0" } logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -z $1 ] then rsld=$(ak-ipfs-name-resolve $1) if [ "$?" != 0 ] then - logit "[ERROR]" "Failed to resolve $1" + logit "ERROR" "Failed to resolve $1" exit 1 fi echo -n $rsld | sed -e 's/\/ipfs\///' - logit "[INFO]" "Resolved $1 to $rsld" + logit "INFO" "Resolved $1 to $rsld" else usage fi diff --git a/bin/ak-profile b/bin/ak-profile index 4033000..e7e6e48 100755 --- a/bin/ak-profile +++ b/bin/ak-profile @@ -5,7 +5,7 @@ TEMP="/tmp/aktmp" # Outputs to log file in the classic format :) logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } # Whatever the command is, we check if $ZPROFILEDIR is there. diff --git a/bin/ak-sm-filejoiner b/bin/ak-sm-filejoiner index f16abfc..6850104 100755 --- a/bin/ak-sm-filejoiner +++ b/bin/ak-sm-filejoiner @@ -76,7 +76,7 @@ then # We check if everything is okay sha512sum -c $MAPSDIR/$MAPSFILE if [ "$?" != "0" ]; then - logit "[ERROR]" "Error while checking sums" + logit "ERROR" "Error while checking sums" exit 1 fi diff --git a/bin/ak-sm-files b/bin/ak-sm-files index 17635d6..4265617 100755 --- a/bin/ak-sm-files +++ b/bin/ak-sm-files @@ -44,14 +44,14 @@ main(){ cd $TEMPASSIN echo "Adding $FILENAME" - logit "[INFO]" "Switching to tmp folder..." + logit "INFO" "Switching to tmp folder..." if [ $? == 0 ]; then logit "INFO" "Success" else logit "ERROR" "Error with tmp folder" exit 5 fi - logit "[INFO]" "Copying $1 to $TEMPASSIN" + logit "INFO" "Copying $1 to $TEMPASSIN" cp $CRP/$FILENAME $FILENAME if [ $? == 0 ]; then @@ -60,7 +60,7 @@ main(){ logit "ERROR" "Error copying..." fi - logit "[INFO]" "Adding $FILENAME to IPFS..." + logit "INFO" "Adding $FILENAME to IPFS..." FILE_IPFS_HASH=$(ak-ipfs-add $FILENAME) if [ $? == 0 ]; then logit "INFO" "Added $FILENAME to IPFS" @@ -68,7 +68,7 @@ main(){ logit "ERROR" "Error in adding the $FILENAME to IPFS" fi - logit "[INFO]" "Adding $FILE to SHAMAPSYS..." + logit "INFO" "Adding $FILE to SHAMAPSYS..." FILEMAP_SHA512_HASH=$(ak-sm-filesplitter $FILENAME) if [ $? == 0 ]; then logit "INFO" "Added $FILENAME to SHAMAPSYS" @@ -76,7 +76,7 @@ main(){ logit "ERROR" "Error in adding the $FILENAME to SHAMAPSYS" fi - logit "[INFO]" "Signing..." + logit "INFO" "Signing..." SIGN_FILE=$FILENAME".asc" gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $SIGN_FILE $FILENAME if [ $? == 0 ]; then @@ -85,7 +85,7 @@ main(){ logit "ERROR" "Error while signing" fi - logit "[INFO]" "Adding signature to IPFS" + logit "INFO" "Adding signature to IPFS" SIGNATURE=$(ak-ipfs-add $SIGN_FILE) if [ $? == 0 ]; then logit "INFO" "Added" @@ -93,7 +93,7 @@ main(){ logit "ERROR" "Error while adding" fi - logit "[INFO]" "Adding signature to SHAMAPSYS" + logit "INFO" "Adding signature to SHAMAPSYS" SHAMAPSIGMAP=$(ak-sm-filesplitter $SIGN_FILE) if [ $? == 0 ]; then logit "INFO" "Added" diff --git a/bin/ak-sm-filesplitter b/bin/ak-sm-filesplitter index 0d0ff30..d77b8ae 100755 --- a/bin/ak-sm-filesplitter +++ b/bin/ak-sm-filesplitter @@ -23,7 +23,7 @@ PROGRAM="$(basename $0)" if [ ! -f "$1" ] then - echo "[ERROR] File not found" + echo "ERROR File not found" exit 1 else FILE="$1" @@ -42,7 +42,7 @@ CURRENTDIR="$(pwd)/" # Our snippet for logging debug info logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } # Checking directories and create them if necessary @@ -53,14 +53,14 @@ then mkdir -p "$TECHDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $TECHDIR created!" + logit "INFO" "Folder $TECHDIR created!" else - logit "[ERROR]" "Problem occured while creating $TECHDIR" - echo "[ERROR] Can't create $TECHDIR" + logit "ERROR" "Problem occured while creating $TECHDIR" + echo "ERROR Can't create $TECHDIR" exit 1 fi else - logit "[INFO]" "Temp dir found" + logit "INFO" "Temp dir found" fi # FILEMAPSDIR @@ -69,14 +69,14 @@ then mkdir -p "$FILEMAPSDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $FILEMAPSDIR created!" + logit "INFO" "Folder $FILEMAPSDIR created!" else - logit "[ERROR]" "Problem occured while creating $FILEMAPSDIR" - echo "[ERROR] Can't create $FILEMAPSDIR" + logit "ERROR" "Problem occured while creating $FILEMAPSDIR" + echo "ERROR Can't create $FILEMAPSDIR" exit 1 fi else - logit "[INFO]" "Mapsdir found" + logit "INFO" "Mapsdir found" fi # CHKDIR @@ -85,14 +85,14 @@ then mkdir -p "$CHKDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $CHKDIR created!" + logit "INFO" "Folder $CHKDIR created!" else - logit "[ERROR]" "Problem occured while creating $CHKDIR" - echo "[ERROR] Can't create $CHKDIR" + logit "ERROR" "Problem occured while creating $CHKDIR" + echo "ERROR Can't create $CHKDIR" exit 1 fi else - logit "[INFO]" "Workdir found" + logit "INFO" "Workdir found" fi # Uncomment next line in case you want to debug the resulting script as well diff --git a/bin/ak-sm-merkle-tree b/bin/ak-sm-merkle-tree index 461930f..2ba5e91 100755 --- a/bin/ak-sm-merkle-tree +++ b/bin/ak-sm-merkle-tree @@ -26,7 +26,7 @@ PROGRAM="$(basename $0)" if [ ! -f "$1" ] then - echo "[ERROR] File not found" + echo "ERROR File not found" exit 1 else base64 $1 > file @@ -43,31 +43,31 @@ MERKLEDIR="$AK_WORKDIR/fmrk/" TEMPORARYDIR="$(ak-tempassin)" # A subdir to split the files there TECHDIR="$TEMPORARYDIR/chks/" -# A pin point to return from where we came from +# A pin point to return from where we came from CURRENTDIR="$(pwd)/" # Our snippet for logging debug info logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } # Checking directories and create them if necessary rm -rf $TEMPORARYDIR - + # TECHDIR if [ ! -d "$TECHDIR" ] then mkdir -p "$TECHDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $TECHDIR created!" + logit "INFO" "Folder $TECHDIR created!" else - logit "[ERROR]" "Problem occured while creating $TECHDIR" - echo "[ERROR] Can't create $TECHDIR" + logit "ERROR" "Problem occured while creating $TECHDIR" + echo "ERROR Can't create $TECHDIR" exit 1 fi else - logit "[INFO]" "Temp dir found" + logit "INFO" "Temp dir found" fi # FILEMAPSDIR @@ -76,14 +76,14 @@ then mkdir -p "$FILEMAPSDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $FILEMAPSDIR created!" + logit "INFO" "Folder $FILEMAPSDIR created!" else - logit "[ERROR]" "Problem occured while creating $FILEMAPSDIR" - echo "[ERROR] Can't create $FILEMAPSDIR" + logit "ERROR" "Problem occured while creating $FILEMAPSDIR" + echo "ERROR Can't create $FILEMAPSDIR" exit 1 fi else - logit "[INFO]" "Mapsdir found" + logit "INFO" "Mapsdir found" fi # CHKDIR @@ -92,14 +92,14 @@ then mkdir -p "$CHKDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $CHKDIR created!" + logit "INFO" "Folder $CHKDIR created!" else - logit "[ERROR]" "Problem occured while creating $CHKDIR" - echo "[ERROR] Can't create $CHKDIR" + logit "ERROR" "Problem occured while creating $CHKDIR" + echo "ERROR Can't create $CHKDIR" exit 1 fi else - logit "[INFO]" "Workdir found" + logit "INFO" "Workdir found" fi # MERKLEDIR @@ -108,14 +108,14 @@ then mkdir -p "$MERKLEDIR" if [ "$?" == 0 ] then - logit "[INFO]" "Folder $MERKLEDIR created!" + logit "INFO" "Folder $MERKLEDIR created!" else - logit "[ERROR]" "Problem occured while creating $MERKLEDIR" - echo "[ERROR] Can't create $MERKLEDIR" + logit "ERROR" "Problem occured while creating $MERKLEDIR" + echo "ERROR Can't create $MERKLEDIR" exit 1 fi else - logit "[INFO]" "Workdir found" + logit "INFO" "Workdir found" fi # Uncomment next line in case you want to debug the resulting script as well # echo 'set -xe' > $TEMPORARYDIR/cmd_queue.sh diff --git a/bin/ak-stellar-get-participants b/bin/ak-stellar-get-participants index 838ad08..82c5503 100755 --- a/bin/ak-stellar-get-participants +++ b/bin/ak-stellar-get-participants @@ -4,7 +4,7 @@ tempdir=`mktemp -d` tempfile="$tempdir/tmp" tempaddr="$tempdir/tmpaddr" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } stellarParticipants="$AK_WORKDIR/stellar-network-participants" stellarParticipantsOnline="$AK_WORKDIR/stellar-network-participants-online" @@ -49,9 +49,9 @@ show_ids(){ if [ "$flag" == "0" ] then echo $test >> $stellarParticipants - logit "[INFO]" "Added $test" + logit "INFO" "Added $test" else - logit "[INFO]" "$test already there. Skipping..." + logit "INFO" "$test already there. Skipping..." fi i="$(expr $i + 1)" done @@ -99,9 +99,9 @@ do if [ "$flag" == "0" ] then echo $addressValuePair >> $stellarParticipantsOnline - logit "[INFO]" "$p is configured with $(echo $addressValuePair | awk '{ print $2 }'). Added to online participants." + logit "INFO" "$p is configured with $(echo $addressValuePair | awk '{ print $2 }'). Added to online participants." else - logit "[INFO]" "$(echo $addressValuePair | awk '{ print $2 }') is already in $stellarParticipantsOnline. Skipping..." + logit "INFO" "$(echo $addressValuePair | awk '{ print $2 }') is already in $stellarParticipantsOnline. Skipping..." fi fi done < $stellarParticipants diff --git a/bin/ak-tempassin b/bin/ak-tempassin index ac7b600..575e55e 100755 --- a/bin/ak-tempassin +++ b/bin/ak-tempassin @@ -2,14 +2,14 @@ AK_TEMP="$(mktemp -d /tmp/aktmp-XXXXXXX)" PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -d "$AK_TEMP" ] then - logit "[ERROR]" "Could not make $AK_TEMP directory to work in" + logit "ERROR" "Could not make $AK_TEMP directory to work in" echo "Could not make $AK_TEMP directory to work in" exit 1 fi - -logit "[INFO]" "$AK_TEMP created successfully" + +logit "INFO" "$AK_TEMP created successfully" echo "$AK_TEMP" diff --git a/bin/ak-transactions b/bin/ak-transactions index 9573147..92a622f 100755 --- a/bin/ak-transactions +++ b/bin/ak-transactions @@ -5,11 +5,11 @@ _ak_modules_transactions_usage(){ } logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } _ak_modules_transactions_main(){ - logit "[INFO]" "$FROM_ADDRESS to $TO_ADDRESS value sent: $AMOUNT" + logit "INFO" "$FROM_ADDRESS to $TO_ADDRESS value sent: $AMOUNT" cat > transaction_file <" "[ERROR]" "sed didn't found $search" + ak-logthis "$PROGRAM" "ERROR" "sed didn't found $search" exit 1 fi IPFS="$(ak-ipfs-add $FOLLOWING)" if [ $? != 0 ] then - ak-logthis "<$PROGRAM>" "[ERROR]" "IPFS problem" + ak-logthis "$PROGRAM" "ERROR" "IPFS problem" exit 1 fi ak-profile set repositories "$IPFS" diff --git a/bin/ak-zblock-cache b/bin/ak-zblock-cache index f1a1c2b..ca4f736 100755 --- a/bin/ak-zblock-cache +++ b/bin/ak-zblock-cache @@ -1,7 +1,7 @@ #!/bin/bash PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } if [ ! -d "$AK_CACHEDIR/fzblocks" ] @@ -15,16 +15,16 @@ then then if [ "$(sha512sum $AK_ZBLOCKDIR/$1 | awk '{ print $1 }')" == "$(ak-zblock-show $1 | sha512sum | awk '{ print $1 }')" ] then - logit "[INFO]" "Cache already there and updated" + logit "INFO" "Cache already there and updated" else - logit "[INFO]" "Updating cache" + logit "INFO" "Updating cache" ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 fi - logit "[INFO]" "No cache found. Caching..." + logit "INFO" "No cache found. Caching..." ak-zblock-show "$1" if [ "$?" -ne "0" ] then - logit "[ERROR]" "ak-zblock-show failed..." + logit "ERROR" "ak-zblock-show failed..." exit 2 fi ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 @@ -32,10 +32,10 @@ then ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 if [ "$?" -ne "0" ] then - logit "[ERROR]" "ak-zblock-show failed..." + logit "ERROR" "ak-zblock-show failed..." exit 2 fi - logit "[ERROR]" "Could not find zblock $1..." + logit "ERROR" "Could not find zblock $1..." exit 1 fi exit 0 diff --git a/bin/ak-zblock-pack b/bin/ak-zblock-pack index 5d84976..25377bc 100755 --- a/bin/ak-zblock-pack +++ b/bin/ak-zblock-pack @@ -19,7 +19,7 @@ set -xe # Logging patch logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } # Below, the usage information @@ -48,13 +48,13 @@ main(){ do if [ "$p" == "$TO_CHECK" ] then - logit "[ERROR]" "Value $TO_CHECK already mentioned on the zchain" + logit "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" + + logit "INFO" "We are doing $ACTION with content $MESSAGE" # We add it to IPFS MESSAGE_HASH=$(ak-ipfs-add $MESSAGE) @@ -101,7 +101,7 @@ then if [ -f "$MESSAGE" ]; then main else - logit "[ERROR]" "File does not exist. Aborting..." + logit "ERROR" "File does not exist. Aborting..." exit 1 fi @@ -113,42 +113,42 @@ then ak-ipfs-name-publish --key=zchain $ZBLOCK > /dev/null 2>&1 if [ "$?" -ne 0 ] then - logit "[ERROR]" "Failed publishing ZBLOCK: $ZBLOCK" + logit "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" + logit "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." + logit "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" + logit "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" + logit "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" + logit "ERROR" "Could not copy $ZBLOCK to /zlatest" exit 1 fi ak-config publish if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not publish new configuration" + logit "ERROR" "Could not publish new configuration" exit 1 fi else diff --git a/bin/ak-zblock-show b/bin/ak-zblock-show index 3244c4b..d0ebcc5 100755 --- a/bin/ak-zblock-show +++ b/bin/ak-zblock-show @@ -8,7 +8,7 @@ PROGRAM="$(basename $0)" logit(){ - ak-logthis "<$PROGRAM>" "$1" "$2" + ak-logthis "$PROGRAM" "$1" "$2" } usage(){ @@ -28,7 +28,7 @@ then echo $1 | grep -e 'Qm.\{44\}' >/dev/null if [ "$?" -ne 0 ] then - logit "[ERROR]" "Argument provided ($1) was not an IPFS CIDv0 string" + logit "ERROR" "Argument provided ($1) was not an IPFS CIDv0 string" exit 1 fi entrance="$1" diff --git a/bin/ak-zchain-rebase b/bin/ak-zchain-rebase index 255ec69..e5d9b52 100755 --- a/bin/ak-zchain-rebase +++ b/bin/ak-zchain-rebase @@ -43,7 +43,7 @@ rebase (){ ak-config publish if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not publish new configuration" + logit "ERROR" "Could not publish new configuration" exit 1 fi echo "Rebase was successful" diff --git a/bin/ak-zchain-reset b/bin/ak-zchain-reset index 8b72810..f19e1b0 100755 --- a/bin/ak-zchain-reset +++ b/bin/ak-zchain-reset @@ -1,5 +1,5 @@ #!/bin/bash -PROGRAM=$(basename $0) +PROGRAM=$(basename $0) usage(){ echo "$PROGRAM - Zchain reset" echo "" @@ -42,7 +42,7 @@ reset (){ ak-config publish if [ "$?" -ne 0 ] then - logit "[ERROR]" "Could not publish new configuration" + logit "ERROR" "Could not publish new configuration" exit 1 fi -- cgit v1.2.3