aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak-articles150
-rwxr-xr-xbin/ak-categories132
-rwxr-xr-xbin/ak-cli2
-rwxr-xr-xbin/ak-comments80
-rwxr-xr-xbin/ak-config2
-rwxr-xr-xbin/ak-enter4
-rwxr-xr-xbin/ak-files8
-rwxr-xr-xbin/ak-ipfs-check2
-rwxr-xr-xbin/ak-json2bash4
-rwxr-xr-xbin/ak-news21
-rwxr-xr-xbin/ak-profile291
-rwxr-xr-xbin/ak-reference2
-rwxr-xr-xbin/ak-repositories236
-rwxr-xr-xbin/ak-roadmap26
-rwxr-xr-xbin/ak-sm-files75
-rwxr-xr-xbin/ak-sm-filesplitter10
-rwxr-xr-xbin/ak-sm-merkle-tree10
-rwxr-xr-xbin/ak-startup2
-rwxr-xr-xbin/ak-stellar-get-participants4
-rwxr-xr-xbin/ak-todos8
-rwxr-xr-xbin/ak-unfollow4
-rwxr-xr-xbin/ak-zblock-manipulator4
-rwxr-xr-xbin/ak-zblock-pack2
-rwxr-xr-xbin/ak-zchain-chk200
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 <<EOF
+ 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 <<EOF
{
"datetime":"$DATETIME",
"title":"$TITLE",
@@ -93,39 +93,37 @@ _ak_modules_articles_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 "articles/add" $(pwd)/data
- if [ $? == 0 ]
- then
- echo "Articles added successfully"
- else
- echo "error??"
- exit 1
- fi
+ if [ $? == 0 ]
+ then
+ echo "Articles added successfully"
+ else
+ echo "error??"
+ exit 1
+ fi
}
_ak_modules_articles_usage(){
- echo "#TODO"
- echo "All you need to know is that there are two options available:"
- echo "help Prints this help message"
- echo "index Prints an indexed table of your articles files"
- echo "import <file> #TODO"
- echo "add <file> 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 <file> #TODO"
+ echo " add <file> 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 <<EOF
+ 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 <<EOF
{
"datetime":"$DATETIME",
"title":"$TITLE",
@@ -83,18 +83,18 @@ _ak_modules_categories_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 "news/add" $(pwd)/data
- if [ $? == 0 ]
- then
- echo "News added successfully"
- else
- echo "error??"
- exit 1
- fi
+ if [ $? == 0 ]
+ then
+ echo "News added successfully"
+ else
+ echo "error??"
+ exit 1
+ fi
}
_ak_modules_categories_usage(){
echo "#TODO"
@@ -115,7 +115,7 @@ if [ ! -z $1 ]; then
import) _ak_modules_categories_import $2; exit;;
add) _ak_modules_categories_add $2; exit;;
create) _ak_modules_categories_create; exit;;
- * ) _ak_modules_categories_usage;;
- esac
+ * ) _ak_modules_categories_usage;;
+ esac
else _ak_modules_categories_usage
fi
diff --git a/bin/ak-cli b/bin/ak-cli
index a6bfb90..14f049b 100755
--- a/bin/ak-cli
+++ b/bin/ak-cli
@@ -55,7 +55,7 @@ help_all(){
help_log
new_line
-
+
help_follow
new_line
diff --git a/bin/ak-comments b/bin/ak-comments
index add1872..d4a73de 100755
--- a/bin/ak-comments
+++ b/bin/ak-comments
@@ -6,9 +6,9 @@ logit(){
ZCOMMENTSDIR="$AK_WORKDIR/comments"
TEMP="/tmp/aktmp"
if [ ! -d $ZCOMMENTSDIR ]; then
- mkdir $ZCOMMENTSDIR
- cd $ZCOMMENTSDIR
- ak-logthis "[INFO]" "zcommentsdir created"
+ mkdir $ZCOMMENTSDIR
+ cd $ZCOMMENTSDIR
+ logit "INFO" "zcommentsdir created"
else
logit "INFO" "zcommentsdir found"
fi
@@ -40,43 +40,43 @@ _ak_modules_comments_create(){
}
_ak_modules_comments_index(){
- FILES="$(ls -1 $ZCOMMENTSDIR)"
- i=0
- for FILE in $FILES
- do
- DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}')
- TITLE=$(head -n 1 $ZCOMMENTSDIR/$FILE)
- echo $i \| $DATE \| $TITLE
- let i+=1
- done
+ FILES="$(ls -1 $ZCOMMENTSDIR)"
+ i=0
+ for FILE in $FILES
+ do
+ DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}')
+ TITLE=$(head -n 1 $ZCOMMENTSDIR/$FILE)
+ echo $i \| $DATE \| $TITLE
+ let i+=1
+ done
}
_ak_modules_comments_title(){
- echo comments
+ echo comments
}
_ak_modules_comments_add(){
TEMP="$(ak-tempassin)"
cd $TEMP
- 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
+ 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 <kaotisk/kaotiskhund>
-#
+#
# 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 <file> #TODO"
- echo "add <file> 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 <file> #TODO"
+ echo "add <file> 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 <<EOF
+ 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 <<EOF
{
"datetime":"$(date -u +%s)",
"ipfs":"$FILE_IPFS_HASH",
"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 "profile/add" $(pwd)/data
- if [ "$?" -ne 0 ]
- then
- echo "error??"
- exit 1
- fi
+ if [ "$?" -ne 0 ]
+ then
+ echo "error??"
+ exit 1
+ fi
echo "Profile added successfully"
cd $ZPROFILEDIR
rm -rf "$TEMPASSIN"
}
_ak_modules_profile_usage(){
- echo "Usage:"
- echo " $PROGRAM command [options]"
- echo ""
- echo "Indexes, shows, imports, adds, sets and gets values from and to the"
+ echo "Usage:"
+ echo " $PROGRAM command [options]"
+ echo ""
+ echo "Indexes, shows, imports, adds, sets and gets values from and to the"
echo "zchain and files."
- echo ""
- echo -e "\thelp\t\t\t\tPrints this help message"
- echo -e "\tindex\t\t\t\tShow current status"
- echo -e "\tshow <data>\t\t\tShow profile entry from specified DATA IPFS CIDv0"
- echo -e "\tset <property> <value>\t\tSets a profile value"
- echo -e "\tget <property>\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 <data> Show profile entry from specified DATA IPFS CIDv0"
+ echo " set <property> <value> Sets a profile value"
+ echo " get <property> Gets a profile value from the on-disk file."
+ echo ""
echo "Advanced (use with caution may produce duplicate entries):"
- echo -e "\tadd <file>\t\t\tCreates a data file from the profile file you point to (file should already be in ZPROFILEDIR."
- echo -e "\timport <folder>\t\t\tImport a folder to zchain #TODO"
- echo ""
- exit 0
+ echo " add <file> Creates a data file from the profile file you point"
+ echo " to (file should already be in ZPROFILEDIR."
+ echo " import <folder> Import a folder to zchain #TODO"
+ echo ""
+ exit 0
}
if [ ! -z $1 ]; then
- case $1 in
- help) _ak_modules_profile_usage; exit;;
- index) _