diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/_ak_config | 49 | ||||
-rwxr-xr-x | lib/_ak_gpg | 3 | ||||
-rwxr-xr-x | lib/_ak_zblock | 2 | ||||
-rwxr-xr-x | lib/_ak_zchain | 5 |
4 files changed, 55 insertions, 4 deletions
diff --git a/lib/_ak_config b/lib/_ak_config new file mode 100755 index 0000000..c362178 --- /dev/null +++ b/lib/_ak_config @@ -0,0 +1,49 @@ +#!/bin/bash + +source $AK_LIBDIR/_ak_gpg +source $AK_LIBDIR/_ak_ipfs +source $AK_LIBDIR/_ak_node + +_ak_config_get_ipns_key(){ + _ak_ipfs_key_list_full | grep 'ak-config' | cut -d ' ' -f 1 +} + +_ak_config_show(){ + # We will be using our public key also to put it in the block later + KEY="tmp-gpg.pub" + _ak_gpg_key_self_export $KEY + GPG_PUB_KEY=$(_ak_ipfs_add $KEY) + rm $KEY + profile="$(ak-profile -l)" + + echo ' +{ + "profile":'$profile', + "genesis":"'$(cat $AK_WORKDIR/config/zgenesis)'", + "gpg":"'$GPG_PUB_KEY'", + "zchain":"'$(cat $AK_WORKDIR/config/zchain)'", + "zlatest":"'$(ak-get-zlatest)'" +}'| jq; +} + +_ak_config_publish(){ + _ak_config_show | jq -c -M > tmpfile + _ak_ipfs key list | grep ak-config 2> /dev/null 1>&2 + if [ $? -ne 0 ] + then + _ak_ipfs_key_gen ak-config + fi + _ak_ipfs_name_publish --key=ak-config /ipfs/$(_ak_ipfs_add tmpfile) + if [ $? != 0 ] + then + echo -e "\033[0;34mError on publishing\033[0;0m\nYour information:\n" + cat tmpfile + exit 1 + fi + rm tmpfile +} + +_ak_config_published(){ + _ak_ipfs_cat $(_ak_node_info_ipfs_hash) | jq +} + diff --git a/lib/_ak_gpg b/lib/_ak_gpg index d220a4b..80e461c 100755 --- a/lib/_ak_gpg +++ b/lib/_ak_gpg @@ -1,6 +1,7 @@ #!/bin/bash source $AK_LIBDIR/_ak_log source $AK_LIBDIR/_ak_ipfs +source $AK_LIBDIR/_ak_config _ak_gpg(){ gpg2 --homedir $AK_GPGHOME $* @@ -26,7 +27,7 @@ _ak_gpg_key_import_from_file(){ } _ak_gpg_key_self_get_fingerprint_from_config(){ - ak-config --show | jq -r '.gpg' + _ak_config_show | jq -r '.gpg' } _ak_gpg_key_self_get_fingerprint(){ diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 278619f..6afacfc 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -551,7 +551,7 @@ _ak_zblock_pack(){ _ak_log_error "Could not copy $ZBLOCK to /zlatest" exit 1 fi - ak-config --publish + _ak_config_publish if [ $? -ne 0 ] then _ak_log_error "Could not publish new configuration" diff --git a/lib/_ak_zchain b/lib/_ak_zchain index 147f8d5..462a509 100755 --- a/lib/_ak_zchain +++ b/lib/_ak_zchain @@ -1,6 +1,7 @@ #!/bin/bash source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_config _ak_zchain_reset(){ echo "Reseting ZLATEST to ZGENESIS" @@ -28,7 +29,7 @@ _ak_zchain_reset(){ _ak_ipfs_name_publish --key=zchain /ipfs/$(cat $ZLATEST) if [ $? != 0 ]; then exit 1; fi - ak-config --publish + _ak_config_publish if [ $? -ne 0 ] then _ak_log_error "Could not publish new configuration" @@ -67,7 +68,7 @@ _ak_zchain_rebase(){ _ak_ipfs_name_publish --key=zchain /ipfs/$(cat $AK_ZLATEST) if [ $? != 0 ]; then exit 1; fi - ak-config --publish + _ak_config_publish if [ $? -ne 0 ] then _ak_log_error "Could not publish new configuration" |