|
@@ -0,0 +1,30 @@
|
|
|
|
+#!/bin/bash
|
|
|
|
+
|
|
|
|
+# Set the URL of the Atom feed
|
|
|
|
+feed_url="https://fediverse.observer/new-servers.xml"
|
|
|
|
+
|
|
|
|
+# Set the interval for checking for updates (in seconds)
|
|
|
|
+interval=600
|
|
|
|
+
|
|
|
|
+while true; do
|
|
|
|
+ # Get the date of the last update from the feed
|
|
|
|
+ last_update=$(curl -Ls "$feed_url" | grep -oP -m 1 "(?<=<updated>)[^<]+")
|
|
|
|
+
|
|
|
|
+ # Compare the last update date with the date of the last check
|
|
|
|
+ if [ "$last_update" != "$last_check" ]; then
|
|
|
|
+ # Update the date of the last check
|
|
|
|
+ last_check="$last_update"
|
|
|
|
+
|
|
|
|
+ # Parse the feed and get the link of the first entry
|
|
|
|
+ urls=$(curl -Ls "$feed_url" | xmlstarlet sel -N atom=http://www.w3.org/2005/Atom -t -v "//atom:entry/atom:link/@href" | awk -F'/' '{print $NF}' | sort | uniq -c | sort -nr | awk '{print $2}')
|
|
|
|
+
|
|
|
|
+ for url in $urls; do
|
|
|
|
+ cd /opt/fedi-block-api && sudo -Hu fba python3 fetch_instances.py $url
|
|
|
|
+ done
|
|
|
|
+
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # Wait for the specified interval
|
|
|
|
+ sleep $interval
|
|
|
|
+done
|
|
|
|
+
|