From 7affa2082f61455a413d0c8fea08e79935d4f308 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 1 Mar 2024 19:20:34 +0200 Subject: Spacing adjustment --- bin/ak-articles | 150 ++++++++++----------- bin/ak-categories | 132 +++++++++--------- bin/ak-cli | 2 +- bin/ak-comments | 80 +++++------ bin/ak-config | 2 +- bin/ak-enter | 4 +- bin/ak-files | 8 +- bin/ak-ipfs-check | 2 +- bin/ak-json2bash | 4 +- bin/ak-news | 21 ++- bin/ak-profile | 291 ++++++++++++++++++++-------------------- bin/ak-reference | 2 +- bin/ak-repositories | 236 ++++++++++++++++---------------- bin/ak-roadmap | 26 ++-- bin/ak-sm-files | 75 ++++++----- bin/ak-sm-filesplitter | 10 +- bin/ak-sm-merkle-tree | 10 +- bin/ak-startup | 2 +- bin/ak-stellar-get-participants | 4 +- bin/ak-todos | 8 +- bin/ak-unfollow | 4 +- bin/ak-zblock-manipulator | 4 +- bin/ak-zblock-pack | 2 +- bin/ak-zchain-chk | 200 +++++++++++++-------------- 24 files changed, 639 insertions(+), 640 deletions(-) diff --git a/bin/ak-articles b/bin/ak-articles index 5eaf225..e6c45c4 100755 --- a/bin/ak-articles +++ b/bin/ak-articles @@ -3,16 +3,16 @@ ZARTICLESDIR="$AK_WORKDIR/articles" TEMP="/tmp/aktmp" echo $ZARTICLESDIR if [ ! -d $ZARTICLESDIR ]; then - mkdir $ZARTICLESDIR - cd $ZARTICLESDIR - git init - echo "Articles repository" > README - echo "Qmetc" >> README - git add README - git commit -m "Initiated articles repository" - echo "zarticlesdir created along with git repo" + mkdir $ZARTICLESDIR + cd $ZARTICLESDIR + #git init + echo "Articles repository" > README + echo "Qmetc" >> README + #git add README + #git commit -m "Initiated articles repository" + logit "INFO" "zarticlesdir created" else - echo "zarticlesdir found" + logit "INFO" "zarticlesdir found" fi _ak_modules_articles_create(){ @@ -36,55 +36,55 @@ _ak_modules_articles_create(){ # rm -rf $TEMP } _ak_modules_articles_index(){ - FILES="$(ls -1 $ZARTICLESDIR)" - i=0 - for FILE in $FILES - do - DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') - TITLE=$(head -n 1 $ZARTICLESDIR/$FILE) - echo $i \| $DATE \| $TITLE - let i+=1 - done + FILES="$(ls -1 $ZARTICLESDIR)" + i=0 + for FILE in $FILES + do + DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') + TITLE=$(head -n 1 $ZARTICLESDIR/$FILE) + echo $i \| $DATE \| $TITLE + let i+=1 + done } _ak_modules_articles_title(){ echo ak-articles-cli echo "--------------" } _ak_modules_articles_import(){ - echo "#TODO" - if [ ! -z $1 ] - then - if [ ! -d $1 ] - then - echo "Folder does not exists" - exit 4 - else - echo "Folder $1 exists" - fl="$(ls -1 $1)" - for f in $fl - do - _ak_modules_articles_add $1/$f - done - fi - else - echo "No value" - exit 6 - fi - exit 224 + echo "#TODO" + if [ ! -z $1 ] + then + if [ ! -d $1 ] + then + echo "Folder does not exists" + exit 4 + else + echo "Folder $1 exists" + fl="$(ls -1 $1)" + for f in $fl + do + _ak_modules_articles_add $1/$f + done + fi + else + echo "No value" + exit 6 + fi + exit 224 } _ak_modules_articles_add(){ TEMP="$(ak-tempassin)" cd $TEMP - if [ -f $1 ]; then - FILE="$1" - echo "Adding articles from " $FILE - DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') - TITLE=$(head -n 1 $FILE) - FILE_IPFS_HASH=$(ak-ipfs-add $FILE) - FILE_SIGN_FILE=$FILE".asc" - gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE - FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE) - cat > data < data < #TODO" - echo "add Creates a data file from the articles file you point to" - echo "create Vim is going to pop up, you will write and save your" - echo " articlesletter and it's going to be saved" - exit 0 + echo " -h, --help Prints this help message" + echo " index Prints an indexed table of your articles files" + echo " import #TODO" + echo " add Creates a data file from the articles file you point to" + echo " create Vim is going to pop up, you will write and save your" + echo " articlesletter and it's going to be saved" + exit 0 } _ak_modules_articles_title if [ ! -z $1 ]; then - case $1 in - help) _ak_modules_articles_usage; exit;; - index) _ak_modules_articles_index; exit;; - import) _ak_modules_articles_import $2; exit;; - add) _ak_modules_articles_add $2; exit;; - create) _ak_modules_articles_create; exit;; - * ) _ak_modules_articles_usage;; - esac + case $1 in + -h | --help) _ak_modules_articles_usage; exit;; + index) _ak_modules_articles_index; exit;; + import) _ak_modules_articles_import $2; exit;; + add) _ak_modules_articles_add $2; exit;; + create) _ak_modules_articles_create; exit;; + * ) _ak_modules_articles_usage;; + esac else _ak_modules_articles_usage fi diff --git a/bin/ak-categories b/bin/ak-categories index dbcf42c..32edb4f 100755 --- a/bin/ak-categories +++ b/bin/ak-categories @@ -4,77 +4,77 @@ PROGRAM="$(basename $0)" echo $AK_CATEGORIES if [ ! -d $AK_CATEGORIES ]; then - mkdir $AK_CATEGORIES - cd $AK_CATEGORIES - echo "AK_CATEGORIES created" + mkdir $AK_CATEGORIES + cd $AK_CATEGORIES + echo "AK_CATEGORIES created" else - echo "AK_CATEGORIES found" + echo "AK_CATEGORIES found" fi _ak_modules_categories_create(){ TEMP="$(ak-tempassin)" cd $TEMP - export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" - vi $NEWS_FILE - echo "Renaming..." - TITLE="$(head -n 1 $NEWS_FILE)" - TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) - IPFS_FILE=$(ak-ipfs-add $NEWS_FILE) - mv $NEWS_FILE $AK_CATEGORIES/$TO_FILE - sed -e 's,Qm.*,'"$IPFS_FILE"',g' $AK_CATEGORIES/README - _ak_modules_categories_add $AK_CATEGORIES/$TO_FILE - cd $AK_CATEGORIES + export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" + vi $NEWS_FILE + echo "Renaming..." + TITLE="$(head -n 1 $NEWS_FILE)" + TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) + IPFS_FILE=$(ak-ipfs-add $NEWS_FILE) + mv $NEWS_FILE $AK_CATEGORIES/$TO_FILE + sed -e 's,Qm.*,'"$IPFS_FILE"',g' $AK_CATEGORIES/README + _ak_modules_categories_add $AK_CATEGORIES/$TO_FILE + cd $AK_CATEGORIES } _ak_modules_categories_index(){ - FILES="$(ls -1 $AK_CATEGORIES)" - i=0 - for FILE in $FILES - do - DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') - TITLE=$(head -n 1 $AK_CATEGORIES/$FILE) - echo $i \| $DATE \| $TITLE - let i+=1 - done + FILES="$(ls -1 $AK_CATEGORIES)" + i=0 + for FILE in $FILES + do + DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') + TITLE=$(head -n 1 $AK_CATEGORIES/$FILE) + echo $i \| $DATE \| $TITLE + let i+=1 + done } _ak_modules_categories_title(){ echo "$PROGRAM" } _ak_modules_categories_import(){ - echo "#TODO" - if [ ! -z $1 ] - then - if [ ! -d $1 ] - then - echo "Folder does not exists" - exit 4 - else - echo "Folder $1 exists" - fl="$(ls -1 $1)" - for f in $fl - do - _ak_modules_categories_add $1/$f - done - fi - else - echo "No value" - exit 6 - fi - exit 224 + echo "#TODO" + if [ ! -z $1 ] + then + if [ ! -d $1 ] + then + echo "Folder does not exists" + exit 4 + else + echo "Folder $1 exists" + fl="$(ls -1 $1)" + for f in $fl + do + _ak_modules_categories_add $1/$f + done + fi + else + echo "No value" + exit 6 + fi + exit 224 } _ak_modules_categories_add(){ TEMP="$(ak-tempassin)" cd $TEMP - if [ -f $1 ]; then - FILE="$1" - echo "Adding news from " $FILE - DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') - TITLE=$(head -n 1 $FILE) - FILE_IPFS_HASH=$(ak-ipfs-add $FILE) - FILE_SIGN_FILE=$FILE".asc" - gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE - FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE) - cat > data < data < data - else - echo "File $FILE doesn't exist"; - exit 2 - fi + if [ -f "$ZCOMMENTSDIR/$1" ]; then + FILE=$ZCOMMENTSDIR/$1 + echo "Adding comments from " $FILE + DATETIME="$1" + FILE_IPFS_HASH=$(ak-ipfs-add $FILE) + FILE_SIGN_FILE=$FILE".asc" + gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE + FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE) + printf '{"datetime":"%s","ipfs":"%s","detach":"%s"}' $DATETIME $FILE_IPFS_HASH $FILE_SIGNATURE > data + else + echo "File $FILE doesn't exist"; + exit 2 + fi REFERENCE="$(ak-zblock-pack "comments/add" $(pwd)/data)" - if [ $? == 0 ] - then - echo "Comment added successfully" - else - echo "error??" - exit 1 - fi + if [ $? == 0 ] + then + echo "Comment added successfully" + else + echo "error??" + exit 1 + fi } _ak_modules_comments_usage(){ _ak_modules_comments_title @@ -91,12 +91,12 @@ _ak_modules_comments_usage(){ } if [ ! -z $1 ]; then - case $1 in - help) _ak_modules_comments_usage; exit;; - index) _ak_modules_comments_index; exit;; - add) _ak_modules_comments_add $2 $3; exit;; - create) _ak_modules_comments_create $2; exit;; - * ) _ak_modules_comments_usage;; - esac + case $1 in + help) _ak_modules_comments_usage; exit;; + index) _ak_modules_comments_index; exit;; + add) _ak_modules_comments_add $2 $3; exit;; + create) _ak_modules_comments_create $2; exit;; + * ) _ak_modules_comments_usage;; + esac else _ak_modules_comments_usage fi diff --git a/bin/ak-config b/bin/ak-config index c20e8d7..9ccb567 100755 --- a/bin/ak-config +++ b/bin/ak-config @@ -24,7 +24,7 @@ _ak_config_show(){ rm $KEY echo ' -{ +{ "profile":'$(ak-profile index | jq -cM)', "genesis":"'$(cat $HOME/.arching-kaos/config/zgenesis)'", "gpg":"'$GPG_PUB_KEY'", diff --git a/bin/ak-enter b/bin/ak-enter index ae542fb..3313329 100755 --- a/bin/ak-enter +++ b/bin/ak-enter @@ -87,9 +87,9 @@ while [ "$#" ]; do logit "[ERROR]" "Could not resolve IPNS name" exit 1 fi - shift + shift ;; - *) + *) test="$1" if [ ! -z "$test" ] && [ "$fromIpns" == "0" ] then diff --git a/bin/ak-files b/bin/ak-files index 25dc69b..20083ab 100755 --- a/bin/ak-files +++ b/bin/ak-files @@ -22,7 +22,7 @@ else fi _ak_modules_files_usage(){ - echo "$PROGRAM - file" + echo "$PROGRAM - file" } _ak_modules_files_add(){ @@ -94,10 +94,10 @@ echo "Publishing..." ak-zblock-pack files/add $PWD/data if [ $? == 0 ] then - echo "cool" + echo "cool" else - echo "not?" - exit 2 + echo "not?" + exit 2 fi } diff --git a/bin/ak-ipfs-check b/bin/ak-ipfs-check index 0ee3e3c..d54f5fc 100755 --- a/bin/ak-ipfs-check +++ b/bin/ak-ipfs-check @@ -37,7 +37,7 @@ fi ak-ipfs-key-list | grep ak-config > /dev/null if [ $? != 0 ]; then - logit "[WARNING]" "ak-config key is missing" + logit "WARNING" "ak-config key is missing" ak-ipfs-key-gen ak-config if [ $? != 0 ]; then logit "[ERROR]" "ak-config fails to create" diff --git a/bin/ak-json2bash b/bin/ak-json2bash index 85af2bc..3ff6bef 100755 --- a/bin/ak-json2bash +++ b/bin/ak-json2bash @@ -1,9 +1,9 @@ #!/bin/bash # # ak-json2bash -# +# # Kaotisk Hund -# +# # Strips " , { } from input and replaces ":" with = # # Usage: diff --git a/bin/ak-news b/bin/ak-news index b730821..9824788 100755 --- a/bin/ak-news +++ b/bin/ak-news @@ -25,7 +25,7 @@ cd $ZNEWSDIR _ak_modules_news_create(){ TEMP="$(ak-tempassin)" cd $TEMP - cd + cd curpath="$(pwd)" export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" vi $NEWS_FILE @@ -38,7 +38,7 @@ _ak_modules_news_create(){ _ak_modules_news_add $TO_FILE echo "Adding to git repo..." cd $ZNEWSDIR - # rm -rf $TEMP + # rm -rf $TEMP } _ak_modules_news_index(){ FILES="$(ls -1 $ZNEWSDIR)" @@ -58,7 +58,7 @@ _ak_modules_news_index(){ printf "%3d | %5s | %52s | %10s | %56s \n"\ "$i" "$ONLINE" "$IPFS_HASH" "$DATE" "$TITLE" let i+=1 - done + done rm temp } _ak_modules_news_title(){ @@ -161,14 +161,13 @@ EOF fi } _ak_modules_news_usage(){ - echo "#TODO" - echo "All you need to know is that there are two options available:" - echo "help Prints this help message" - echo "local-index Prints an indexed table of your news files" - echo "import #TODO" - echo "add Creates a data file from the news file you point to" - echo "create Vim is going to pop up, you will write and save your" - echo " newsletter and it's going to be saved" + echo "-h, --help Prints this help message" + echo "local-index Prints an indexed table of your news files" + echo "import #TODO" + echo "add Creates a data file from the news file you point to" + echo "create Vim is going to pop up, you will write and save your" + echo " newsletter and it's going to be saved" + echo "specs Print specs of data block" exit 0 } _ak_modules_news_read(){ diff --git a/bin/ak-profile b/bin/ak-profile index 3f72263..4033000 100755 --- a/bin/ak-profile +++ b/bin/ak-profile @@ -11,11 +11,11 @@ logit(){ # Whatever the command is, we check if $ZPROFILEDIR is there. # If NOT we create it and we change dir there. if [ ! -d $ZPROFILEDIR ]; then - mkdir $ZPROFILEDIR - cd $ZPROFILEDIR - logit "[INFO]" "zprofiledir created" + mkdir $ZPROFILEDIR + cd $ZPROFILEDIR + logit "INFO" "zprofiledir created" else - logit "[INFO]" "zprofiledir found" + logit "INFO" "zprofiledir found" fi @@ -25,189 +25,190 @@ fi # Hence, we need a specific DATA block that actually has the announcement of a # {"key":"value"} pair. _ak_modules_profile_show(){ - if [ ! -z $1 ] - then - logit "[INFO]" "Working with $1" + if [ ! -z $1 ] + then + logit "INFO" "Working with $1" ak-ipfs-cat $(echo $(ak-ipfs-cat $1) | jq '.ipfs' -r) - else - echo "No DATA provided" - exit 1 - fi + else + echo "No DATA provided" + exit 1 + fi } # This should retrieve a specific value from our profile otherwise it dumps the # whole profile values. _ak_modules_profile_propget(){ - if [ ! -z $1 ] - then - if [ ! -f $ZPROFILEDIR/$1 ] - then - echo "property not found" - else - cat $ZPROFILEDIR/$1 - fi - else - echo "No particular property... indexing" - _ak_modules_profile_index - fi + if [ ! -z $1 ] + then + if [ ! -f $ZPROFILEDIR/$1 ] + then + echo "property not found" + else + cat $ZPROFILEDIR/$1 + fi + else + echo "No particular property... indexing" + _ak_modules_profile_index + fi } propwrite(){ - cat > $ZPROPERTY_FILE << EOF + cat > $ZPROPERTY_FILE << EOF { "$ZPROPERTY_KEY":"${ZPROPERTY_VALUE}" } EOF - if [ $? == 0 ] - then - echo "Added successfully... proceeding" - IPFS_FILE=$(ak-ipfs-add $ZPROPERTY_FILE) - echo "Prop writting,,, $IPFS_FILE" - _ak_modules_profile_add $ZPROPERTY_KEY - cd $ZPROFILEDIR - else - echo "Couldn't write to file $ZPROFILEDIR/$TO_FILE" - exit 1 - fi + if [ $? == 0 ] + then + echo "Added successfully... proceeding" + IPFS_FILE=$(ak-ipfs-add $ZPROPERTY_FILE) + echo "Prop writting,,, $IPFS_FILE" + _ak_modules_profile_add $ZPROPERTY_KEY + cd $ZPROFILEDIR + else + echo "Couldn't write to file $ZPROFILEDIR/$TO_FILE" + exit 1 + fi } _ak_modules_profile_propset(){ - if [ ! -z $1 ] - then - ZPROPERTY_FILE="$ZPROFILEDIR/$1" - ZPROPERTY_KEY="$1" - if [ ! -f $ZPROPERTY_FILE ] - then - echo "No such property: $ZPROPERTY_KEY ... creating" - ZPROPERTY_VALUE="$2" - if [ ! -z "$ZPROPERTY_VALUE" ] - then - touch $ZPROPERTY_FILE - echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" - propwrite #"$ZPROPERTY_FILE" "${ZPROPERTY_VALUE}" - else - echo "No value for $1" - fi - else - echo found $ZPROPERTY_FILE - echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" - ZPROPERTY_VALUE="$2" - read -p "Overwrite $1 with ${ZPROPERTY_VALUE} ? " yn - case $yn in - [Yy]* ) propwrite;;# "$ZPROPERTY_" "${ZPROPERTY_VALUE}";; - [Nn]* ) exit 130;; - * ) echo "Answer please";; - esac - echo $IPFS_FILE - _ak_modules_profile_show $IPFS_FILE - fi - else - echo "conditions unmet" - exit 244 - fi + if [ ! -z $1 ] + then + ZPROPERTY_FILE="$ZPROFILEDIR/$1" + ZPROPERTY_KEY="$1" + if [ ! -f $ZPROPERTY_FILE ] + then + echo "No such property: $ZPROPERTY_KEY ... creating" + ZPROPERTY_VALUE="$2" + if [ ! -z "$ZPROPERTY_VALUE" ] + then + touch $ZPROPERTY_FILE + echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" + propwrite #"$ZPROPERTY_FILE" "${ZPROPERTY_VALUE}" + else + echo "No value for $1" + fi + else + echo found $ZPROPERTY_FILE + echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" + ZPROPERTY_VALUE="$2" + read -p "Overwrite $1 with ${ZPROPERTY_VALUE} ? " yn + case $yn in + [Yy]* ) propwrite;;# "$ZPROPERTY_" "${ZPROPERTY_VALUE}";; + [Nn]* ) exit 130;; + * ) echo "Answer please";; + esac + echo $IPFS_FILE + _ak_modules_profile_show $IPFS_FILE + fi + else + echo "conditions unmet" + exit 244 + fi } _ak_modules_profile_index(){ - FILES="$(ls -1 $ZPROFILEDIR)" - i=0 - echo -n "{" - for FILE in $FILES - do - if [ $FILE != "README" ]; then - if [ $i != "0" ]; then - echo -n ","; - fi - PROP=$(echo $(cat $ZPROFILEDIR/$FILE | ak-json2bash) | cut -d '=' -f 1 | awk '{print $0}') - VAL=$(echo $(cat $ZPROFILEDIR/$FILE | ak-json2bash) | cut -d '=' -f 2 | awk '{print $1}') - echo -n '"'$PROP'":"'$VAL'"'; - let i+=1 - fi - done - echo "}" + FILES="$(ls -1 $ZPROFILEDIR)" + i=0 + echo -n "{" + for FILE in $FILES + do + if [ $FILE != "README" ]; then + if [ $i != "0" ]; then + echo -n ","; + fi + PROP=$(echo $(cat $ZPROFILEDIR/$FILE | ak-json2bash) | cut -d '=' -f 1 | awk '{print $0}') + VAL=$(echo $(cat $ZPROFILEDIR/$FILE | ak-json2bash) | cut -d '=' -f 2 | awk '{print $1}') + echo -n '"'$PROP'":"'$VAL'"'; + let i+=1 + fi + done + echo "}" } _ak_modules_profile_import(){ - if [ ! -z $1 ] - then - if [ ! -d $1 ] - then - echo "Profile folder check: Folder $1 does not exist. Stopping..." - exit 4 - else - echo "Profile folder check: Folder $1 exists." - fl="$(ls -1 $1)" - for f in $fl - do - _ak_modules_profile_add $1/$f - done - fi - else - echo "No value" - exit 6 - fi - exit 224 + if [ ! -z $1 ] + then + if [ ! -d $1 ] + then + echo "Profile folder check: Folder $1 does not exist. Stopping..." + exit 4 + else + echo "Profile folder check: Folder $1 exists." + fl="$(ls -1 $1)" + for f in $fl + do + _ak_modules_profile_add $1/$f + done + fi + else + echo "No value" + exit 6 + fi + exit 224 } # Adds a file as a profile/add ACTION on the zchain. _ak_modules_profile_add(){ TEMP="$(ak-tempassin)" cd $TEMP - if [ -f $ZPROFILEDIR/$1 ]; then - FILE="$ZPROFILEDIR/$1" - echo "Adding from " $FILE - FILE_IPFS_HASH=$(ak-ipfs-add $FILE) - FILE_SIGN_FILE=$(pwd)/$1".asc" - gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE - FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE) - cat > data < data <\t\t\tShow profile entry from specified DATA IPFS CIDv0" - echo -e "\tset \t\tSets a profile value" - echo -e "\tget \t\t\tGets a profile value from the on-disk file." - echo "" + echo "" + echo " -h, --help Prints this help message" + echo " index Show current status" + echo " show Show profile entry from specified DATA IPFS CIDv0" + echo " set Sets a profile value" + echo " get Gets a profile value from the on-disk file." + echo "" echo "Advanced (use with caution may produce duplicate entries):" - echo -e "\tadd \t\t\tCreates a data file from the profile file you point to (file should already be in ZPROFILEDIR." - echo -e "\timport \t\t\tImport a folder to zchain #TODO" - echo "" - exit 0 + echo " add Creates a data file from the profile file you point" + echo " to (file should already be in ZPROFILEDIR." + echo " import Import a folder to zchain #TODO" + echo "" + exit 0 } if [ ! -z $1 ]; then - case $1 in - help) _ak_modules_profile_usage; exit;; - index) _ak_modules_profile_index; exit;; - show) _ak_modules_profile_show $2; exit;; - import) _ak_modules_profile_import $2; exit;; - add) _ak_modules_profile_add $2; exit;; - set) _ak_modules_profile_propset $2 "$3"; exit;; - get) _ak_modules_profile_propget $2; exit;; - * ) _ak_modules_profile_usage;; - esac + case $1 in + -h | --help) _ak_modules_profile_usage; exit;; + index) _ak_modules_profile_index; exit;; + show) _ak_modules_profile_show $2; exit;; + import) _ak_modules_profile_import $2; exit;; + add) _ak_modules_profile_add $2; exit;; + set) _ak_modules_profile_propset $2 "$3"; exit;; + get) _ak_modules_profile_propget $2; exit;; + * ) _ak_modules_profile_usage;; + esac else _ak_modules_profile_usage fi diff --git a/bin/ak-reference b/bin/ak-reference index 231af00..4c70b11 100755 --- a/bin/ak-reference +++ b/bin/ak-reference @@ -45,7 +45,7 @@ _ak_modules_reference_index(){ REFE=$(tail -n 1 $ZREFERENCESDIR/$FILE) echo $i \| $DATE \| $TITLE \| $REFE let i+=1 - done + done } _ak_modules_reference_title(){ echo ak-references-cli diff --git a/bin/ak-repositories b/bin/ak-repositories index 0344467..7689e08 100755 --- a/bin/ak-repositories +++ b/bin/ak-repositories @@ -6,146 +6,146 @@ if [ ! -d $BAREDIR ]; then mkdir $BAREDIR; fi if [ ! -d $REPODIR ]; then echo "no $REPODIR" && exit; fi if [ ! -f $REPOSTORE ]; then touch $REPOSTORE; fi import(){ - REPOS="$(ls -1 $REPODIR)" - for PROJECT in $REPOS - do - cd $BAREDIR - # Can be as well be - # git clone --bare $REPODIR/$PROJECT/.git - # or whatever form git let's you use - git clone --bare http://git.h.kaotisk-hund.com/$PROJECT/.git - if [ $? == 0 ] - then - cd $PROJECT.git - git repack -a - IPFS="$(ak-ipfs-add .)" - ak-ipfs-key-gen "$PROJECT.git" - ak-ipfs-name-publish --key="$PROJECT.git" /ipfs/$IPFS - cd $HOME/bare - else - echo "$PROJECT not a git repo" - fi - done + REPOS="$(ls -1 $REPODIR)" + for PROJECT in $REPOS + do + cd $BAREDIR + # Can be as well be + # git clone --bare $REPODIR/$PROJECT/.git + # or whatever form git let's you use + git clone --bare http://git.h.kaotisk-hund.com/$PROJECT/.git + if [ $? == 0 ] + then + cd $PROJECT.git + git repack -a + IPFS="$(ak-ipfs-add .)" + ak-ipfs-key-gen "$PROJECT.git" + ak-ipfs-name-publish --key="$PROJECT.git" /ipfs/$IPFS + cd $HOME/bare + else + echo "$PROJECT not a git repo" + fi + done } update(){ - if [ ! -z $1 ] - then - USING="$1" - REPO="$REPODIR/$1/.git" - BARE="$BAREDIR/$1.git" - BARENAME="$1.git" - if [ -d $BARE ] - then - cd $BARE - git pull - git repack -a - IPFS="$(ak-ipfs-add .)" - ak-ipfs-name-publish --key="$BARENAME" /ipfs/$IPFS - echo "DONE" - else - echo "NO BARE TO UPDATE" - echo "updating all..." - fi - else - BARES="$(ls -1 $BAREDIR)" - cd $BAREDIR - for PROJECT in $BARES - do - cd "$PROJECT" - git pull - git repack -a - IPFS="$(ak-ipfs-add .)" - ak-ipfs-name-publish --key="$PROJECT" /ipfs/$IPFS - cd $BAREDIR - done - fi + if [ ! -z $1 ] + then + USING="$1" + REPO="$REPODIR/$1/.git" + BARE="$BAREDIR/$1.git" + BARENAME="$1.git" + if [ -d $BARE ] + then + cd $BARE + git pull + git repack -a + IPFS="$(ak-ipfs-add .)" + ak-ipfs-name-publish --key="$BARENAME" /ipfs/$IPFS + echo "DONE" + else + echo "NO BARE TO UPDATE" + echo "updating all..." + fi + else + BARES="$(ls -1 $BAREDIR)" + cd $BAREDIR + for PROJECT in $BARES + do + cd "$PROJECT" + git pull + git repack -a + IPFS="$(ak-ipfs-add .)" + ak-ipfs-name-publish --key="$PROJECT" /ipfs/$IPFS + cd $BAREDIR + done + fi } append-if-needed(){ - under="$1" - file="$HOME/.arching-kaos/repos" - lines="$(cat $file)" - found="no" - for line in $lines - do - if [ $found == "yes" ] - then - echo "found $found" - break - else - if [ "$line" == "$under" ] - then - found="yes" - echo "found $found" - break - fi - fi - done - if [ $found == "no" ] - then - echo $under > $file - fi + under="$1" + file="$HOME/.arching-kaos/repos" + lines="$(cat $file)" + found="no" + for line in $lines + do + if [ $found == "yes" ] + then + echo "found $found" + break + else + if [ "$line" == "$under" ] + then + found="yes" + echo "found $found" + break + fi + fi + done + if [ $found == "no" ] + then + echo $under > $file + fi } add(){ - PROJECT="$1" - PROJECTDIR="$REPODIR/$PROJECT" - BAREGITDIR="$BAREDIR/$PROJECT.git" - if [ -d $PROJECTDIR ] - then - cd $HOME/bare - git clone --bare $PROJECTDIR/.git - if [ $? == 0 ] - then - cd $BAREGITDIR - git repack -a - IPFS="$(ak-ipfs-add .)" - try=ak-ipfs-key-gen "$PROJECT.git" - if [ $? == 0 ] - then - ak-ipfs-name-publish --key="$PROJECT.git" /ipfs/$IPFS - printf '{"project":"%s.git","ipns":"%s"}' $PROJECT $try > data - ak-zblock-pack "repos/add" $PWD/data - echo "Done" - fi - fi - else - echo "$PROJECT not a git repo" - fi + PROJECT="$1" + PROJECTDIR="$REPODIR/$PROJECT" + BAREGITDIR="$BAREDIR/$PROJECT.git" + if [ -d $PROJECTDIR ] + then + cd $HOME/bare + git clone --bare $PROJECTDIR/.git + if [ $? == 0 ] + then + cd $BAREGITDIR + git repack -a + IPFS="$(ak-ipfs-add .)" + try=ak-ipfs-key-gen "$PROJECT.git" + if [ $? == 0 ] + then + ak-ipfs-name-publish --key="$PROJECT.git" /ipfs/$IPFS + printf '{"project":"%s.git","ipns":"%s"}' $PROJECT $try > data + ak-zblock-pack "repos/add" $PWD/data + echo "Done" + fi + fi + else + echo "$PROJECT not a git repo" + fi } index(){ - ak-ipfs-key-list-full | grep -e '\.git' + ak-ipfs-key-list-full | grep -e '\.git' } set-as-profile(){ - IPFS=$(ak-ipfs-add $REPOSTORE) - if [ $? == 0 ] - then - profile set repositories $IPFS - else - echo error - fi + IPFS=$(ak-ipfs-add $REPOSTORE) + if [ $? == 0 ] + then + profile set repositories $IPFS + else + echo error + fi } publish(){ - if [ ! -z $1 ] - then - echo "Filtering for $1..." - index | grep "$1" > $REPOSTORE - set-as-profile - else - echo "Publishing all..." - index > $REPOSTORE - set-as-profile - fi + if [ ! -z $1 ] + then + echo "Filtering for $1..." + index | grep "$1" > $REPOSTORE + set-as-profile + else + echo "Publishing all..." + index > $REPOSTORE + set-as-profile + fi } usage(){ echo "TODO" echo "index | add | publish | update" - exit + exit } if [ ! -z $1 ] @@ -159,5 +159,5 @@ then *) echo "No command $1";usage; exit;; esac else - usage + usage fi diff --git a/bin/ak-roadmap b/bin/ak-roadmap index f4db04d..1bd6202 100755 --- a/bin/ak-roadmap +++ b/bin/ak-roadmap @@ -1,22 +1,22 @@ #!/bin/bash title(){ - echo "AK Roadmap tool" + echo "AK Roadmap tool" } usage(){ - title + title } search(){ - cd $HOME/projects - PRJS="$(ls -1 .)" - for prj in $PRJS - do - if [ -f $prj/ROADMAP.md ]; - then - echo " - Roadmap found in $prj" - fi - done + cd $HOME/projects + PRJS="$(ls -1 .)" + for prj in $PRJS + do + if [ -f $prj/ROADMAP.md ]; + then + echo " - Roadmap found in $prj" + fi + done } if [ ! -z $1 ]; @@ -27,6 +27,6 @@ then *) usage; exit;; esac else - usage - exit 0 + usage + exit 0 fi 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 " - echo " index" - echo " full-index" - echo " ls-map-files" + echo "$PROGRAM - file" + echo " -h, --help Prints this help message" + echo " add 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 < $TEMPORARYDIR/map; while IFS="" read -r p || [ -n "$p" ] do diff --git a/bin/ak-sm-merkle-tree b/bin/ak-sm-merkle-tree index 2ff6493..461930f 100755 --- a/bin/ak-sm-merkle-tree +++ b/bin/ak-sm-merkle-tree @@ -1,7 +1,7 @@ #!/bin/bash # # The concept is bit more complicated now -# +# # 1. For a given file we split in 4KB files inside a temporary directory # # 2. We then create a map file and a merkle tree containing the resulted files @@ -20,7 +20,7 @@ # 6. We are done! # -# Uncomment next line if you want to debug +# Uncomment next line if you want to debug # set -xe PROGRAM="$(basename $0)" @@ -134,9 +134,9 @@ fi # We go over there... cd $TECHDIR #set -xe -# We get every chunks' SHA512 and we craft a script to rename the chunks and +# We get every chunks' SHA512 and we craft a script to rename the chunks and # move them to CHKDIR -for file in $TEMPORARYDIR/chks/* +for file in $TEMPORARYDIR/chks/* do sha512sum $file >> $TEMPORARYDIR/map done @@ -195,7 +195,7 @@ fi # Reset file with uniq cat $TEMPORARYDIR/map | uniq > $TEMPORARYDIR/map2 cat $TEMPORARYDIR/map2 > $TEMPORARYDIR/map -rm $TEMPORARYDIR/map2 +rm $TEMPORARYDIR/map2 counter=0 while IFS="" read -r p || [ -n "$p" ] diff --git a/bin/ak-startup b/bin/ak-startup index 54a9918..07c7935 100755 --- a/bin/ak-startup +++ b/bin/ak-startup @@ -4,4 +4,4 @@ screen -dmS ipfs-daemon ipfs daemon source $HOME/.arching-kaos/rc ak-logrotate screen -dmS akdaemon ak-daemon > $AK_WORKDIR/akd.log 2> $AK_WORKDIR/akd.err & printf '%s' "$!" > $AK_WORKDIR/akd.pid -# ak-logfollow +# ak-logfollow diff --git a/bin/ak-stellar-get-participants b/bin/ak-stellar-get-participants index bac4635..838ad08 100755 --- a/bin/ak-stellar-get-participants +++ b/bin/ak-stellar-get-participants @@ -71,11 +71,11 @@ get_asset_holders(){ curl https://horizon.stellar.org/accounts\?asset\=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2\&limit\=$limit > $tempfile 2>/dev/null } -get_asset_holders +get_asset_holders while [ "$(tail -1 $stellarParticipants)" != "null" ] do show_ids - proceed_to_next_page + proceed_to_next_page done grep G $stellarParticipants > $tempaddr diff --git a/bin/ak-todos b/bin/ak-todos index 89e8960..4a0a8ea 100755 --- a/bin/ak-todos +++ b/bin/ak-todos @@ -95,10 +95,10 @@ _ak_modules_todos_add(){ "detach":"$FILE_SIGNATURE" } EOF - else - echo "File $FILE doesn't exist"; - exit 2 - fi + else + echo "File $FILE doesn't exist"; + exit 2 + fi ak-zblock-pack "todos/add" $(pwd)/data if [ $? == 0 ] then diff --git a/bin/ak-unfollow b/bin/ak-unfollow index 21f0da1..1a3f8c1 100755 --- a/bin/ak-unfollow +++ b/bin/ak-unfollow @@ -23,6 +23,6 @@ else echo "Who to unfollow?" echo "Type following to see them" exit 1 -fi - +fi + diff --git a/bin/ak-zblock-manipulator b/bin/ak-zblock-manipulator index 20de3e0..6a4c700 100755 --- a/bin/ak-zblock-manipulator +++ b/bin/ak-zblock-manipulator @@ -2,7 +2,7 @@ # This file describe the structure of the ArchingKaos messages in their basis. # # As previously thought, we exchange one IPFS hash through whatever means we can. -# +# # GPG is mentioned as a signing algorithm for encryption, decryption and signing. # Let's say we have a file named as `example` # @@ -45,7 +45,7 @@ usage(){ } main(){ - + logit "[INFO]" "We are doing" $BLOCK_TO_ADD "with content" $PREVIOUS # We add it to IPFS MESSAGE_HASH=$(ak-ipfs-add $MESSAGE) diff --git a/bin/ak-zblock-pack b/bin/ak-zblock-pack index 5105f38..5d84976 100755 --- a/bin/ak-zblock-pack +++ b/bin/ak-zblock-pack @@ -2,7 +2,7 @@ # This file describe the structure of the ArchingKaos messages in their basis. # # As previously thought, we exchange one IPFS hash through whatever means we can. -# +# # GPG is mentioned as a signing algorithm for encryption, decryption and signing. # Let's say we have a file named as `example` # diff --git a/bin/ak-zchain-chk b/bin/ak-zchain-chk index e9779f7..6b75405 100755 --- a/bin/ak-zchain-chk +++ b/bin/ak-zchain-chk @@ -5,35 +5,35 @@ logit(){ } fix="0" usage(){ - echo "zchain-chk - Check and fix zchain" - echo "---------------------------------" - echo "Usage:" - echo " --help, -h Print this help and exit" - echo " --chain , -n Crawl specified chain" - echo " --fix #TODO Fix your chain" - echo "" - echo "Note that combined flags don't work for now" - echo "Running with no flags crawls your chain" + echo "zchain-chk - Check and fix zchain" + echo "---------------------------------" + echo "Usage:" + echo " --help, -h Print this help and exit" + echo " --chain , -n Crawl specified chain" + echo " --fix #TODO Fix your chain" + echo "" + echo "Note that combined flags don't work for now" + echo "Running with no flags crawls your chain" } if [ ! -z "$1" ] && [ "$1" == "-h" ] || [ "$1" == "--help" ] then - usage - exit + usage + exit elif [ ! -z "$1" ] && [ "$1" == "-f" ] || [ "$1" == "--fix" ] then - fix="1" - entrance="$(cat $AK_ZLATEST)" + fix="1" + entrance="$(cat $AK_ZLATEST)" elif [ ! -z "$1" ] && [ "$1" == "-n" ] || [ "$1" == "--chain" ] then - entrance="$(ak-ipns-resolve $2)" + entrance="$(ak-ipns-resolve $2)" elif [ ! -z "$1" ] then - entrance="$1" + entrance="$1" else - # By default we ak-enter from the latest block - # We can alter this by changing this value - entrance="$(cat $AK_ZLATEST)" + # By default we ak-enter from the latest block + # We can alter this by changing this value + entrance="$(cat $AK_ZLATEST)" fi # We assign the IPFS CIDv0 of an empty file as this is used @@ -55,92 +55,92 @@ counter=0 # We break the loop from inside the loop while true do - if [ $counter == 0 ] - then - echo 'Start checking' - fi - counter=$(expr $counter + 1) + if [ $counter == 0 ] + then + echo 'Start checking' + fi + counter=$(expr $counter + 1) - # Check if $zblock exists as variable - if [ ! -v $zblock ] - then - # Check if it is not our seed cause if it is we skip this part - if [ "$zblock" != "$seed" ] - then - # Reset timestamp since it's introduced later - timestamp='' - # Announce to stdout which ZBLOCK is being read at the moment - ak-logthis "[INFO]" "Examining $zblock" + # Check if $zblock exists as variable + if [ ! -v $zblock ] + then + # Check if it is not our seed cause if it is we skip this part + if [ "$zblock" != "$seed" ] + then + # Reset timestamp since it's introduced later + timestamp='' + # Announce to stdout which ZBLOCK is being read at the moment + logit "INFO" "Examining $zblock" - # We create files named after each ZBLOCK IPFS CID for later - # reference. Files are empty. - touch $AK_ZBLOCKDIR/$zblock - ak-logthis "[INFO]" "Created reference" + # We create files named after each ZBLOCK IPFS CID for later + # reference. Files are empty. + touch $AK_ZBLOCKDIR/$zblock + logit "INFO" "Created reference" - # We concatenate the zblock's contents, pipe them through filter - # ak-json2bash and output them to tmp-file - ak-ipfs-cat $zblock | ak-json2bash > tmp-zblock - ak-logthis "[INFO]" "ZBLOCK $zblock READ" + # We concatenate the zblock's contents, pipe them through filter + # ak-json2bash and output them to tmp-file + ak-ipfs-cat $zblock | ak-json2bash > tmp-zblock + logit "INFO" "ZBLOCK $zblock READ" - # Supposingly you are on a safe environment and you only have - # access to your chain, I would consider mild secure to source - # the files into your bash. - # File an issue/pull request if you think it can be done better!! - source tmp-zblock - ak-logthis "[INFO]" "ZBLOCK SOURCED" + # Supposingly you are on a safe environment and you only have + # access to your chain, I would consider mild secure to source + # the files into your bash. + # File an issue/pull request if you think it can be done better!! + source tmp-zblock + logit "INFO" "ZBLOCK SOURCED" - # Same as above applies to BLOCK and DATA subparts of each ZBLOCK - # BLOCKS - ak-ipfs-cat $block | ak-json2bash > tmp-block - source tmp-block - ak-logthis "[INFO]" "BLOCK $block SOURCED" - touch $AK_BLOCKDIR/$block - ak-logthis "[INFO]" "BLOCK REFERENCED" - module="$(echo $action | sed -e 's/\// /g' | awk '{ print $1 }')" - ak-logthis "[INFO]" "DATA is $module module." - command="$(echo $action | sed -e 's/\// /g' | awk '{ print $2 }')" - ak-logthis "[INFO]" "COMMAND is $command" - if [ ! -v $timestamp ] - then - echo "$timestamp : $zblock -> $block -> $previous" - blocks_found[$counter]="$block" - fi - touch $AK_DATADIR/$data + # Same as above applies to BLOCK and DATA subparts of each ZBLOCK + # BLOCKS + ak-ipfs-cat $block | ak-json2bash > tmp-block + source tmp-block + logit "INFO" "BLOCK $block SOURCED" + touch $AK_BLOCKDIR/$block + logit "INFO" "BLOCK REFERENCED" + module="$(echo $action | sed -e 's/\// /g' | awk '{ print $1 }')" + logit "INFO" "DATA is $module module." + command="$(echo $action | sed -e 's/\// /g' | awk '{ print $2 }')" + logit "INFO" "COMMAND is $command" + if [ ! -v $timestamp ] + then + echo "$timestamp : $zblock -> $block -> $previous" + blocks_found[$counter]="$block" + fi + touch $AK_DATADIR/$data - # Now, since we sourced the BLOCK to our terminal, we can search - # for $previous variable. In case we don't find one, we exit with - # code 0 - if [ -v $previous ] - then - ak-logthis "[ERROR]" "Block $block has no previous zblock" - echo "Chain with no genesis" - if [ "$fix" == "1" ] - then - echo "LOL" - else - echo "Blocks found and need repacking..." - for value in ${blocks_found[@]} - do - echo $value - ak-ipfs-cat $value | jq -M - done - fi - exit 0 - # Otherwise, we inform of the sequence - else - zblock=$previous - fi - # Now check if it is equal to the seed - # which apparently means we reached the seed. - elif [ "$zblock" == "$seed" ] - then - echo "Chain is OK with GENESIS block = $seed" - ak-logthis "[INFO]" "Counter $counter" - exit 0 - fi - # And finally, if nothing is there exit with error - else - ak-logthis "[ERROR]" "Check not passed... No previous IPFS CID" - exit 1 - fi + # Now, since we sourced the BLOCK to our terminal, we can search + # for $previous variable. In case we don't find one, we exit with + # code 0 + if [ -v $previous ] + then + logit "ERROR" "Block $block has no previous zblock" + echo "Chain with no genesis" + if [ "$fix" == "1" ] + then + echo "LOL" + else + echo "Blocks found and need repacking..." + for value in ${blocks_found[@]} + do + echo $value + ak-ipfs-cat $value | jq -M + done + fi + exit 0 + # Otherwise, we inform of the sequence + else + zblock=$previous + fi + # Now check if it is equal to the seed + # which apparently means we reached the seed. + elif [ "$zblock" == "$seed" ] + then + echo "Chain is OK with GENESIS block = $seed" + logit "INFO" "Counter $counter" + exit 0 + fi + # And finally, if nothing is there exit with error + else + logit "ERROR" "Check not passed... No previous IPFS CID" + exit 1 + fi done -- cgit v1.2.3