diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-03-01 19:20:34 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-03-01 19:20:34 +0200 |
commit | 7affa2082f61455a413d0c8fea08e79935d4f308 (patch) | |
tree | 7efb39304c06b1c6e525a911308622818ef32d3b /bin/ak-sm-files | |
parent | cd43e57b999422980ea95df7f1d03117342e358e (diff) | |
download | arching-kaos-tools-7affa2082f61455a413d0c8fea08e79935d4f308.tar.gz arching-kaos-tools-7affa2082f61455a413d0c8fea08e79935d4f308.tar.bz2 arching-kaos-tools-7affa2082f61455a413d0c8fea08e79935d4f308.zip |
Spacing adjustment
Diffstat (limited to 'bin/ak-sm-files')
-rwxr-xr-x | bin/ak-sm-files | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/bin/ak-sm-files b/bin/ak-sm-files index 7ee3d42..17635d6 100755 --- a/bin/ak-sm-files +++ b/bin/ak-sm-files @@ -6,28 +6,29 @@ CRD=$(cat .pwd) PROGRAM="$(basename $0)" #set -xe 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 + mkdir $ZFILESDIR + if [ $? == 0 ] + then + logit "INFO" "Folder $ZFILESDIR created!" + else + logit "ERROR" "Failed to create $ZFILESDIR folder" + exit 1 + fi + cd $ZFILESDIR else - logit "[INFO]" "$ZFILESDIR found!" + logit "INFO" "$ZFILESDIR found!" fi usage(){ - echo "$PROGRAM - file" - echo " add <file>" - echo " index" - echo " full-index" - echo " ls-map-files" + echo "$PROGRAM - file" + echo " -h, --help Prints this help message" + echo " add <file> Adds file to zchain as a zblock" + echo " index List files" + echo " full-index List all files" + echo " ls-map-files List map files" } add(){ @@ -45,59 +46,59 @@ main(){ echo "Adding $FILENAME" logit "[INFO]" "Switching to tmp folder..." 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" cp $CRP/$FILENAME $FILENAME if [ $? == 0 ]; then - logit "[INFO]" "Copied successfully" + logit "INFO" "Copied successfully" else - logit "[ERROR]" "Error copying..." + logit "ERROR" "Error copying..." fi logit "[INFO]" "Adding $FILENAME to IPFS..." FILE_IPFS_HASH=$(ak-ipfs-add $FILENAME) if [ $? == 0 ]; then - logit "[INFO]" "Added $FILENAME to IPFS" + logit "INFO" "Added $FILENAME to IPFS" else - logit "[ERROR]" "Error in adding the $FILENAME to IPFS" + logit "ERROR" "Error in adding the $FILENAME to IPFS" fi logit "[INFO]" "Adding $FILE to SHAMAPSYS..." FILEMAP_SHA512_HASH=$(ak-sm-filesplitter $FILENAME) if [ $? == 0 ]; then - logit "[INFO]" "Added $FILENAME to SHAMAPSYS" + logit "INFO" "Added $FILENAME to SHAMAPSYS" else - logit "[ERROR]" "Error in adding the $FILENAME to SHAMAPSYS" + logit "ERROR" "Error in adding the $FILENAME to SHAMAPSYS" fi 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 - logit "[INFO]" "Signed" + logit "INFO" "Signed" else - logit "[ERROR]" "Error while signing" + logit "ERROR" "Error while signing" fi logit "[INFO]" "Adding signature to IPFS" SIGNATURE=$(ak-ipfs-add $SIGN_FILE) if [ $? == 0 ]; then - logit "[INFO]" "Added" + logit "INFO" "Added" else - logit "[ERROR]" "Error while adding" + logit "ERROR" "Error while adding" fi logit "[INFO]" "Adding signature to SHAMAPSYS" SHAMAPSIGMAP=$(ak-sm-filesplitter $SIGN_FILE) if [ $? == 0 ]; then - logit "[INFO]" "Added" + logit "INFO" "Added" else - logit "[ERROR]" "Error while adding" + logit "ERROR" "Error while adding" fi cat > data <<EOF @@ -118,10 +119,10 @@ EOF ak-zblock-pack sha-files/announce $(pwd)/data if [ $? == 0 ] then - echo "cool" + echo "cool" else - echo "not?" - exit 2 + echo "not?" + exit 2 fi } @@ -134,7 +135,7 @@ ls-mapfiles(){ for f in `find . -type f | sed -e 's/\.\///g'`;do FILENAME="$(tail -n1 $f | grep '^[abcdef1234567890]' | awk '{ print $2 }')" FILEHASH="$(tail -n1 $f | grep '^[abcdef1234567890]' | awk '{ print $1 }')" - MAPFILE="$f" + MAPFILE="$f" printf "\nMap: %s\nFilename: %s\nSum: %s\n\n" $MAPFILE $FILENAME $FILEHASH done } @@ -150,7 +151,7 @@ if [ ! -z $1 ]; then index) index; exit;; full-index) full-index; exit;; ls-map-files) ls-mapfiles; exit;; - *) usage; exit;; - esac + *) usage; exit;; + esac else usage fi |