]> git.mxchange.org Git - fba.git/blob - nodeinfo.sh
Continued:
[fba.git] / nodeinfo.sh
1 #!/bin/sh
2
3 MODE=""
4 if [ "$1" = "--help" ]
5 then
6         echo "Usage: $0 [file|--software|--software2|--nodeinfo|--generator|--detection|--no-auto|--no-auto2|--timeout]"
7         exit 255
8 elif [ -n "$1" -a -f "$1" ]
9 then
10         DOMAINS=$(cat "$1")
11         MODE="file"
12 elif [ "$1" = "--software" ]
13 then
14         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL ORDER BY last_updated ASC;")
15         MODE="software"
16 elif [ "$1" = "--nodeinfo" ]
17 then
18         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;")
19         MODE="nodeinfo"
20 elif [ "$1" = "--detection" ]
21 then
22         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode IS NULL ORDER BY last_updated ASC;")
23         MODE="detection"
24 elif [ "$1" = "--no-auto" ]
25 then
26         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC;")
27         MODE="noauto"
28 elif [ "$1" = "--no-auto2" ]
29 then
30         DOMAINS=`sqlite3 blocks.db "SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey', 'mammuthus') AND detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC;"`
31         MODE="noauto2"
32 elif [ "$1" = "--timeout" ]
33 then
34         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE last_error_details LIKE '%Timeout%' ORDER BY last_updated ASC;")
35         MODE="software"
36 elif [ "$1" = "--software2" ]
37 then
38         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NOT NULL AND detection_mode IS NULL ORDER BY last_updated ASC;")
39         MODE="software2"
40 elif [ "$1" = "--generator" ]
41 then
42         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode='GENERATOR' ORDER BY last_updated ASC;")
43         MODE="generator"
44 else
45         DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;")
46 fi
47
48 if [ -z "${DOMAINS}" ]
49 then
50         echo "$0: No domains found! MODE='${MODE}'"
51         exit 255
52 fi
53
54 for DOMAIN in ${DOMAINS};
55 do
56         echo "$0: DOMAIN='${DOMAIN}'"
57         if [ -n "$1" -a -z "${MODE}" ]
58         then
59                 ./fba.py update_nodeinfo --domain=${DOMAIN} "$1"
60         elif [ -n "$2" ]
61         then
62                 ./fba.py update_nodeinfo --domain=${DOMAIN} "$2"
63         else
64                 ./fba.py update_nodeinfo --domain=${DOMAIN}
65         fi
66 done
67 echo "$0: All done."