From Kromonos, 3 Months ago, written in Bash.
Embed
  1. #!/bin/bash
  2. MAILTO=hab@ich.net
  3. LIST=/etc/nginx/tor-ips.conf
  4.  
  5. wget -qO- https://check.torproject.org/exit-addresses | grep ExitAddress | cut -d ' ' -f 2 | sed "s/^/allow /g; s/$/;/g" > /tmp/tor.nodes
  6. diff $LIST /tmp/tor.nodes > /dev/null
  7. if [ $? -eq 0 ] || [ $? -eq 2 ] ; then
  8.   exit
  9. fi
  10.  
  11. mv /tmp/tor.nodes $LIST
  12. /sbin/nginx -t
  13. if [ $? -ne 0 ]; then
  14.   echo "Error reloading new tor ip list" | mail -s "[ERROR] Tor ip list" $MAILTO
  15. else
  16.   /bin/systemctl reload nginx
  17. fi