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-21 05:02:34 +02:00
|
|
|
# Version: 2019-07-21_1
|
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-07-18 18:36:35 +02:00
|
|
|
if ! command -v curl > /dev/null; then
|
|
|
|
echo "You need to install curl (https://curl.haxx.se/)" >&2
|
|
|
|
exit 2
|
|
|
|
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-07-18 18:36:35 +02:00
|
|
|
mycurl="curl -sk"
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
function parse_nodeinfo()
|
2019-06-23 22:05:07 +02:00
|
|
|
{
|
|
|
|
local instance="${1}"
|
2019-07-18 18:15:46 +02:00
|
|
|
local nodeinfo="${2}"
|
2019-07-18 18:36:35 +02:00
|
|
|
json=$(${mycurl} "${nodeinfo}")
|
2019-07-18 18:15:46 +02:00
|
|
|
|
2019-06-24 15:15:41 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-07-18 18:15:46 +02:00
|
|
|
local implementation=$(jq -r ".software.name" <<<"${json}")
|
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local version=$(jq -r ".software.version" <<<"${json}")
|
|
|
|
echo "${implementation} ${version} detected."
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local description=$(jq -r ".metadata.nodeDescription" <<<"${json}")
|
|
|
|
if [[ "${description}" == "null" ]]; then
|
|
|
|
description=$(jq -r ".metadata.shortDescription" <<<"${json}")
|
|
|
|
fi
|
|
|
|
if [[ "${description}" == "null" ]]; then
|
|
|
|
description=$(jq -r ".metadata.nodeName" <<<"${json}")
|
|
|
|
fi
|
|
|
|
[[ "${description}" != "null" ]] && echo "Description: ${description}"
|
2019-06-24 15:15:41 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local admins=$(jq -r ".metadata.staffAccounts" <<<"${json}")
|
|
|
|
if [[ "${admins}" == "null" ]]; then
|
|
|
|
admins=$(jq -r ".metadata.adminAccount" <<<"${json}")
|
|
|
|
fi
|
|
|
|
[[ "${admins}" != "null" ]] && echo "Admins: ${admins}"
|
2019-06-25 02:27:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
echo -n "Number of users: "
|
|
|
|
jq -r ".usage.users.total" <<<"${json}"
|
2019-06-24 15:15:41 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local active=$(jq -r ".usage.users.activeMonth" <<<"${json}")
|
|
|
|
[[ "${active}" != "null" ]] && echo "Active user (month): ${active}"
|
2019-06-24 15:15:41 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".openRegistrations" <<<"${json}"
|
2019-06-24 15:15:41 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local restrictions=$(jq -r ".metadata.federation.mrf_simple" <<<"${json}")
|
|
|
|
[[ "${restrictions}" != "null" ]] && echo "Federation restrictions: ${restrictions}"
|
|
|
|
|
|
|
|
if [[ "${implementation}" == "pleroma" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about"
|
|
|
|
elif [[ "${implementation}" == "funkwhale" ]]; then
|
|
|
|
echo -n "Artists / tracks: "
|
|
|
|
jq -rj ".metadata.library.artists.total" <<<"${json}"
|
|
|
|
echo -n " / "
|
|
|
|
jq -r ".metadata.library.tracks.total" <<<"${json}"
|
|
|
|
elif [[ "${implementation}" == "mastodon" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about/more"
|
|
|
|
elif [[ "${implementation}" == "pixelfed" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/site/terms"
|
|
|
|
elif [[ "${implementation}" == "peertube" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about/instance"
|
|
|
|
fi
|
|
|
|
}
|
2019-06-25 02:27:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
function parse_mastodon()
|
|
|
|
{
|
|
|
|
local instance="${1}"
|
|
|
|
local mastoinfo="${2}"
|
2019-07-18 18:36:35 +02:00
|
|
|
json=$(${mycurl} "${mastoinfo}")
|
2019-07-18 18:15:46 +02:00
|
|
|
local implementation=""
|
|
|
|
|
|
|
|
if grep -Eq '"is_(pro|verified)"' <<<"${json}"; then
|
|
|
|
implementation="Gab"
|
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\."' <<<"${json}"; then
|
|
|
|
implementation="Florence"
|
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9]+"' <<<"${json}"; then
|
|
|
|
implementation="Mastodon"
|
2019-07-21 05:02:34 +02:00
|
|
|
elif grep -Eq '"version":"[0-9]+\.[0-9]+\.[0-9][\._\-\+]?[a-zA-Z0-9]+"' <<<"${json}"; then
|
2019-07-18 18:15:46 +02:00
|
|
|
implementation="Mastodon fork"
|
|
|
|
fi
|
|
|
|
if [[ -n "${implementation}" ]]; then
|
2019-06-24 20:13:29 +02:00
|
|
|
# shellcheck disable=SC2155
|
2019-07-18 18:15:46 +02:00
|
|
|
local version=$(jq -r ".version" <<<"${json}")
|
2019-06-25 02:27:07 +02:00
|
|
|
echo "${implementation} ${version} detected."
|
2019-07-18 18:15:46 +02:00
|
|
|
fi
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
echo -n "Description: "
|
|
|
|
# shellcheck disable=SC2046
|
|
|
|
striphtml $(jq ".description" <<<"${json}")
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local admin=$(jq -r ".contact_account.acct" <<<"${json}")
|
|
|
|
[[ -n "${admin}" ]] && echo "Admin: https://${instance}/users/${admin}"
|
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local email=$(jq -r ".email" <<<"${json}")
|
|
|
|
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
echo -n "Number of users: "
|
|
|
|
jq -r ".stats.user_count" <<<"${json}"
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".registrations" <<<"${json}"
|
2019-07-16 01:14:31 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
if [[ "${implementation}" == "Mastodon"
|
|
|
|
|| "${implementation}" == "Mastodon fork"
|
|
|
|
|| "${implementation}" == "Florence" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about/more"
|
|
|
|
elif [[ "${implementation}" == "Gab" ]]; then
|
|
|
|
echo "Further info, maybe: https://${instance}/about"
|
|
|
|
fi
|
|
|
|
}
|
2019-07-15 15:55:09 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
function parse_misskey()
|
|
|
|
{
|
|
|
|
local instance="${1}"
|
|
|
|
local misskeyinfo="${2}"
|
2019-07-18 18:36:35 +02:00
|
|
|
json=$(${mycurl} -X POST "${misskeyinfo}")
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local version=$(jq -r ".version" <<<"${json}")
|
|
|
|
echo "Misskey ${version} detected."
|
2019-06-23 22:05:07 +02:00
|
|
|
|
2019-07-18 18:15:46 +02:00
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local email=$(jq -r ".maintainerEmail" <<<"${json}")
|
|
|
|
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
|
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
2019-07-18 18:36:35 +02:00
|
|
|
local users=$(${mycurl} -X POST "https://${instance}/api/stats" | jq -r ".usersCount")
|
2019-07-18 18:15:46 +02:00
|
|
|
[[ -n ${users} ]] && echo "Number of users: ${users}"
|
|
|
|
|
|
|
|
echo -n "Open registrations: "
|
|
|
|
jq -r ".features.registration" <<<"${json}"
|
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
|
|
|
local tos=$(jq -r ".ToSUrl" <<<"${json}")
|
|
|
|
[[ -n "${tos}" ]] && echo "ToS: ${tos}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
local instance="${1}"
|
|
|
|
# shellcheck disable=SC2155
|
2019-07-18 18:36:35 +02:00
|
|
|
local nodeinfo=$(${mycurl} -L "https://${instance}/.well-known/nodeinfo" | jq -r '.links[-1].href' 2> /dev/null)
|
2019-07-18 18:15:46 +02:00
|
|
|
local mastoinfo="https://${instance}/api/v1/instance"
|
|
|
|
local misskeyinfo="https://${instance}/api/meta"
|
|
|
|
|
2019-07-18 18:36:35 +02:00
|
|
|
if ${mycurl} -ILf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-07-18 18:15:46 +02:00
|
|
|
echo "Misskey API found."
|
|
|
|
parse_misskey "${instance}" "${misskeyinfo}"
|
2019-07-18 18:36:35 +02:00
|
|
|
elif ${mycurl} -ILf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-07-18 18:15:46 +02:00
|
|
|
echo "Nodeinfo found."
|
|
|
|
parse_nodeinfo "${instance}" "${nodeinfo}"
|
2019-07-18 18:36:35 +02:00
|
|
|
elif ${mycurl} -ILf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then
|
2019-07-18 18:15:46 +02:00
|
|
|
echo "Mastodon API found."
|
|
|
|
parse_mastodon "${instance}" "${mastoinfo}"
|
2019-06-23 22:05:07 +02:00
|
|
|
else
|
|
|
|
echo "Could not detect type of server."
|
2019-07-18 18:36:35 +02:00
|
|
|
${mycurl} -I "https://${instance}/"
|
2019-06-23 22:05:07 +02:00
|
|
|
fi
|
|
|
|
|
2019-07-18 18:36:35 +02:00
|
|
|
if ${mycurl} -ILf "${instance}" | grep -q 'Server: cloudflare'; then
|
2019-07-12 21:23:39 +02:00
|
|
|
echo "Uses CloudFlare."
|
|
|
|
fi
|
|
|
|
|
2019-06-23 22:05:07 +02:00
|
|
|
echo "See also: https://fediverse.network/${instance}"
|
|
|
|
}
|
|
|
|
|
|
|
|
main "${1}"
|