Skip to content

Instantly share code, notes, and snippets.

@maddie
Last active November 1, 2023 16:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maddie/e298debf8ab0e86a92bafe2633fc84dd to your computer and use it in GitHub Desktop.
Save maddie/e298debf8ab0e86a92bafe2633fc84dd to your computer and use it in GitHub Desktop.
Script for updating V2Ray geoip.dat and geosite.dat on OpenWRT
#!/bin/sh
LOGGER_TAG=v2ray-geodata-updater
log () {
echo $@
logger -t $LOGGER_TAG "$@"
}
log "fetching geoip url..."
GEOIP_URL=$(curl -sL https://api.github.com/repos/v2ray/geoip/releases/latest | jq -r '.assets[].browser_download_url')
log "geoip url: $GEOIP_URL"
log "fetching geosite url..."
GEOSITE_URL=$(curl -sL https://api.github.com/repos/v2ray/domain-list-community/releases/latest | jq -r '.assets[].browser_download_url')
log "geosite url: $GEOSITE_URL"
GEOIP_PATH=/usr/bin/geoip.dat
GEOSITE_PATH=/usr/bin/geosite.dat
log "geoip.dat will be saved as $GEOIP_PATH"
log "geosite.dat will be saved as $GEOSITE_PATH"
log "downloading geoip.dat..."
curl -o /tmp/geoip.dat -sL $GEOIP_URL
if [ $? -ne 0 ]; then
log "failed to download latest geoip.dat, not updating!"
else
mv /tmp/geoip.dat $GEOIP_PATH
log "v2ray geoip.dat updated"
fi
log "downloading geosite.dat..."
curl -o /tmp/geosite.dat -sL $GEOSITE_URL
if [ $? -ne 0 ]; then
log "failed to download latest geosite.dat, not updating!"
else
mv /tmp/geosite.dat $GEOSITE_PATH
log "v2ray geosite.dat updated"
fi
@maddie
Copy link
Author

maddie commented Jul 18, 2019

You need to install curl, ca-certificates and jq to your router in order to get this to work

@rogerBridge
Copy link

Hello sir, do you know how to add domain to geodata.dat file? thank you

@maddie
Copy link
Author

maddie commented May 27, 2021

@rogerBridge
Copy link

You need to install curl, ca-certificates and jq to your router in order to get this to work

Thanks a lot😀

@Gherkashen2
Copy link

Gherkashen2 commented Jun 15, 2021

How Can I get scripts for openwrt to get latest update GeoIP.dat & GeoSite.dat automatically from this resource??? 👇

https://github.com/Loyalsoldier/v2ray-rules-dat/releases

because these rules are full complete for GeoIP: IR

@amit-gshe
Copy link

You can download the latest assets via an direct link: https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat

@AmirRajabii
Copy link

You need to install curl, ca-certificates and jq to your router in order to get this to work

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment