instanceinfo.sh: added Misskey-support.

This commit is contained in:
tastytea 2019-06-24 00:14:15 +02:00
parent 58e22e8133
commit 9f705a2c3d
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07

View File

@ -2,7 +2,7 @@
# Print some basic info about fediverse instances. Install json_pp for prettier
# output.
# Version: 2019-06-23_2
# Version: 2019-06-24_1
if [ -z "${1}" ]; then
echo "usage: ${0} DOMAIN" >&2
@ -30,8 +30,9 @@ function main()
local instance="${1}"
local nodeinfo="https://${instance}/nodeinfo/2.0.json"
local mastoinfo="https://${instance}/api/v1/instance"
local misskeyinfo="https://${instance}/api/meta"
if curl -sIf "${nodeinfo}" | grep -q '200 OK'; then
if curl -sIf "${nodeinfo}" | grep -q 'Content-Type: application/json'; then
echo "Nodeinfo found."
json=$(curl -s "${nodeinfo}")
local implementation=""
@ -88,6 +89,27 @@ function main()
if [[ "${implementation}" == "Mastodon" ]]; then
echo "Further info, maybe: https://${instance}/about/more"
fi
elif curl -sIf -X POST "${misskeyinfo}" | grep -q 'Content-Type: application/json'; then
echo "Misskey API found."
json=$(curl -s -X POST "${misskeyinfo}")
# shellcheck disable=SC2155
local email=$(grep -Eo '"maintainerEmail":"[^"]+"' <<<"${json}" | cut -d: -f2 | sed 's/"//g')
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
# shellcheck disable=SC2155
local users=$(curl -s -X POST "https://${instance}/api/stats" | grep -Eo '"usersCount":[0-9]+' | cut -d: -f2)
[[ -n ${users} ]] && echo "Number of users: ${users}"
# NOTE: I'm not sure what the returned data means exactly and I couldn't find the API-documentation. So I commented it out for now.
# # shellcheck disable=SC2155
# local federation=$(curl -s -X POST "https://${instance}/api/federation/instances" | grep -Eo '"host":"[^"]+",' | sed 's/"host"://g')
# # shellcheck disable=SC2046
# [[ -n ${federation} ]] && echo -n "Federates with: " && pretty '"":['"${federation}"'""]'
# shellcheck disable=SC2155
local tos=$(grep -Eo '"ToSUrl":"[^"]+"' <<<"${json}" | cut -d: -f2,3 | sed 's/"//g')
[[ -n "${tos}" ]] && echo "ToS: ${tos}"
else
echo "Could not detect type of server."
curl -I "https://${instance}/"