aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-node-info
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-02-27 07:20:27 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-02-27 07:20:27 +0200
commitfa5d6becb482da75e65683b0ae690d35fa3eade6 (patch)
tree131bae638ebcdde7179620a0b0b5153aa36b927a /bin/ak-node-info
parent1da7813fe8dab6deb3bcbcfe79f4ad44c5f7fe0c (diff)
downloadarching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.tar.gz
arching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.tar.bz2
arching-kaos-tools-fa5d6becb482da75e65683b0ae690d35fa3eade6.zip
Refactor Arching Kaos ID to node_info
Diffstat (limited to 'bin/ak-node-info')
-rwxr-xr-xbin/ak-node-info34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/ak-node-info b/bin/ak-node-info
new file mode 100755
index 0000000..73217a0
--- /dev/null
+++ b/bin/ak-node-info
@@ -0,0 +1,34 @@
+#!/bin/bash
+PROGRAM="$(basename $0)"
+# Resolves the IPNS key "ak-config" to its current IPFS value
+# Return IPFS CIDv0 without /ipfs/ prefix
+_ak_node_info_ipfs_hash(){
+ ak-ipfs-name-resolve /ipns/$(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///'
+}
+
+# Finds ak-config ipns key
+# Returns IPNS key
+_ak_node_info_ipns_key(){
+ ak-ipfs-key-list-full | grep ak-config | awk '{print $1}'
+}
+
+_ak_node_info_usage(){
+ echo "$PROGRAM ipfs | ipns"
+}
+
+if [ ! -z "$1" ]
+then
+ case "$1" in
+ ipfs)
+ _ak_node_info_ipfs_hash
+ ;;
+ ipns)
+ _ak_node_info_ipns_key
+ ;;
+ *)
+ _ak_node_info_usage
+ ;;
+ esac
+else
+ _ak_node_info_usage
+fi