123456789101112131415161718192021222324252627282930313233343536 |
- #!/bin/bash
- # Set the URL of the RSS feed
- feed_url="http://demo.fedilist.com/instance/newest/rss"
- # Set the interval for checking for updates (in seconds)
- interval=600
- # Initialize last_update variable
- last_update=""
- while true; do
- # Get dates of last updated sites from the feed
- feed=$(curl -Ls "$feed_url")
- update_dates=$(echo "$feed" | xmlstarlet sel -t -v "/rss/channel/item/pubDate" | awk -v date="$last_update" '{ if ($0 == date) exit; print }')
- if [ -n "$update_dates" ]; then
- # Update the date of the last check
- last_update=$(echo "$update_dates" | head -1)
- # Get total count of last updated sites
- update_count=$(echo "$update_dates" | wc -l)
- # Parse the feed and get the link of the entries
- urls=$(echo "$feed" | xmlstarlet sel -t -v "/rss/channel/item/title" | head -n "$update_count" | 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
|