aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/_ak_cjdns37
-rwxr-xr-xlib/_ak_coin2
-rwxr-xr-xlib/_ak_config7
-rwxr-xr-xlib/_ak_fs20
-rwxr-xr-xlib/_ak_gpg52
-rwxr-xr-xlib/_ak_html5
-rwxr-xr-xlib/_ak_ipfs69
-rwxr-xr-xlib/_ak_log21
-rwxr-xr-xlib/_ak_network46
-rwxr-xr-xlib/_ak_node4
-rwxr-xr-xlib/_ak_sblock2
-rwxr-xr-xlib/_ak_schain19
-rwxr-xr-xlib/_ak_settings8
-rwxr-xr-xlib/_ak_smfiles38
-rwxr-xr-xlib/_ak_zblock68
15 files changed, 140 insertions, 258 deletions
diff --git a/lib/_ak_cjdns b/lib/_ak_cjdns
index 30229ca..69e5ffc 100755
--- a/lib/_ak_cjdns
+++ b/lib/_ak_cjdns
@@ -25,7 +25,7 @@ cjdns_src_git_repo_url="https://github.com/cjdelisle/cjdns"
cjdnstoolspath="$HOME/cjdns/tools"
cargo_env="$HOME/.cargo/env"
-_ak_cjdns_check_availability(){
+function _ak_cjdns_check_availability(){
declare -a cjdns_bins=("cjdroute" "makekeys" "mkpasswd" "privatetopublic" "publictoip6" "randombytes" "sybilsim")
for cbin in "${cjdns_bins[@]}"
do
@@ -40,19 +40,20 @@ _ak_cjdns_check_availability(){
done
}
-_ak_cargo_rust_check_install(){
- if [ ! -f $cargo_env ]
+function _ak_cargo_rust_check_install(){
+ if [ ! -f ${cargo_env} ]
then
- curl --proto '=https' --tlsv1.2 -sSf $rust_sh_install_url | sh
+ curl --proto '=https' --tlsv1.2 -sSf ${rust_sh_install_url} | sh
fi
- source $cargo_env
+ source ${cargo_env}
}
-_ak_cjdns_install(){
+function _ak_cjdns_install(){
_ak_cargo_rust_check_install
- git clone $cjdns_src_git_repo_url
+ git clone ${cjdns_src_git_repo_url}
+ cjdns_install_script="./do"
cd cjdns
- sh do
+ sh ${cjdns_install_script}
if [ $? -ne 0 ]
then
_ak_log_error "Failed to compile cjdns"
@@ -66,25 +67,24 @@ _ak_cjdns_install(){
sudo cp cjdns/target/release/publictoip6 /usr/bin/publictoip6
sudo cp cjdns/target/release/randombytes /usr/bin/randombytes
sudo cp cjdns/target/release/sybilsim /usr/bin/sybilsim
- ln -s "$(realpath cjdns/tools/dumpLinks)" $HOME/.arching-kaos/bin/dumpLinks
- ln -s "$(realpath cjdns/tools/cexec)" $HOME/.arching-kaos/bin/cjdns-cexec
- ln -s "$(realpath cjdns/tools/peerStats)" $HOME/.arching-kaos/bin/peerStats
+ ln -s "$(realpath cjdns/tools/dumpLinks)" ${HOME}/.arching-kaos/bin/dumpLinks
+ ln -s "$(realpath cjdns/tools/cexec)" ${HOME}/.arching-kaos/bin/cjdns-cexec
+ ln -s "$(realpath cjdns/tools/peerStats)" ${HOME}/.arching-kaos/bin/peerStats
which systemctl 2> /dev/null 1>&2
if [ $? -ne 0 ]
then
_ak_log_error "Systemctl not found... TODO"
else
- sudo cp "$(realpath cjdns/contrib/systemd/cjdns.service)" /etc/systemd/system/cjdns.service
- sudo cp "$(realpath cjdns/contrib/systemd/cjdns-resume.service)" /etc/systemd/system/cjdns-resume.service
+ sudo cp cjdns/contrib/systemd/cjdns.service /etc/systemd/system/cjdns.service
+ sudo cp cjdns/contrib/systemd/cjdns-resume.service /etc/systemd/system/cjdns-resume.service
sudo systemctl enable --now cjdns.service
fi
}
-_ak_cjdns_read_peers_to_vars_with_jq(){
+function _ak_cjdns_read_peers_to_vars_with_jq(){
totalpeers="$(jq '. | length' < $peersfile)"
number="0"
interface="0"
-
while [ $number -lt $totalpeers ]
do
address="$(jq -r '.['$number'].address' < $peersfile)"
@@ -103,7 +103,7 @@ _ak_cjdns_read_peers_to_vars_with_jq(){
done
}
-_ak_cjdns_read_peers_to_vars_natively(){
+function _ak_cjdns_read_peers_to_vars_natively(){
number=-1
cat $peersfile | tr -d $'\n' | sed -e 's/]$/\n/g' | tr -d ' ' | sed -e 's/"//g; s/,/,\n/g; s/}//g; s/,//g' | while read line
do
@@ -150,8 +150,7 @@ _ak_cjdns_read_peers_to_vars_natively(){
rm peerfile
}
-
-_ak_cjdns_connect_peers(){
+function _ak_cjdns_connect_peers(){
_ak_network_cjdns_connect
exit $?
#
@@ -187,7 +186,7 @@ _ak_cjdns_connect_peers(){
fi
}
-_ak_cjdns_get_ip(){
+function _ak_cjdns_get_ip(){
which ip > /dev/null 2>&1
if [ $? -ne 0 ]
then
diff --git a/lib/_ak_coin b/lib/_ak_coin
index dd895a0..4c58e2d 100755
--- a/lib/_ak_coin
+++ b/lib/_ak_coin
@@ -26,7 +26,7 @@ COINBASE=100000000000
GENESIS="00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-_ak_coin_stats(){
+function _ak_coin_stats(){
echo "Coinbase: $COINBASE"
echo "Genesis: $GENESIS"
}
diff --git a/lib/_ak_config b/lib/_ak_config
index 0a4d55c..d8705d8 100755
--- a/lib/_ak_config
+++ b/lib/_ak_config
@@ -19,7 +19,7 @@
###
source $AK_LIBDIR/_ak_node
-_ak_config_show(){
+function _ak_config_show(){
# We will be using our public key also to put it in the block later
KEY="self.pub"
ak-gpg --export-key-self-to-file
@@ -27,7 +27,6 @@ _ak_config_show(){
GPG_PUB_KEY=$(_ak_ipfs_add $KEY)
rm $KEY
profile="$(ak-profile -l)"
-
echo '
{
"profile":'$profile',
@@ -38,7 +37,7 @@ _ak_config_show(){
}'| jq;
}
-_ak_config_publish(){
+function _ak_config_publish(){
_ak_config_show | jq -c -M > tmpfile
ipfs_hash="$(_ak_ipfs_add tmpfile)"
_ak_ipfs_config_publish $ipfs_hash
@@ -51,7 +50,7 @@ _ak_config_publish(){
rm tmpfile
}
-_ak_config_published(){
+function _ak_config_published(){
_ak_ipfs_cat $(_ak_node_info_ipfs_hash) | jq
}
diff --git a/lib/_ak_fs b/lib/_ak_fs
index bea850c..525b108 100755
--- a/lib/_ak_fs
+++ b/lib/_ak_fs
@@ -88,17 +88,14 @@ function _ak_fs_import(){
#
# 6. We are done!
#
-
# A temporary root dir to work on
TEMPDIR="$(_ak_make_temp_directory)"
# A subdir to split the files there
TCHKDIR="$TEMPDIR/chks"
# A pin point to return from where we came from
CURRENTDIR="$(pwd)"
-
# Checking directories and create them if necessary
# rm -rf $TEMPDIR
-
_ak_check_and_create_dir $TCHKDIR
_ak_fs_dir_init_setup
if [ ! -f "$1" ]
@@ -118,10 +115,8 @@ function _ak_fs_import(){
base64 $1 > file
FILE="file"
fi
-
# Uncomment next line in case you want to debug the resulting script as well
# echo 'set -xe' > $TEMPDIR/cmd_queue.sh
-
# We get the SHA512 hash for the $FILE given
CHECKSUM=$(sha512sum "$FILE"|awk '{print $1}')
FILE_SIZE="$( (du -b $FILE||stat -f %z $FILE)2>/dev/null | awk '{ print $1 }')"
@@ -140,7 +135,6 @@ function _ak_fs_import(){
split -a 13 -b $FACTOR -d "$FILE" "$TCHKDIR/chunk-"
fi
_ak_log_info "File done splitting"
-
# We go over there...
cd $TCHKDIR
#set -xe
@@ -164,7 +158,6 @@ function _ak_fs_import(){
done
_ak_log_debug "Ran $timesRan times"
_ak_log_debug "Total chunks $totalChunks"
-
workingIndex="$TEMPDIR/map"
c=$timesRan
while [ $c -ne 0 ]
@@ -193,7 +186,6 @@ function _ak_fs_import(){
totalChunks=`cat $workingIndex | wc -l`
c=`expr $c - 1`
done
-
if [ -f level.1.map ]
then
sha512sum level.1.map
@@ -202,12 +194,10 @@ function _ak_fs_import(){
ak_log_error "Got error an error, level.1.map is missing"
exit 1
fi
-
# Reset file with uniq
cat $TEMPDIR/map | uniq > $TEMPDIR/map2
cat $TEMPDIR/map2 > $TEMPDIR/map
rm $TEMPDIR/map2
-
counter=0
while IFS="" read -r p || [ -n "$p" ]
do
@@ -216,31 +206,22 @@ function _ak_fs_import(){
cp $(echo $p | awk '{ print $2 }') $AK_CHUNKSDIR/$(echo $p | awk '{ print $1 }')
counter=`expr "$counter" + 1`
done < $TEMPDIR/map
-
# We run the crafted script
# sh $TEMPDIR/cmd_queue.sh
-
# and we delete it
# rm $TEMPDIR/cmd_queue.sh
-
# We inform the map about the original $FILE name and SHA512
# echo "$CHECKSUM $(basename "$FILE")" >> $TEMPDIR/map
-
# We get the SHA512 hash of the resulted map file
# MAPFILEHASH="$(sha512sum $TEMPDIR/map | awk '{ print $1 }')"
-
# and we rename it with it and move it to AK_MAPSDIR
# `sha512sum $TEMPDIR/map | awk '{print "mv " $2 " '$AK_MAPSDIR/'" $1}'`
-
mp512p="$(sha512sum $TEMPDIR/3rd_gen_map | awk '{print $1}')"
cp $TEMPDIR/3rd_gen_map $AK_MAPSDIR/$mp512p
-
# We remove the TEMPDIR
rm -rf $TEMPDIR
-
# and print the MAPFILEHASH
echo "$mp512p"
-
}
function _ak_fs_find_depth(){
@@ -325,7 +306,6 @@ function _ak_fs_cat(){
done < workspace.$counter
counter="$(expr $counter + 1)"
done
-
base64 -d output
_ak_log_info "Recreation of $treeRootHash succeeded!"
}
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
index 1450c60..bdb8829 100755
--- a/lib/_ak_gpg
+++ b/lib/_ak_gpg
@@ -24,11 +24,11 @@ source $AK_LIBDIR/_ak_settings
export AK_FINGERPRINT="$(_ak_settings_get gpg.fingerprint)"
-_ak_gpg(){
+function _ak_gpg(){
gpg2 --homedir $AK_GPGHOME $*
}
-_ak_gpg_check_or_create(){
+function _ak_gpg_check_or_create(){
_ak_gpg --list-keys | grep kaos@kaos.kaos -B 1
if [ $? -ne 0 ]
then
@@ -38,7 +38,7 @@ _ak_gpg_check_or_create(){
fi
}
-_ak_gpg_create_key(){
+function _ak_gpg_create_key(){
_ak_log_debug "Key name: $1"
if [ -z $1 ] || [ ! -n "$1" ]
then
@@ -56,7 +56,7 @@ _ak_gpg_create_key(){
_ak_gpg --batch --passphrase '' --quick-add-key $FINGERPRINT rsa4096 encrypt 0
}
-_ak_gpg_key_import_from_file(){
+function _ak_gpg_key_import_from_file(){
if [ -z $1 ]
then
_ak_log_error "No argument given"
@@ -75,11 +75,11 @@ _ak_gpg_key_import_from_file(){
_ak_gpg --import $AK_IPFS_ARTIFACTS/$1 > /dev/null 2>&1
}
-_ak_gpg_key_self_get_fingerprint_from_config(){
+function _ak_gpg_key_self_get_fingerprint_from_config(){
_ak_config_show | jq -r '.gpg'
}
-_ak_gpg_key_self_get_fingerprint(){
+function _ak_gpg_key_self_get_fingerprint(){
if [ -z $1 ]
then
_ak_ipfs_cat "$(_ak_gpg_key_self_get_fingerprint_from_config)" | \
@@ -92,7 +92,7 @@ _ak_gpg_key_self_get_fingerprint(){
fi
}
-_ak_gpg_key_get_fingerprint_from_ipfs(){
+function _ak_gpg_key_get_fingerprint_from_ipfs(){
if [ -n "$1" ]
then
_ak_ipfs_cat "$1" | \
@@ -105,7 +105,7 @@ _ak_gpg_key_get_fingerprint_from_ipfs(){
fi
}
-_ak_gpg_sign(){
+function _ak_gpg_sign(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
then
_ak_gpg --sign --sign-with $AK_FINGERPRINT --armor --output $1 $2
@@ -114,7 +114,7 @@ _ak_gpg_sign(){
fi
}
-_ak_gpg_sign_detached(){
+function _ak_gpg_sign_detached(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
then
_ak_gpg --detach-sign --sign-with $AK_FINGERPRINT --armor --output $1 $2
@@ -124,7 +124,7 @@ _ak_gpg_sign_detached(){
fi
}
-_ak_gpg_sign_clear(){
+function _ak_gpg_sign_clear(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
then
_ak_gpg --clear-sign --sign-with $AK_FINGERPRINT --armor --output $1 $2
@@ -133,7 +133,7 @@ _ak_gpg_sign_clear(){
fi
}
-_ak_gpg_encrypt_sign(){
+function _ak_gpg_encrypt_sign(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
then
_ak_gpg --sign-with $AK_FINGERPRINT --encypt -r $3 --armor --output $1 $2
@@ -142,7 +142,7 @@ _ak_gpg_encrypt_sign(){
fi
}
-_ak_gpg_encrypt_sign_for_self(){
+function _ak_gpg_encrypt_sign_for_self(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
then
_ak_gpg --sign-with $AK_FINGERPRINT --encypt -r $AK_FINGERPRINT --armor --output $1 $2
@@ -151,7 +151,7 @@ _ak_gpg_encrypt_sign_for_self(){
fi
}
-_ak_gpg_encrypt(){
+function _ak_gpg_encrypt(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
then
_ak_gpg --encypt -r $3 --armor --output $1 $2
@@ -160,7 +160,7 @@ _ak_gpg_encrypt(){
fi
}
-_ak_gpg_encrypt_for_self(){
+function _ak_gpg_encrypt_for_self(){
if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
then
_ak_gpg --encypt -r $AK_FINGERPRINT --armor --output $1 $2
@@ -169,7 +169,7 @@ _ak_gpg_encrypt_for_self(){
fi
}
-_ak_gpg_verify_clear_signature(){
+function _ak_gpg_verify_clear_signature(){
if [ ! -z $1 ] && [ -n "$1" ] && [ -f "$1" ]
then
fingerprint="$(cat $1 | _ak_gpg 2>&1 | grep RSA | awk '{print $5}')"
@@ -186,7 +186,7 @@ _ak_gpg_verify_clear_signature(){
fi
}
-_ak_gpg_verify_signature(){
+function _ak_gpg_verify_signature(){
if [ ! -z $1 ] && [ -n "$1" ] && [ -f "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ -f "$2" ]
then
_ak_gpg --verify $1 $2 > /dev/null 2>&1
@@ -196,7 +196,7 @@ _ak_gpg_verify_signature(){
fi
}
-_ak_gpg_key_self_export(){
+function _ak_gpg_key_self_export(){
if [ ! -z $1 ] && [ -n "$1" ]
then
_ak_gpg --armour --output $1 --export $AK_FINGERPRINT
@@ -205,15 +205,15 @@ _ak_gpg_key_self_export(){
fi
}
-_ak_gpg_list_keys_plain(){
+function _ak_gpg_list_keys_plain(){
_ak_gpg --list-keys
}
-_ak_gpg_list_keys(){
+function _ak_gpg_list_keys(){
_ak_gpg --list-keys | grep '^ ' | awk '{print $1}'
}
-_ak_gpg_list_keys_long(){
+function _ak_gpg_list_keys_long(){
_ak_gpg --list-keys | \
grep -A 1 '^ \{6\}' | \
tr $'\n' ' ' | \
@@ -224,15 +224,15 @@ _ak_gpg_list_keys_long(){
uniq
}
-_ak_gpg_list_secret_keys_plain(){
+function _ak_gpg_list_secret_keys_plain(){
_ak_gpg --list-secret-keys
}
-_ak_gpg_list_secret_keys(){
+function _ak_gpg_list_secret_keys(){
_ak_gpg --list-secret-keys | grep '^ ' | awk '{print $1}'
}
-_ak_gpg_list_secret_keys_long(){
+function _ak_gpg_list_secret_keys_long(){
_ak_gpg --list-secret-keys | \
grep -A 1 '^ \{6\}' | \
tr $'\n' ' ' | \
@@ -243,7 +243,7 @@ _ak_gpg_list_secret_keys_long(){
uniq
}
-_ak_gpg_select_key(){
+function _ak_gpg_select_key(){
select x in $(_ak_gpg_list_secret_keys | tr '\n' ' ')
do
if [ -n "$x" ]
@@ -257,7 +257,7 @@ _ak_gpg_select_key(){
done
}
-_ak_gpg_delete_key(){
+function _ak_gpg_delete_key(){
select x in $(_ak_gpg_list_keys | tr '\n' ' ')
do
if [ -n "$x" ]
@@ -277,7 +277,7 @@ _ak_gpg_delete_key(){
done
}
-_ak_gpg_delete_secret_key(){
+function _ak_gpg_delete_secret_key(){
if [ ! -z $1 ]
then
x="$1"
diff --git a/lib/_ak_html b/lib/_ak_html
index 5a47836..491cb6c 100755
--- a/lib/_ak_html
+++ b/lib/_ak_html
@@ -19,7 +19,7 @@
###
source $AK_LIBDIR/_ak_log
-_ak_generate_html_header(){
+function _ak_generate_html_header(){
printf '<!DOCTYPE html>\n<html>\n<head>\n'
printf '<title>Arching Kaos Chain Data</title>\n'
printf ' <meta charset="UTF-8">\n'
@@ -82,7 +82,7 @@ _ak_generate_html_header(){
printf '<body>\n'
}
-_ak_generate_html_zblock(){
+function _ak_generate_html_zblock(){
if [ ! -z $1 ] && [ -n "$1" ]
then
arg="$1"
@@ -160,7 +160,6 @@ _ak_generate_html_zblock(){
_ak_log_error "Empty datablock value"
exit 1
fi
-
# Output data in HTML format
printf ' <h1>%s</h1>\n' "$PROGRAM"
printf ' <h2>🔎 %szblock</h2>\n' "$zblock"
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs
index 1297949..f2e0629 100755
--- a/lib/_ak_ipfs
+++ b/lib/_ak_ipfs
@@ -25,7 +25,7 @@ then
mkdir -p $AK_IPFS_ARTIFACTS
fi
-_ak_ipfs(){
+function _ak_ipfs(){
export IPFS_PATH=$AK_IPFS_REPO; kubo $*
if [ $? -ne 0 ]
then
@@ -34,12 +34,12 @@ _ak_ipfs(){
fi
}
-_ak_ipfs_daemon(){
+function _ak_ipfs_daemon(){
_ak_ipfs daemon --routing=dht --migrate &
printf '%s' "$!" > $AK_WORKDIR/akipfsd.pid
}
-_ak_ipfs_swarm_connect(){
+function _ak_ipfs_swarm_connect(){
if [ ! -z $1 ] && [ -n "$1" ]
then
_ak_ipfs swarm connect "$1"
@@ -48,7 +48,7 @@ _ak_ipfs_swarm_connect(){
fi
}
-_ak_ipfs_get_peers(){
+function _ak_ipfs_get_peers(){
_ak_ipfs swarm peers 1> /dev/null 2>&1
if [ $? -eq 0 ]
then
@@ -56,7 +56,7 @@ _ak_ipfs_get_peers(){
fi
}
-_ak_ipfs_scanner(){
+function _ak_ipfs_scanner(){
peersIPFSfile="$AK_WORKDIR/peers.ipfs"
ak_peersIPFSfile="$AK_WORKDIR/ipfs.peers.akn"
if [ ! -f $peersIPFSfile ]
@@ -104,7 +104,7 @@ _ak_ipfs_scanner(){
mv walk.aknet $ak_peersIPFSfile
}
-_ak_ipfs_add(){
+function _ak_ipfs_add(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "no argument given"
@@ -120,7 +120,7 @@ _ak_ipfs_add(){
fi
}
-_ak_ipfs_block_stat(){
+function _ak_ipfs_block_stat(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "no argument given"
@@ -134,7 +134,7 @@ _ak_ipfs_block_stat(){
fi
}
-_ak_ipfs_files_cp(){
+function _ak_ipfs_files_cp(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "Source: No argument given"
@@ -153,7 +153,7 @@ _ak_ipfs_files_cp(){
fi
}
-_ak_ipfs_files_ls(){
+function _ak_ipfs_files_ls(){
_ak_ipfs files ls "$1"
if [ $? -ne 0 ]
then
@@ -162,7 +162,7 @@ _ak_ipfs_files_ls(){
fi
}
-_ak_ipfs_files_mkdir(){
+function _ak_ipfs_files_mkdir(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -176,7 +176,7 @@ _ak_ipfs_files_mkdir(){
fi
}
-_ak_ipfs_files_mv(){
+function _ak_ipfs_files_mv(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -195,7 +195,7 @@ _ak_ipfs_files_mv(){
fi
}
-_ak_ipfs_files_rm(){
+function _ak_ipfs_files_rm(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -209,7 +209,7 @@ _ak_ipfs_files_rm(){
fi
}
-_ak_ipfs_files_stat(){
+function _ak_ipfs_files_stat(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -223,7 +223,7 @@ _ak_ipfs_files_stat(){
fi
}
-_ak_ipfs_get(){
+function _ak_ipfs_get(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -244,7 +244,7 @@ _ak_ipfs_get(){
fi
}
-_ak_ipfs_cat(){
+function _ak_ipfs_cat(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "no argument given"
@@ -262,8 +262,7 @@ _ak_ipfs_cat(){
fi
}
-
-_ak_ipfs_key_gen(){
+function _ak_ipfs_key_gen(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -277,7 +276,7 @@ _ak_ipfs_key_gen(){
fi
}
-_ak_ipfs_key_list(){
+function _ak_ipfs_key_list(){
_ak_ipfs key list
if [ $? -ne 0 ]
then
@@ -286,7 +285,7 @@ _ak_ipfs_key_list(){
fi
}
-_ak_ipfs_key_list_full(){
+function _ak_ipfs_key_list_full(){
_ak_ipfs key list -l
if [ $? -ne 0 ]
then
@@ -295,7 +294,7 @@ _ak_ipfs_key_list_full(){
fi
}
-_ak_ipfs_name_publish(){
+function _ak_ipfs_name_publish(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -314,7 +313,7 @@ _ak_ipfs_name_publish(){
fi
}
-_ak_ipfs_config_publish(){
+function _ak_ipfs_config_publish(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -324,7 +323,7 @@ _ak_ipfs_config_publish(){
_ak_ipfs_name_publish "ak-config" $1
}
-_ak_ipfs_name_resolve(){
+function _ak_ipfs_name_resolve(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "No argument given"
@@ -338,7 +337,7 @@ _ak_ipfs_name_resolve(){
fi
}
-_ak_ipfs_swarm_peers(){
+function _ak_ipfs_swarm_peers(){
_ak_ipfs swarm peers
if [ $? -ne 0 ]
then
@@ -347,7 +346,7 @@ _ak_ipfs_swarm_peers(){
fi
}
-_ak_ipfs_starter(){
+function _ak_ipfs_starter(){
_ak_ipfs_daemon
if [ $? -ne 0 ]
then
@@ -363,7 +362,7 @@ _ak_ipfs_starter(){
fi
}
-_ak_ipns_resolve(){
+function _ak_ipns_resolve(){
if [ ! -z $1 ]
then
rsld=$(_ak_ipfs_name_resolve $1)
@@ -380,7 +379,7 @@ _ak_ipns_resolve(){
fi
}
-_ak_ipfs_check_config_key(){
+function _ak_ipfs_check_config_key(){
_ak_ipfs_key_list | grep ak-config > /dev/null
if [ $? -ne 0 ]
then
@@ -397,7 +396,7 @@ _ak_ipfs_check_config_key(){
fi
}
-_ak_ipfs_check_zchain_key(){
+function _ak_ipfs_check_zchain_key(){
_ak_ipfs_key_list | grep zchain > /dev/null
if [ $? -ne 0 ]
then
@@ -414,7 +413,7 @@ _ak_ipfs_check_zchain_key(){
fi
}
-_ak_ipfs_check_zarchive_dir(){
+function _ak_ipfs_check_zarchive_dir(){
_ak_ipfs_files_ls /zarchive > /dev/null
if [ $? -ne 0 ]
then
@@ -424,7 +423,7 @@ _ak_ipfs_check_zarchive_dir(){
fi
}
-_ak_ipfs_check_zlatest_file(){
+function _ak_ipfs_check_zlatest_file(){
_ak_ipfs_files_ls /zlatest > /dev/null
if [ $? -ne 0 ]
then
@@ -434,14 +433,14 @@ _ak_ipfs_check_zlatest_file(){
fi
}
-_ak_ipfs_check(){
+function _ak_ipfs_check(){
_ak_ipfs_check_zarchive_dir
_ak_ipfs_check_zlatest_file
_ak_ipfs_check_config_key
_ak_ipfs_check_zchain_key
}
-_ak_ipfs_init(){
+function _ak_ipfs_init(){
if [ ! -d $AK_IPFS_REPO ]
then
mkdir $AK_IPFS_REPO
@@ -449,7 +448,7 @@ _ak_ipfs_init(){
fi
}
-_ak_ipfs_download(){
+function _ak_ipfs_download(){
_ak_log_info "Attempting to install IPFS..."
IPFS_VERSION="$(curl \
--connect-timeout 3 \
@@ -481,7 +480,7 @@ _ak_ipfs_download(){
fi
}
-_ak_ipfs_cid_v0_check(){
+function _ak_ipfs_cid_v0_check(){
if [ -z $1 ] || [ ! -n "$1" ]
then
_ak_log_error "_ak_ipfs_cid_v0_check: No argument given"
@@ -501,7 +500,7 @@ _ak_ipfs_cid_v0_check(){
_ak_log_debug "_ak_ipfs_cid_v0_check: $1 provided is an IPFS CIDv0 string"
}
-_ak_ipfs_swarm_install(){
+function _ak_ipfs_swarm_install(){
SWARMSHA512SUM="7001e37412758c43d372a969e977ca11511e034c8c1e233a58dc3ce1c6f3c1aa7d2da8cba9944a5eabaa8885742bfe6cc6794224c146b7129da8f633b53b9cfc"
if [ ! -f $AK_IPFS_REPO/swarm.key ]
then
@@ -516,6 +515,6 @@ _ak_ipfs_swarm_install(){
fi
}
-_ak_ipfs_get_config_ipns_key(){
+function _ak_ipfs_get_config_ipns_key(){
_ak_ipfs_key_list_full | grep 'ak-config' | cut -d ' ' -f 1
}
diff --git a/lib/_ak_log b/lib/_ak_log
index f6ffc21..8d6972d 100755
--- a/lib/_ak_log
+++ b/lib/_ak_log
@@ -18,7 +18,7 @@
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-_ak_log_print_log_line(){
+function _ak_log_print_log_line(){
if [ -n "$1" ]
then
timestamp="$(echo "$*" | awk '{print $1}')"
@@ -33,14 +33,14 @@ _ak_log_print_log_line(){
fi
}
-_ak_log_follow(){
+function _ak_log_follow(){
tail -f $AK_LOGSFILE | while read -r p || [ -n "$p" ]
do
_ak_log_print_log_line "$p"
done
}
-_ak_log_grep(){
+function _ak_log_grep(){
if [ ! -z $1 ] && [ -n "$1" ]
then
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
@@ -50,7 +50,6 @@ _ak_log_grep(){
exit 1
fi
fi
-
echo "The following scripts have entries in the log file."
echo "Select one of those by entering the number of it below and hit enter:"
select x in $(cat $AK_LOGSFILE | cut -d ' ' -f 2 | sort | uniq)
@@ -63,7 +62,7 @@ _ak_log_grep(){
done
}
-_ak_log_rotate(){
+function _ak_log_rotate(){
if [ -f $AK_LOGSFILE ]
then
tar cvfz $AK_ARCHIVESDIR/logs_$(date -u +%s).tar.gz $AK_WORKDIR/logs
@@ -76,7 +75,7 @@ _ak_log_rotate(){
fi
}
-_ak_log_message(){
+function _ak_log_message(){
TS="$(date -u +%s)"
if [ ! -z $1 ] && [ -n "$1" ]
then
@@ -116,23 +115,23 @@ _ak_log_message(){
fi
}
-_ak_log_exit(){
+function _ak_log_exit(){
_ak_log_message "$PROGRAM" "EXIT" "$1"
}
-_ak_log_warning(){
+function _ak_log_warning(){
_ak_log_message "$PROGRAM" "WARNING" "$1"
}
-_ak_log_debug(){
+function _ak_log_debug(){
_ak_log_message "$PROGRAM" "DEBUG" "$1"
}
-_ak_log_error(){
+function _ak_log_error(){
_ak_log_message "$PROGRAM" "ERROR" "$1"
}
-_ak_log_info(){
+function _ak_log_info(){
_ak_log_message "$PROGRAM" "INFO" "$1"
}
diff --git a/lib/_ak_network b/lib/_ak_network
index a6faf87..2bddfd5 100755
--- a/lib/_ak_network
+++ b/lib/_ak_network
@@ -22,7 +22,7 @@ source $AK_LIBDIR/_ak_ipfs
cjdnstoolspath="$HOME/cjdns/tools"
-_ak_network_stellar_show_ids(){
+function _ak_network_stellar_show_ids(){
i=0
flag=0
while [ "$i" -lt "$limit" ]
@@ -47,19 +47,19 @@ _ak_network_stellar_show_ids(){
done
}
-_ak_network_stellar_get_next_page(){
+function _ak_network_stellar_get_next_page(){
cat $tempfile | jq -r '._links.next.href'
# cat $tempfile | grep -1 next | grep https | sed -e 's/^.*https/https/' | sed -e 's/\u0026/\&/g; s/"//g; s/\\//g'
}
-_ak_network_stellar_proceed_to_next_page(){
+function _ak_network_stellar_proceed_to_next_page(){
nextURL="$(_ak_network_stellar_get_next_page)"
curl \
--connect-timeout 3 \
"$nextURL" > $tempfile 2>/dev/null
}
-_ak_network_stellar_get_asset_holders(){
+function _ak_network_stellar_get_asset_holders(){
if [ ! -z $1 ] && [ $1 -gt 0 ] && [ -n "$1" ]
then
limit=$1
@@ -71,11 +71,10 @@ _ak_network_stellar_get_asset_holders(){
https://horizon.stellar.org/accounts\?asset\=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2\&limit\=$limit > $tempfile 2>/dev/null
}
-_ak_network_scan_stellar(){
+function _ak_network_scan_stellar(){
tempdir=`_ak_make_temp_directory`
tempfile="$tempdir/tmp"
tempaddr="$tempdir/tmpaddr"
-
stellarParticipants="$AK_WORKDIR/stellar-network-participants"
stellarParticipantsOnline="$AK_WORKDIR/stellar-network-participants-online"
if [ ! -f "$stellarParticipants" ]
@@ -94,21 +93,18 @@ _ak_network_scan_stellar(){
then
touch $tempaddr
fi
-
if [ ! -z $1 ] && [ "$1" == "-l" ] && [ ! -z $2 ]
then
limit=$2
else
limit=3
fi
-
_ak_network_stellar_get_asset_holders $limit
while [ "$(tail -1 $stellarParticipants)" != "null" ]
do
_ak_network_stellar_show_ids
_ak_network_stellar_proceed_to_next_page
done
-
grep G $stellarParticipants > $tempaddr
cat $tempaddr > $stellarParticipants
rm $tempfile $tempaddr
@@ -140,11 +136,11 @@ _ak_network_scan_stellar(){
done < $stellarParticipants
}
-_ak_network_scan_ipfs(){
+function _ak_network_scan_ipfs(){
_ak_not_implemented _ak_network_scan_ipfs
}
-_ak_network_scan_cjdns_dump(){
+function _ak_network_scan_cjdns_dump(){
#
# Needs CJDNS tools in your PATH
#
@@ -208,7 +204,7 @@ _ak_network_scan_cjdns_dump(){
rm -rf $TEMPDIR
}
-_ak_network_scan_cjdns_full(){
+function _ak_network_scan_cjdns_full(){
# This scan is using HIA resources to scan the whole cjdns network for peers
#
# Ref:
@@ -276,7 +272,7 @@ _ak_network_scan_cjdns_full(){
rm -rf $TEMPDIR
}
-_ak_network_scan_yggdrasil_full(){
+function _ak_network_scan_yggdrasil_full(){
# This scan is using HIA resources to scan the whole cjdns network for peers
#
# Ref:
@@ -331,7 +327,7 @@ _ak_network_scan_yggdrasil_full(){
rm -rf $TEMPDIR
}
-_ak_network_scan_cjdns(){
+function _ak_network_scan_cjdns(){
if [ ! -z $1 ] && [ -n "$1" ]
then
case $1 in
@@ -344,7 +340,7 @@ _ak_network_scan_cjdns(){
fi
}
-_ak_network_scan_yggdrasil(){
+function _ak_network_scan_yggdrasil(){
if [ ! -z $1 ] && [ -n "$1" ]
then
case $1 in
@@ -355,7 +351,7 @@ _ak_network_scan_yggdrasil(){
fi
}
-_ak_network_scan(){
+function _ak_network_scan(){
if [ ! -z $1 ] && [ -n "$1" ]
then
case $1 in
@@ -372,7 +368,7 @@ _ak_network_scan(){
_ak_network_scan_yggdrasil
fi
}
-_ak_network_show_peers_stellar(){
+function _ak_network_show_peers_stellar(){
stellarParticipants="$AK_WORKDIR/stellar-network-participants"
stellarParticipantsOnline="$AK_WORKDIR/stellar-network-participants-online"
if [ -f "${stellarParticipantsOnline}" ]
@@ -400,7 +396,7 @@ _ak_network_show_peers_stellar(){
fi
}
-_ak_network_show_peers_cjdns(){
+function _ak_network_show_peers_cjdns(){
if [ -f $AK_ZPEERSFILE.hyperboria ]
then
cat $AK_ZPEERSFILE.hyperboria | jq
@@ -409,7 +405,7 @@ _ak_network_show_peers_cjdns(){
fi
}
-_ak_network_show_peers_yggdrasil(){
+function _ak_network_show_peers_yggdrasil(){
if [ -f $AK_ZPEERSFILE.yggdrasil ]
then
cat $AK_ZPEERSFILE.yggdrasil | jq
@@ -418,11 +414,11 @@ _ak_network_show_peers_yggdrasil(){
fi
}
-_ak_network_show_peers_ipfs(){
+function _ak_network_show_peers_ipfs(){
_ak_not_implemented _ak_network_show_peers_ipfs
}
-_ak_network_show_peers(){
+function _ak_network_show_peers(){
if [ ! -z $1 ] && [ -n "$1" ]
then
case $1 in
@@ -440,14 +436,14 @@ _ak_network_show_peers(){
fi
}
-_ak_network_ipfs_connect_bootstrap(){
+function _ak_network_ipfs_connect_bootstrap(){
curl -s "https://arching-kaos.net/files/ak_ipfs_bootstrap_peers" | while read peer
do
_ak_ipfs_swarm_connect "$peer"
done
}
-_ak_network_cjdns_connect(){
+function _ak_network_cjdns_connect(){
if [ ! -z $1 ] && [ -n "$1" ] && [ -f $1 ]
then
peersfile="$1"