find_fsd_pages.sh 767 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. readonly WIKI_BASE_URL=https://directory.fsf.org/wiki
  3. readonly BLACKLIST_URL=https://git.parabola.nu/blacklist.git/plain
  4. readonly BLACKLIST_FILE=blacklist.txt
  5. wget $BLACKLIST_URL/$BLACKLIST_FILE
  6. [ ! -f ./$BLACKLIST_FILE ] && echo "download failed" && exit 1
  7. readonly PACKAGES=$(grep '^\s*[^:#]*:.*' ./$BLACKLIST_FILE | \
  8. sed 's/^\s*\([^:#]*\):.*/\1/ ; s/^./\U&/g ; s/-./\U&/g ; s/-/_/g')
  9. for package in $PACKAGES
  10. do status=$(curl -s -o /dev/null -w "%{http_code}" $WIKI_BASE_URL/$package)
  11. if [ "$status" == '200' ]
  12. then echo "$package entry exists"
  13. elif [ "$status" == '404' -o "$status" == '301' ]
  14. then echo "$package entry not found"
  15. else echo "$package unknown response"
  16. fi
  17. done