aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-node-info
blob: 1b1279825b2c229ff6ceb6755c1d28be2039f553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_ipfs
# 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