aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak-data-expand156
-rwxr-xr-xbin/ak-find-latest-mined-sblock82
-rwxr-xr-xbin/ak-following8
-rwxr-xr-xbin/ak-fs-add21
-rwxr-xr-xbin/ak-mempool6
-rwxr-xr-xbin/ak-miner-script56
-rwxr-xr-xbin/ak-network2
-rwxr-xr-xbin/ak-sblock-show4
-rwxr-xr-xbin/ak-sm-filejoiner64
-rwxr-xr-xbin/ak-sm-filesplitter68
-rwxr-xr-xbin/ak-zchain-calculate-size2
-rwxr-xr-xbin/ak-zchain-reset74
12 files changed, 274 insertions, 269 deletions
diff --git a/bin/ak-data-expand b/bin/ak-data-expand
index a19ca65..8ee54c9 100755
--- a/bin/ak-data-expand
+++ b/bin/ak-data-expand
@@ -11,94 +11,94 @@ fi
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"
- exit 1
- fi
- _ak_ipfs_cat $1 > /dev/null
- if [ "$?" -ne 0 ]
- then
- 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"
- 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"
- 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"
- 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"
- 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"
- exit 1
- fi
- echo -n "$2" | grep -e 'Qm.\{44\}' >/dev/null
- if [ "$?" -ne 0 ]
- then
- logit "ERROR" "Invalid hash format for $2"
- exit 1
- fi
+ echo -n "$1" | grep -e 'Qm.\{44\}' >/dev/null
+ if [ "$?" -ne 0 ]
+ then
+ 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"
+ exit 1
+ fi
+ _ak_ipfs_cat $1 | jq -M > /dev/null
+ if [ "$?" -ne 0 ]
+ then
+ 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"
+ 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"
+ 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"
+ 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"
+ exit 1
+ fi
+ echo -n "$2" | grep -e 'Qm.\{44\}' >/dev/null
+ if [ "$?" -ne 0 ]
+ then
+ 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"
- exit 1
+ logit "ERROR" "Could not get GPG key: $gpg"
+ exit 1
fi
_ak_gpg_key_import_from_file $gpg > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
- logit "ERROR" "Could not import GPG key: $gpg"
- 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"
- exit 1
- fi
- mv $DETACH $DATA.asc
- logit "INFO" "Block signature downloaded"
- _ak_ipfs_get $DATA > /dev/null 2>&1
- if [ "$?" -ne 0 ]
- then
- logit "ERROR" "Error while getting data: $DATA"
- exit 1
- fi
- logit "INFO" "Data downloaded: $DATA"
- _ak_gpg_verify_signature $DATA.asc $DATA > /dev/null 2>&1
- if [ "$?" -ne 0 ]
- then
- logit "ERROR" "Error while verifying signature for $DATA"
- exit 1
- fi
+ 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"
+ exit 1
+ fi
+ mv $DETACH $DATA.asc
+ logit "INFO" "Block signature downloaded"
+ _ak_ipfs_get $DATA > /dev/null 2>&1
+ if [ "$?" -ne 0 ]
+ then
+ logit "ERROR" "Error while getting data: $DATA"
+ exit 1
+ fi
+ logit "INFO" "Data downloaded: $DATA"
+ _ak_gpg_verify_signature $DATA.asc $DATA > /dev/null 2>&1
+ if [ "$?" -ne 0 ]
+ then
+ 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
+ exit 0
else
- echo "Usage: $PROGRAM HASH GPG"
- exit 1
+ echo "Usage: $PROGRAM HASH GPG"
+ exit 1
fi
diff --git a/bin/ak-find-latest-mined-sblock b/bin/ak-find-latest-mined-sblock
index 8ef104c..772e884 100755
--- a/bin/ak-find-latest-mined-sblock
+++ b/bin/ak-find-latest-mined-sblock
@@ -15,63 +15,63 @@ then
fi
further(){
- # logit "INFO" "Diving into $1"
- lookfor $1
+ # logit "INFO" "Diving into $1"
+ lookfor $1
}
lookfor(){
- echo -n $1 | grep -e '[0-9a-f]\{128\}' > /dev/null
- if [ ! $? = 0 ]
- then
- logit "ERROR" "Oops!!! The argument passed, does not match the regular expression!"
- else
- counters[$CHAIN_PARENT]="$(expr ${counters[$CHAIN_PARENT]} + 1)"
- if [ ! $? = 0 ]
- then
- echo "$1, $counters[$1]"
- exit 1
- fi
- logit "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
- logit "INFO" "Found previous: $NEXT_TARGET"
- if [ ! -f "$NEXT_TARGET" ]
- then
- logit "WARNING" "Could not find $NEXT_TARGET"
- else
- further "$NEXT_TARGET"
- fi
- else
- logit "WARNING" "No next target found. So long for $1"
- fi
- fi
+ echo -n $1 | grep -e '[0-9a-f]\{128\}' > /dev/null
+ if [ ! $? = 0 ]
+ then
+ logit "ERROR" "Oops!!! The argument passed, does not match the regular expression!"
+ else
+ counters[$CHAIN_PARENT]="$(expr ${counters[$CHAIN_PARENT]} + 1)"
+ if [ ! $? = 0 ]
+ then
+ echo "$1, $counters[$1]"
+ exit 1
+ fi
+ logit "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
+ logit "INFO" "Found previous: $NEXT_TARGET"
+ if [ ! -f "$NEXT_TARGET" ]
+ then
+ logit "WARNING" "Could not find $NEXT_TARGET"
+ else
+ further "$NEXT_TARGET"
+ fi
+ else
+ logit "WARNING" "No next target found. So long for $1"
+ fi
+ fi
}
templistblock="$(mktemp)"
find . -type f | sed 's/^\.\/000/000/g' | grep '^000' | sort > $templistblock
while IFS="" read -r p || [ -n "$p" ]
do
-# if [ ! "$p" = "" ] && [ ! "$p" = "tmplistblock" ]
- if [ "$(echo $p | tr -d '\n' | wc -c)" = 128 ]
- then
+# if [ ! "$p" = "" ] && [ ! "$p" = "tmplistblock" ]
+ if [ "$(echo $p | tr -d '\n' | wc -c)" = 128 ]
+ then
filename="$(basename $p)"
- logit "INFO" "Investigating $filename..."
- export CHAIN_PARENT="$filename"
- counters[$CHAIN_PARENT]=1
- lookfor "$filename"
- else
- logit "WARNING" "Nothing to do with $filename"
- fi
+ logit "INFO" "Investigating $filename..."
+ export CHAIN_PARENT="$filename"
+ counters[$CHAIN_PARENT]=1
+ lookfor "$filename"
+ else
+ logit "WARNING" "Nothing to do with $filename"
+ fi
done < $templistblock
rm $templistblock
max=0
max_holder=0
for value in "${!counters[@]}"
do
- # echo "${value} : ${counters[${value}]}"
+ # echo "${value} : ${counters[${value}]}"
if [ ${counters[${value}]} -gt $max ]
then
max="${counters[${value}]}"
diff --git a/bin/ak-following b/bin/ak-following
index 0446ed8..7b37be3 100755
--- a/bin/ak-following
+++ b/bin/ak-following
@@ -5,9 +5,9 @@ source $AK_LIBDIR/_ak_log
FOLLOWING="$HOME/.arching-kaos/following"
if [ -f $FOLLOWING ]
then
- cat $FOLLOWING
+ cat $FOLLOWING
else
- logit "INFO" "No following file, creating"
- touch $FOLLOWING
- echo "None found"
+ logit "INFO" "No following file, creating"
+ touch $FOLLOWING
+ echo "None found"
fi
diff --git a/bin/ak-fs-add b/bin/ak-fs-add
index d00367d..34ee3c0 100755
--- a/bin/ak-fs-add
+++ b/bin/ak-fs-add
@@ -24,12 +24,20 @@
# Uncomment next line if you want to debug
# set -xe
PROGRAM="$(basename $0)"
+source $AK_LIBDIR/_ak_fs
+source $AK_LIBDIR/_ak_log
if [ ! -f "$1" ]
then
- echo "ERROR File not found"
+ logit "ERROR" "File $1 not found"
exit 1
else
+ # TODO
+ # Side hustle, save the original hash and original filename
+ # This won't be expected in general
+ # The idea is:
+ # sha256sum as quick pointer to root of the tree
+ #
base64 $1 > file
FILE="file"
fi
@@ -57,12 +65,11 @@ rm -rf $TEMPORARYDIR
if [ ! -d "$TECHDIR" ]
then
mkdir -p "$TECHDIR"
- if [ "$?" == 0 ]
+ if [ $? == 0 ]
then
logit "INFO" "Folder $TECHDIR created!"
else
logit "ERROR" "Problem occured while creating $TECHDIR"
- echo "ERROR Can't create $TECHDIR"
exit 1
fi
else
@@ -73,12 +80,11 @@ fi
if [ ! -d "$FILEMAPSDIR" ]
then
mkdir -p "$FILEMAPSDIR"
- if [ "$?" == 0 ]
+ if [ $? == 0 ]
then
logit "INFO" "Folder $FILEMAPSDIR created!"
else
logit "ERROR" "Problem occured while creating $FILEMAPSDIR"
- echo "ERROR Can't create $FILEMAPSDIR"
exit 1
fi
else
@@ -89,12 +95,11 @@ fi
if [ ! -d "$CHKDIR" ]
then
mkdir -p "$CHKDIR"
- if [ "$?" == 0 ]
+ if [ $? == 0 ]
then
logit "INFO" "Folder $CHKDIR created!"
else
logit "ERROR" "Problem occured while creating $CHKDIR"
- echo "ERROR Can't create $CHKDIR"
exit 1
fi
else
@@ -105,7 +110,7 @@ fi
if [ ! -d "$MERKLEDIR" ]
then
mkdir -p "$MERKLEDIR"
- if [ "$?" == 0 ]
+ if [ $? == 0 ]
then
logit "INFO" "Folder $MERKLEDIR created!"
else
diff --git a/bin/ak-mempool b/bin/ak-mempool
index a4e11c9..cb659c2 100755
--- a/bin/ak-mempool
+++ b/bin/ak-mempool
@@ -12,9 +12,9 @@ _ak_ipfs_swarm_peers > tmp_peers
while IFS="" read -r p || [ -n "$p" ]
do
- peer="$(echo "$p" | sed -e 's/^.*\///')"
- logit "INFO" "Peer $peer found! Examining..."
- _ak_ipfs_cat /ipns/$peer/zlatest
+ peer="$(echo "$p" | sed -e 's/^.*\///')"
+ logit "INFO" "Peer $peer found! Examining..."
+ _ak_ipfs_cat /ipns/$peer/zlatest
done < tmp_peers
rm tmp_peers
diff --git a/bin/ak-miner-script b/bin/ak-miner-script
index 28bb056..002c27d 100755
--- a/bin/ak-miner-script
+++ b/bin/ak-miner-script
@@ -1,43 +1,43 @@
#!/bin/bash
PROGRAM="$(basename $0)"
proofofwork(){
- TEST="$1"
- PRE="$2"
- MINER="$3"
- i=1
- l=1; while [ $l = 1 ]
- do
- TIMESTAMP="$(date -u +%s)"
- SHA="$(echo $TEST'"nonce":"'$i'","previous":"'$PRE'","timestamp":"'$TIMESTAMP'","miner":"'$MINER'","reward":"40"}' | sha512sum | awk '{ print $1 }')"
+ TEST="$1"
+ PRE="$2"
+ MINER="$3"
+ i=1
+ l=1; while [ $l = 1 ]
+ do
+ TIMESTAMP="$(date -u +%s)"
+ SHA="$(echo $TEST'"nonce":"'$i'","previous":"'$PRE'","timestamp":"'$TIMESTAMP'","miner":"'$MINER'","reward":"40"}' | sha512sum | awk '{ print $1 }')"
# Static difficulty for securing the sblock
- echo $SHA | grep -e '^000'
- if [ "$?" == 0 ] ;
- then
- echo "SHA512 is $SHA"
- echo "Mined block:"
- echo $TEST'"nonce":"'$i'","previous":"'$PRE'","timestamp":"'$TIMESTAMP'","miner":"'$MINER'","reward":"40"}' | jq --compact-output > $AK_MINEDBLOCKSDIR/$SHA
- cat $AK_MINEDBLOCKSDIR/$SHA | jq
- # exit 0
- # Instead of exiting, we will now sleep for 60 seconds
- # after that we continue mining on top of the just mined
- # block.
- sleep 60
- proofofwork "$1" "$SHA" "$MINER"
- fi
- i=$(expr $i + 1);
- done
+ echo $SHA | grep -e '^000'
+ if [ "$?" == 0 ] ;
+ then
+ echo "SHA512 is $SHA"
+ echo "Mined block:"
+ echo $TEST'"nonce":"'$i'","previous":"'$PRE'","timestamp":"'$TIMESTAMP'","miner":"'$MINER'","reward":"40"}' | jq --compact-output > $AK_MINEDBLOCKSDIR/$SHA
+ cat $AK_MINEDBLOCKSDIR/$SHA | jq
+ # exit 0
+ # Instead of exiting, we will now sleep for 60 seconds
+ # after that we continue mining on top of the just mined
+ # block.
+ sleep 60
+ proofofwork "$1" "$SHA" "$MINER"
+ fi
+ i=$(expr $i + 1);
+ done
}
usage(){
- echo "$PROGRAM <somethings> <previous> <miner_address>"
- echo " hit ak-enter after that !!! "
+ echo "$PROGRAM <somethings> <previous> <miner_address>"
+ echo " hit ak-enter after that !!! "
}
if [ -z "$1" ] ;
then
- usage
- exit;
+ usage
+ exit;
elif [ ! -z "$1" ] && [ ! -z "$2" ] && [ ! -z "$3" ]
then
proofofwork "$1" "$2" "$3";
diff --git a/bin/ak-network b/bin/ak-network
index 3a65d7b..c506879 100755
--- a/bin/ak-network
+++ b/bin/ak-network
@@ -1,5 +1,5 @@
#!/bin/bash
while true
do
- cat $ZLATEST | nc -lv 127.0.0.1 5050
+ cat $ZLATEST | nc -lv 127.0.0.1 5050
done
diff --git a/bin/ak-sblock-show b/bin/ak-sblock-show
index 0a92c54..e840740 100755
--- a/bin/ak-sblock-show
+++ b/bin/ak-sblock-show
@@ -3,7 +3,7 @@ PROGRAM="$(basename $0)"
if [ ! -z $1 ]
then
- cat $AK_MINEDBLOCKSDIR/$1 | jq
+ cat $AK_MINEDBLOCKSDIR/$1 | jq
else
- echo "No sblock hash input"
+ echo "No sblock hash input"
fi
diff --git a/bin/ak-sm-filejoiner b/bin/ak-sm-filejoiner
index 69b1297..3f3604c 100755
--- a/bin/ak-sm-filejoiner
+++ b/bin/ak-sm-filejoiner
@@ -5,11 +5,11 @@ set -xe
PROGRAM="$(basename $0)"
usage(){
- echo "$PROGRAM <hash>"
+ echo "$PROGRAM <hash>"
}
cdaw(){
- pwd > tmp_holder
+ pwd > tmp_holder
}
cdaw
@@ -20,12 +20,12 @@ TMPWD="/tmp/rjs"
if [ ! -d "$TMPWD" ]
then
- mkdir -p "$TMPWD"
- if [ "$?" != 0 ]
- then
- echo "Can't create $TMPWD dir"
- exit 1
- fi
+ mkdir -p "$TMPWD"
+ if [ "$?" != 0 ]
+ then
+ echo "Can't create $TMPWD dir"
+ exit 1
+ fi
fi
MAPSDIR="$AK_WORKDIR/fmp"
@@ -35,54 +35,54 @@ CHKDIR="$AK_WORKDIR/ftr"
cd $CHKDIR
if [ "$?" != 0 ]
then
- echo "Can't get dir"
- exit 1
+ echo "Can't get dir"
+ exit 1
fi
if [ ! -z $1 ]
then
- MAPSFILE="$1"
+ MAPSFILE="$1"
+
+ echo '#!/bin/bash' > script
- echo '#!/bin/bash' > script
-
# We create a script to copy all the chunks and rename them to their serialized
# name produced by split when we splitted the file
- awk '{print "cp '$CHKDIR'/"$1" '$TMPWD'/"$2" "}' $MAPSDIR/$MAPSFILE| grep chk >> script
+ awk '{print "cp '$CHKDIR'/"$1" '$TMPWD'/"$2" "}' $MAPSDIR/$MAPSFILE| grep chk >> script
- bash script
+ bash script
- if [ "$?" != 0 ]
- then
- echo "Error executing copy script"
- exit 1
- fi
- rm script
+ if [ "$?" != 0 ]
+ then
+ echo "Error executing copy script"
+ exit 1
+ fi
+ rm script
- cd $TMPWD
+ cd $TMPWD
- echo "$PWD"
+ echo "$PWD"
# Final name we are going to rename to
- OUTPUT="$(tail -n1 $MAPSDIR/$MAPSFILE | awk '{print $2}')"
+ OUTPUT="$(tail -n1 $MAPSDIR/$MAPSFILE | awk '{print $2}')"
- echo $OUTPUT
+ echo $OUTPUT
# We grep the MAPSFILE for chk filenames in lines and we print them all in
# one line so the first `cat` will concatenate all chunks to OUTPUT
- cat $(echo -n $(cat $MAPSDIR/$MAPSFILE|grep chk|awk '{print $2" "}'|tr -d '\n')) > $OUTPUT
+ cat $(echo -n $(cat $MAPSDIR/$MAPSFILE|grep chk|awk '{print $2" "}'|tr -d '\n')) > $OUTPUT
# We check if everything is okay
- sha512sum -c $MAPSDIR/$MAPSFILE
+ sha512sum -c $MAPSDIR/$MAPSFILE
if [ "$?" != "0" ]; then
logit "ERROR" "Error while checking sums"
exit 1
fi
-
- mv $OUTPUT $CURDIR
- rm -rf "$TMPWD"
+ mv $OUTPUT $CURDIR
+
+ rm -rf "$TMPWD"
- rm $CURDIR/tmp_holder
+ rm $CURDIR/tmp_holder
else
- usage
+ usage
fi
diff --git a/bin/ak-sm-filesplitter b/bin/ak-sm-filesplitter
index d607c15..f9f5cff 100755
--- a/bin/ak-sm-filesplitter
+++ b/bin/ak-sm-filesplitter
@@ -23,10 +23,10 @@ PROGRAM="$(basename $0)"
if [ ! -f "$1" ]
then
- echo "ERROR File not found"
- exit 1
+ echo "ERROR File not found"
+ exit 1
else
- FILE="$1"
+ FILE="$1"
fi
# The directory where the chunked data will be living at
@@ -48,49 +48,49 @@ source $AK_LIBDIR/_ak_log
# TECHDIR
if [ ! -d "$TECHDIR" ]
then
- mkdir -p "$TECHDIR"
- if [ "$?" == 0 ]
- then
- logit "INFO" "Folder $TECHDIR created!"
- else
- logit "ERROR" "Problem occured while creating $TECHDIR"
- echo "ERROR Can't create $TECHDIR"
- exit 1
- fi
+ mkdir -p "$TECHDIR"
+ if [ "$?" == 0 ]
+ then
+ logit "INFO" "Folder $TECHDIR created!"
+ else
+ 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
if [ ! -d "$FILEMAPSDIR" ]
then
- mkdir -p "$FILEMAPSDIR"
- if [ "$?" == 0 ]
- then
- logit "INFO" "Folder $FILEMAPSDIR created!"
- else
- logit "ERROR" "Problem occured while creating $FILEMAPSDIR"
- echo "ERROR Can't create $FILEMAPSDIR"
- exit 1
- fi
+ mkdir -p "$FILEMAPSDIR"
+ if [ "$?" == 0 ]
+ then
+ logit "INFO" "Folder $FILEMAPSDIR created!"
+ else
+ 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
if [ ! -d "$CHKDIR" ]
then
- mkdir -p "$CHKDIR"
- if [ "$?" == 0 ]
- then
- logit "INFO" "Folder $CHKDIR created!"
- else
- logit "ERROR" "Problem occured while creating $CHKDIR"
- echo "ERROR Can't create $CHKDIR"
- exit 1
- fi
+ mkdir -p "$CHKDIR"
+ if [ "$?" == 0 ]
+ then
+ logit "INFO" "Folder $CHKDIR created!"
+ else
+ 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
@@ -109,7 +109,7 @@ cd $TECHDIR
# move them to CHKDIR
sha512sum * > $TEMPORARYDIR/map; while IFS="" read -r p || [ -n "$p" ]
do
- echo $p | awk '{print "mv " $2 " '$CHKDIR'" $1}' >> $TEMPORARYDIR/cmd_queue.sh
+ echo $p | awk '{print "mv " $2 " '$CHKDIR'" $1}' >> $TEMPORARYDIR/cmd_queue.sh
done < $TEMPORARYDIR/map
# We run the crafted script
diff --git a/bin/ak-zchain-calculate-size b/bin/ak-zchain-calculate-size
index 51c4202..5603221 100755
--- a/bin/ak-zchain-calculate-size
+++ b/bin/ak-zchain-calculate-size
@@ -22,7 +22,7 @@ do
else
num=0
fi
- sum=$(expr $sum + $num )
+ sum=$(expr $sum + $num )
done < to_stats
echo "Chain is : $sum bytes"
diff --git a/bin/ak-zchain-reset b/bin/ak-zchain-reset
index b415c44..4d9e099 100755
--- a/bin/ak-zchain-reset
+++ b/bin/ak-zchain-reset
@@ -3,43 +3,43 @@ PROGRAM=$(basename $0)
source $AK_LIBDIR/_ak_ipfs
usage(){
- echo "$PROGRAM - Zchain reset"
- echo ""
- echo "Description:"
- echo "Backs up your latest block into IPFS filesystem, replaces it with an empty file (GENESIS hardcode) and pushes its IPFS link as your chain's latest block."
- echo ""
- echo "Disclaimer:"
- echo "This program, does NOT delete anything from your IPFS repository, neither denies access to previously created blocks."
- echo ""
- echo "Usage:"
- echo " $PROGRAM reset"
- exit 0
+ echo "$PROGRAM - Zchain reset"
+ echo ""
+ echo "Description:"
+ echo "Backs up your latest block into IPFS filesystem, replaces it with an empty file (GENESIS hardcode) and pushes its IPFS link as your chain's latest block."
+ echo ""
+ echo "Disclaimer:"
+ echo "This program, does NOT delete anything from your IPFS repository, neither denies access to previously created blocks."
+ echo ""
+ echo "Usage:"
+ echo " $PROGRAM reset"
+ exit 0
}
reset (){
- echo "Reseting ZLATEST to ZGENESIS"
- cp $ZGENESIS $ZLATEST
- if [ $? != 0 ]; then exit 1; fi
+ echo "Reseting ZLATEST to ZGENESIS"
+ cp $ZGENESIS $ZLATEST
+ if [ $? != 0 ]; then exit 1; fi
- echo "Make sure /zarchive folder exists within IPFS FS"
- _ak_ipfs_files_mkdir /zarchive
- if [ $? != 0 ]; then echo "Folder already there"; fi
+ echo "Make sure /zarchive folder exists within IPFS FS"
+ _ak_ipfs_files_mkdir /zarchive
+ if [ $? != 0 ]; then echo "Folder already there"; fi
- echo "Archive the previous ZLATEST"
- _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1)
- if [ $? != 0 ]; then exit 1; fi
+ echo "Archive the previous ZLATEST"
+ _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1)
+ if [ $? != 0 ]; then exit 1; fi
- echo "Removing previous /zlatest entry"
- _ak_ipfs_files_rm /zlatest
- if [ $? != 0 ]; then exit 1; fi
+ echo "Removing previous /zlatest entry"
+ _ak_ipfs_files_rm /zlatest
+ if [ $? != 0 ]; then exit 1; fi
- echo "Copying reset ZLATEST"
- CZLATEST="$(cat $ZLATEST)"
- _ak_ipfs_files_cp /ipfs/$CZLATEST /zlatest
- if [ $? != 0 ]; then exit 1; fi
+ echo "Copying reset ZLATEST"
+ CZLATEST="$(cat $ZLATEST)"
+ _ak_ipfs_files_cp /ipfs/$CZLATEST /zlatest
+ if [ $? != 0 ]; then exit 1; fi
- echo "Publishing new (reset) ZLATEST"
- _ak_ipfs_name_publish --key=zchain /ipfs/$(cat $ZLATEST)
- if [ $? != 0 ]; then exit 1; fi
+ echo "Publishing new (reset) ZLATEST"
+ _ak_ipfs_name_publish --key=zchain /ipfs/$(cat $ZLATEST)
+ if [ $? != 0 ]; then exit 1; fi
ak-config publish
if [ "$?" -ne 0 ]
@@ -47,15 +47,15 @@ reset (){
logit "ERROR" "Could not publish new configuration"
exit 1
fi
-
- echo "Reset was successful"
- exit 0
+
+ echo "Reset was successful"
+ exit 0
}
if [ ! -z $1 ]; then
- case $1 in
- reset) reset; exit;;
- * ) usage;;
- esac
+ case $1 in
+ reset) reset; exit;;
+ * ) usage;;
+ esac
else usage
fi