2019-06-23 22:05:07 +02:00
|
|
|
#!/bin/bash
|
2019-06-24 15:15:41 +02:00
|
|
|
# Print some basic info about fediverse instances.
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-16 17:12:59 +02:00
|
|
|
# Version: 2019-07-16_2
|
2019-06-23 22:26:14 +02:00
|
|
|
|
2019-06-24 15:15:41 +02:00
|
|
|
if [[ -z "${1}" ]]; then
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "usage: ${0} DOMAIN" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-06-24 15:15:41 +02:00
|
|
|
if ! command -v jq > /dev/null; then
|
|
|
|
echo "You need to install jq (https://stedolan.github.com/jq/)" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2019-06-23 22:05:07 +02:00
|
|
|
function striphtml()
|
|
|
|
{
|
2019-06-23 22:13:42 +02:00
|
|
|
local extract="${*}"
|
2019-07-08 02:45:22 +02:00
|
|
|
echo "${extract}" | sed 's/\\u003c/</g' | sed 's/\\u003e/>/g' | sed -E 's/<[^>]+>//g' | sed 's/\\r\\n/ /g' | sed -E 's/(^"|"$)//g'
|
2019-06-23 22:05:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
local instance="${1}"
|
2019-06-24 15:15:41 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-07-12 21:23:39 +02:00
|
|
|
local nodeinfo=$(curl -sL "https://${instance}/.well-known/nodeinfo" | jq -r '.links[-1].href' 2> /dev/null)
|
2019-06-23 22:05:07 +02:00
|
|
|
local mastoinfo="https://${instance}/api/v1/instance"
|
2019-06-24 00:14:15 +02:00
|
|
|
local misskeyinfo="https://${instance}/api/meta"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-12 21:23:39 +02:00
|
|
|
if curl -sILf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-06-24 15:15:41 +02:00
|
|
|
echo "Misskey API found."
|
|
|
|
json=$(curl -s -X POST "${misskeyinfo}")
|
|
|
|
|
2019-06-25 02:27:07 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local version=$(jq -r ".version" <<<"${json}")
|
|
|
|
echo "Misskey ${version} detected."
|
|
|
|
|
2019-06-24 15:15:41 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-06-24 17:07:36 +02:00
|
|
|
local email=$(jq -r ".maintainerEmail" <<<"${json}")
|
2019-06-24 15:15:41 +02:00
|
|
|
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
|
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
2019-06-24 17:07:36 +02:00
|
|
|
local users=$(curl -s -X POST "https://${instance}/api/stats" | jq -r ".usersCount")
|
2019-06-24 15:15:41 +02:00
|
|
|
[[ -n ${users} ]] && echo "Number of users: ${users}"
|
|
|
|
|
2019-07-15 15:55:09 +02:00
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".features.registration" <<<"${json}"
|
2019-06-24 15:15:41 +02:00
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
2019-06-24 17:07:36 +02:00
|
|
|
local tos=$(jq -r ".ToSUrl" <<<"${json}")
|
2019-06-24 15:15:41 +02:00
|
|
|
[[ -n "${tos}" ]] && echo "ToS: ${tos}"
|
2019-07-12 21:23:39 +02:00
|
|
|
elif curl -sILf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "Nodeinfo found."
|
2019-06-23 22:13:42 +02:00
|
|
|
json=$(curl -s "${nodeinfo}")
|
2019-06-25 02:27:07 +02:00
|
|
|
|
2019-06-24 20:13:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local implementation=$(jq -r ".software.name" <<<"${json}")
|
2019-06-25 02:27:07 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local version=$(jq -r ".software.version" <<<"${json}")
|
|
|
|
echo "${implementation} ${version} detected."
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-06-24 20:13:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local description=$(jq -r ".metadata.nodeDescription" <<<"${json}")
|
2019-06-25 02:19:15 +02:00
|
|
|
if [[ "${description}" == "null" ]]; then
|
|
|
|
description=$(jq -r ".metadata.shortDescription" <<<"${json}")
|
|
|
|
fi
|
2019-06-24 20:13:29 +02:00
|
|
|
if [[ "${description}" == "null" ]]; then
|
|
|
|
description=$(jq -r ".metadata.nodeName" <<<"${json}")
|
|
|
|
fi
|
|
|
|
[[ "${description}" != "null" ]] && echo "Description: ${description}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-06-24 20:13:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local admins=$(jq -r ".metadata.staffAccounts" <<<"${json}")
|
2019-06-25 02:42:45 +02:00
|
|
|
if [[ "${admins}" == "null" ]]; then
|
|
|
|
admins=$(jq -r ".metadata.adminAccount" <<<"${json}")
|
|
|
|
fi
|
2019-06-24 20:13:29 +02:00
|
|
|
[[ "${admins}" != "null" ]] && echo "Admins: ${admins}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
|
|
|
echo -n "Number of users: "
|
2019-06-24 17:07:36 +02:00
|
|
|
jq -r ".usage.users.total" <<<"${json}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-16 01:14:31 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local active=$(jq -r ".usage.users.activeMonth" <<<"${json}")
|
|
|
|
[[ "${active}" != "null" ]] && echo "Active user (month): ${active}"
|
|
|
|
|
2019-07-15 15:55:09 +02:00
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".openRegistrations" <<<"${json}"
|
|
|
|
|
2019-06-24 20:13:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local restrictions=$(jq -r ".metadata.federation.mrf_simple" <<<"${json}")
|
|
|
|
[[ "${restrictions}" != "null" ]] && echo "Federation restrictions: ${restrictions}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-06-24 20:13:29 +02:00
|
|
|
if [[ "${implementation}" == "pleroma" ]]; then
|
2019-06-24 17:16:49 +02:00
|
|
|
echo "Further info, maybe: https://${instance}/about"
|
2019-06-25 02:19:15 +02:00
|
|
|
elif [[ "${implementation}" == "funkwhale" ]]; then
|
|
|
|
echo -n "Artists / tracks: "
|
|
|
|
jq -rj ".metadata.library.artists.total" <<<"${json}"
|
|
|
|
echo -n " / "
|
|
|
|
jq -r ".metadata.library.tracks.total" <<<"${json}"
|
2019-07-04 21:10:26 +02:00
|
|
|
elif [[ "${implementation}" == "mastodon" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about/more"
|
2019-07-16 01:14:31 +02:00
|
|
|
elif [[ "${implementation}" == "pixelfed" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/site/terms"
|
2019-07-16 17:12:59 +02:00
|
|
|
elif [[ "${implementation}" == "peertube" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about/instance"
|
2019-06-23 22:05:07 +02:00
|
|
|
fi
|
2019-07-12 21:23:39 +02:00
|
|
|
elif curl -sILf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "Mastodon API found."
|
2019-06-23 22:13:42 +02:00
|
|
|
json=$(curl -s "${mastoinfo}")
|
2019-06-23 22:05:07 +02:00
|
|
|
local implementation=""
|
|
|
|
|
2019-06-24 02:44:10 +02:00
|
|
|
if grep -Eq '"is_(pro|verified)"' <<<"${json}"; then
|
2019-06-23 22:05:07 +02:00
|
|
|
implementation="Gab"
|
2019-06-24 17:11:42 +02:00
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\."' <<<"${json}"; then
|
|
|
|
implementation="Florence"
|
2019-06-23 22:05:07 +02:00
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9]+"' <<<"${json}"; then
|
|
|
|
implementation="Mastodon"
|
2019-07-15 17:19:25 +02:00
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9][\._\-]?[a-zA-Z]+"' <<<"${json}"; then
|
2019-06-30 01:58:45 +02:00
|
|
|
implementation="Mastodon fork"
|
2019-06-23 22:05:07 +02:00
|
|
|
fi
|
2019-06-25 02:27:07 +02:00
|
|
|
if [[ -n "${implementation}" ]]; then
|
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local version=$(jq -r ".version" <<<"${json}")
|
|
|
|
echo "${implementation} ${version} detected."
|
|
|
|
fi
|
2019-06-23 22:05:07 +02:00
|
|
|
|
|
|
|
echo -n "Description: "
|
2019-06-23 22:13:42 +02:00
|
|
|
# shellcheck disable=SC2046
|
2019-06-30 01:50:58 +02:00
|
|
|
striphtml $(jq ".description" <<<"${json}")
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-06-23 22:13:42 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-06-24 17:07:36 +02:00
|
|
|
local admin=$(jq -r ".contact_account.acct" <<<"${json}")
|
2019-06-23 22:42:09 +02:00
|
|
|
[[ -n "${admin}" ]] && echo "Admin: https://${instance}/users/${admin}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-06-23 22:13:42 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-06-24 17:07:36 +02:00
|
|
|
local email=$(jq -r ".email" <<<"${json}")
|
2019-06-23 22:05:07 +02:00
|
|
|
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
|
|
|
|
|
|
|
|
echo -n "Number of users: "
|
2019-06-24 17:07:36 +02:00
|
|
|
jq -r ".stats.user_count" <<<"${json}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-15 15:55:09 +02:00
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".registrations" <<<"${json}"
|
|
|
|
|
2019-06-24 17:07:36 +02:00
|
|
|
if [[ "${implementation}" == "Mastodon"
|
2019-06-30 01:58:45 +02:00
|
|
|
|| "${implementation}" == "Mastodon fork"
|
2019-07-08 02:31:43 +02:00
|
|
|
|| "${implementation}" == "Florence" ]]; then
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "Further info, maybe: https://${instance}/about/more"
|
2019-07-08 02:31:43 +02:00
|
|
|
elif [[ "${implementation}" == "Gab" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about"
|
2019-06-23 22:05:07 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Could not detect type of server."
|
|
|
|
curl -I "https://${instance}/"
|
|
|
|
fi
|
|
|
|
|
2019-07-12 21:23:39 +02:00
|
|
|
if curl -sILf "${instance}" | grep -q 'Server: cloudflare'; then
|
|
|
|
echo "Uses CloudFlare."
|
|
|
|
fi
|
|
|
|
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "See also: https://fediverse.network/${instance}"
|
|
|
|
}
|
|
|
|
|
|
|
|
main "${1}"
|