update_geodb.sh 906 B

12345678910111213141516171819202122232425262728293031323334
  1. #/bin/bash
  2. cd ../mod/geodb
  3. # Delete the old csv files
  4. rm geoipv4.csv
  5. rm geoipv6.csv
  6. echo "Updating geodb csv files"
  7. echo "Downloading IPv4 database"
  8. curl -f https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country/geo-whois-asn-country-ipv4.csv -o geoipv4.csv
  9. if [ $? -ne 0 ]; then
  10. echo "Failed to download IPv4 database"
  11. failed=true
  12. else
  13. echo "Successfully downloaded IPv4 database"
  14. fi
  15. echo "Downloading IPv6 database"
  16. curl -f https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country/geo-whois-asn-country-ipv6.csv -o geoipv6.csv
  17. if [ $? -ne 0 ]; then
  18. echo "Failed to download IPv6 database"
  19. failed=true
  20. else
  21. echo "Successfully downloaded IPv6 database"
  22. fi
  23. if [ "$failed" = true ]; then
  24. echo "One or more downloads failed. Blocking exit..."
  25. while :; do
  26. read -p "Press [Ctrl+C] to exit..." input
  27. done
  28. fi