فهرست منبع

Add update_fbadb_{1,2}.sh

poesty 1 سال پیش
والد
کامیت
e29b1b99c1
2فایلهای تغییر یافته به همراه60 افزوده شده و 0 حذف شده
  1. 30 0
      update/update_fbadb_1.sh
  2. 30 0
      update/update_fbadb_2.sh

+ 30 - 0
update/update_fbadb_1.sh

@@ -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
+

+ 30 - 0
update/update_fbadb_2.sh

@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Set the URL of the Atom feed
+feed_url="http://demo.fedilist.com/instance/newest/rss"
+
+# 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" | xmlstarlet sel -t -v "/rss/channel/item[1]/pubDate")
+
+    # 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 -t -v "/rss/channel/item/title" | awk '{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
+