From 9a7b53fc23bb07cfcbcee0f008b72c22da5834d3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 30 Sep 2019 01:53:53 +0200 Subject: [PATCH] instanceinfo.sh: Use Mastodon API additionally for Mastodon. The nodeinfo on Mastodon instances is rather sparse at the moment. --- instanceinfo.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/instanceinfo.sh b/instanceinfo.sh index 3d2fb4f..31cd147 100755 --- a/instanceinfo.sh +++ b/instanceinfo.sh @@ -1,7 +1,7 @@ #!/bin/bash # Print some basic info about fediverse instances. -# Version: 2019-07-27_3 +# Version: 2019-09-30_1 if [[ -z "${1}" ]]; then echo "usage: ${0} DOMAIN" >&2 @@ -30,10 +30,12 @@ function parse_nodeinfo() { local instance="${1}" local nodeinfo="${2}" - json=$(${mycurl} "${nodeinfo}") + # shellcheck disable=SC2155 + local json=$(${mycurl} "${nodeinfo}") # shellcheck disable=SC2155 local implementation=$(jq -r ".software.name" <<<"${json}") + # shellcheck disable=SC2155 local version=$(jq -r ".software.version" <<<"${json}") echo "${implementation} ${version} detected." @@ -86,7 +88,10 @@ function parse_nodeinfo() echo -n " / " jq -r ".metadata.library.tracks.total" <<<"${json}" elif [[ "${implementation}" == "mastodon" ]]; then - echo "Further info, maybe: https://${instance}/about/more" + if [[ "${implementation}" == "mastodon" ]]; then + echo -e "\nUsing Mastodon API additionally." + parse_mastodon instance "https://${instance}/api/v1/instance" + fi elif [[ "${implementation}" == "pixelfed" ]]; then echo "Further info, maybe: https://${instance}/site/terms" elif [[ "${implementation}" == "peertube" ]]; then @@ -98,7 +103,8 @@ function parse_mastodon() { local instance="${1}" local mastoinfo="${2}" - json=$(${mycurl} "${mastoinfo}") + # shellcheck disable=SC2155 + local json=$(${mycurl} "${mastoinfo}") local implementation="" if grep -Eq '"is_(pro|verified)"' <<<"${json}"; then @@ -147,7 +153,8 @@ function parse_misskey() { local instance="${1}" local misskeyinfo="${2}" - json=$(${mycurl} -X POST "${misskeyinfo}") + # shellcheck disable=SC2155 + local json=$(${mycurl} -X POST "${misskeyinfo}") # shellcheck disable=SC2155 local version=$(jq -r ".version" <<<"${json}")