💾 Archived View for alpha.lyk.so › systems › gemini › scripts › update-tinylog-subscriptions.sh captured on 2021-11-30 at 20:18:30.

View Raw

More Information

-=-=-=-=-=-=-

#!/usr/bin/env sh

set -e

cd ~/.config/gtl

temp="$(mktemp -d)"
trap 'rm -fr "$temp"' EXIT INT HUP

# Ensure subs file is sorted
cat subs | sort > "$temp/sorted"
mv "$temp/sorted" subs

# Ensure a "blocked" file exists
touch blocked

curl -s https://codeberg.org/bacardi55/gemini-tinylog-rfc/raw/branch/main/Known-tinylogs.md \
| grep "* gemini://" \
| sed "s/^\* //g" \
| sort \
> "$temp/known"

comm -13 blocked "$temp/known" > "$temp/new-subs-file"
comm -13 subs "$temp/new-subs-file" > "$temp/new-logs"

if [ "$(cat "$temp/new-logs")" != "" ]; then
  echo "Subscribing to:"
  cat "$temp/new-logs"
else
  echo "No new tinylogs."
fi

mv "$temp/new-subs-file" subs