From bd36d58fadcf377a7982103ca4d7e5c4376ef463 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 5 Aug 2023 15:52:13 +0200 Subject: [PATCH] Continued: - throw exception again, if they happen then they won't be fixed within a split of a second - also make sure that home directory of FBA is properly set, sure you can choose a different directory or take the default /home/fba/ - added recheck.sh, a small wrapper script I wrote for myself and you should try. For example above exceptions might cause the used software not being detected (sure with timeouts) then you can run ./recheck.sh --software to re-test them --- README.md => docs/README.md | 2 +- fba/http/nodeinfo.py | 5 +++- recheck.sh | 51 +++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) rename README.md => docs/README.md (94%) create mode 100755 recheck.sh diff --git a/README.md b/docs/README.md similarity index 94% rename from README.md rename to docs/README.md index db37a0e..8c08479 100644 --- a/README.md +++ b/docs/README.md @@ -9,7 +9,7 @@ Used to see which instances block yours. ## Installation ```bash -sudo useradd -m fba +sudo useradd --home-dir=/opt/fedi-block-api --comment "Fedi Block API" --user-group --create-home fba sudo mkdir -p /opt/fedi-block-api sudo chown -R fba:fba /opt/fedi-block-api sudo -Hu fba git clone git://git.mxchange.org/fba.git /opt/fedi-block-api/ diff --git a/fba/http/nodeinfo.py b/fba/http/nodeinfo.py index 7d7620a..ec78862 100644 --- a/fba/http/nodeinfo.py +++ b/fba/http/nodeinfo.py @@ -42,7 +42,10 @@ def fetch_nodeinfo(domain: str, path: str = None) -> dict: data = fetch_wellknown_nodeinfo(domain) logger.debug("data[%s](%d)='%s'", type(data), len(data), data) - if "error_message" not in data and "json" in data and len(data["json"]) > 0: + if "exception" in data: + logger.warning("Exception returned: '%s', raising again ...", type(data["exception"])) + raise data["exception"] + elif "error_message" not in data and "json" in data and len(data["json"]) > 0: logger.debug("Invoking instances.set_last_nodeinfo(%s) ...", domain) instances.set_last_nodeinfo(domain) diff --git a/recheck.sh b/recheck.sh new file mode 100755 index 0000000..e685ca7 --- /dev/null +++ b/recheck.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +MODE="" +if [ "$1" = "--help" ] +then + echo "Usage: $ [file|--software|--nodeinfo|--detection|--no-auto]" + exit 255 +elif [ -n "$1" -a -f "$1" ] +then + DOMAINS=$(cat "$1") + MODE="file" +elif [ "$1" = "--software" ] +then + DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL ORDER BY last_updated ASC;") + MODE="software" +elif [ "$1" = "--nodeinfo" ] +then + DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") + MODE="nodeinfo" +elif [ "$1" = "--detection" ] +then + DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode IS NULL ORDER BY last_updated ASC;") + MODE="detection" +elif [ "$1" = "--no-auto" ] +then + DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC;") + MODE="noauto" +else + DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") +fi + +if [ -z "${DOMAINS}" ] +then + echo "$0: No domains found! MODE='${MODE}'" + exit 255 +fi + +for DOMAIN in ${DOMAINS}; +do + echo "$0: DOMAIN='${DOMAIN}'" + if [ -n "$1" -a -z "${MODE}" ] + then + ./fba.py update_nodeinfo --domain=${DOMAIN} "$1" + elif [ -n "$2" ] + then + ./fba.py update_nodeinfo --domain=${DOMAIN} "$2" + else + ./fba.py update_nodeinfo --domain=${DOMAIN} + fi +done +echo "$0: All done." -- 2.39.5