aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2022-11-02 03:16:42 +0200
committerkaotisk <kaotisk@arching-kaos.org>2022-11-02 03:16:42 +0200
commit1db7cda752ed90919917b6979975eae0c7ed4af3 (patch)
tree01b32f6f40d66c248d715d3434742255e29ad2a8
parent082177d774668ee925e43da0d741d8642d87f9ea (diff)
downloadarching-kaos-tools-1db7cda752ed90919917b6979975eae0c7ed4af3.tar.gz
arching-kaos-tools-1db7cda752ed90919917b6979975eae0c7ed4af3.tar.bz2
arching-kaos-tools-1db7cda752ed90919917b6979975eae0c7ed4af3.zip
Adapting to 96ae225b2a179ec36fdb01eaf906fec096002a08 change, also provide usage text
-rwxr-xr-xbin/ipns-resolve26
1 files changed, 25 insertions, 1 deletions
diff --git a/bin/ipns-resolve b/bin/ipns-resolve
index 7f7478c..6ea3799 100755
--- a/bin/ipns-resolve
+++ b/bin/ipns-resolve
@@ -1,3 +1,27 @@
#!/bin/bash
-ipfs name resolve $1 | sed -e 's/\/ipfs\///'
+PROGRAM="$(basename $0)"
+usage(){
+ echo "$PROGRAM - Resolves IPNS to IPFS"
+ echo "------------------------------------"
+ echo "Usage:"
+ echo " $PROGRAM <IPNS>"
+ echo ""
+ echo "Returns the resolved IPFS CIDv0"
+}
+logit(){
+ logthis "<$PROGRAM>" "$1" "$2"
+}
+if [ ! -z $1 ]
+then
+ rsld=$(ipfs name resolve $1)
+ if [ "$?" != 0 ]
+ then
+ logit "[ERROR]" "Failed to resolve $1"
+ exit 1
+ fi
+ echo -n $rsld | sed -e 's/\/ipfs\///'
+ logit "[INFO]" "Resolved $1 to $rsld"
+else
+ usage
+fi