diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-07-04 18:36:54 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-07-04 18:36:54 +0300 |
commit | c0dbfc8dc7cf7af278de1d233d87ffbe481ba704 (patch) | |
tree | 9037aef8094102626f387cec6d026793478fd53a /lib/_ak_ipfs | |
parent | 2d04f1e16cd234b6ad82eff3c4cd6b09149ef4ec (diff) | |
download | arching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.tar.gz arching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.tar.bz2 arching-kaos-tools-c0dbfc8dc7cf7af278de1d233d87ffbe481ba704.zip |
Refactoring + bug fixes
- Recursive sourcing was introduced and fixed
- Almost finished removing old style commands 'ak-zchain-chk' in favor
of the new design (eg 'ak zchain --check')
- A couple of changes on how we really do concatenation of an IPFS link
- Interface function for publishing to 'ak-config' key
- Interface function for publishing to IPNS keys
Diffstat (limited to 'lib/_ak_ipfs')
-rwxr-xr-x | lib/_ak_ipfs | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs index 3437083..5c47f91 100755 --- a/lib/_ak_ipfs +++ b/lib/_ak_ipfs @@ -265,7 +265,7 @@ _ak_ipfs_name_publish(){ _ak_log_error "No argument given" exit 1 fi - _ak_ipfs name publish "$1" "$2" + _ak_ipfs name publish --key="$1" "$2" if [ $? -ne 0 ] then _ak_log_error "Failed to get $1" @@ -273,6 +273,16 @@ _ak_ipfs_name_publish(){ fi } +_ak_ipfs_config_publish(){ + if [ -z $1 ] || [ ! -n "$1" ] + then + _ak_log_error "No argument given" + exit 1 + fi + _ak_ipfs_check_config_key + _ak_ipfs_name_publish "ak-config" $1 +} + _ak_ipfs_name_resolve(){ if [ -z $1 ] || [ ! -n "$1" ] then @@ -321,21 +331,24 @@ _ak_ipns_resolve(){ fi } -_ak_ipfs_check(){ - _ak_ipfs_files_ls /zarchive > /dev/null - if [ $? -ne 0 ] - then - _ak_log_error "/zarchive is missing" - else - _ak_log_info "/zarchive OK" - fi - _ak_ipfs_files_ls /zlatest > /dev/null +_ak_ipfs_check_config_key(){ + _ak_ipfs_key_list | grep ak-config > /dev/null if [ $? -ne 0 ] then - _ak_log_error "/zlatest is missing" + _ak_log_warning "ak-config key is missing" + _ak_ipfs_key_gen ak-config + if [ $? -ne 0 ] + then + _ak_log_error "ak-config fails to create" + else + _ak_log_info "ak-config created" + fi else - _ak_log_info "/zlatest is OK" + _ak_log_info "ak-config is there" fi +} + +_ak_ipfs_check_zchain_key(){ _ak_ipfs_key_list | grep zchain > /dev/null if [ $? -ne 0 ] then @@ -350,22 +363,35 @@ _ak_ipfs_check(){ else _ak_log_info "zchain is there" fi - _ak_ipfs_key_list | grep ak-config > /dev/null +} + +_ak_ipfs_check_zarchive_dir(){ + _ak_ipfs_files_ls /zarchive > /dev/null if [ $? -ne 0 ] then - _ak_log_warning "ak-config key is missing" - _ak_ipfs_key_gen ak-config - if [ $? -ne 0 ] - then - _ak_log_error "ak-config fails to create" - else - _ak_log_info "ak-config created" - fi + _ak_log_error "/zarchive is missing" else - _ak_log_info "ak-config is there" + _ak_log_info "/zarchive OK" fi } +_ak_ipfs_check_zlatest_file(){ + _ak_ipfs_files_ls /zlatest > /dev/null + if [ $? -ne 0 ] + then + _ak_log_error "/zlatest is missing" + else + _ak_log_info "/zlatest is OK" + fi +} + +_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(){ if [ ! -d $AK_IPFS_REPO ] then @@ -429,3 +455,7 @@ _ak_ipfs_swarm_install() { _ak_log_error "Visit https://arching-kaos.net/files/swarm.key and copy it to your ipfs folder" fi } + +_ak_ipfs_get_config_ipns_key(){ + _ak_ipfs_key_list_full | grep 'ak-config' | cut -d ' ' -f 1 +} |