Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

Loading

@rogerBridge
Copy link

rogerBridge commented May 27, 2021

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

Loading

@maddie
Copy link
Author

maddie commented May 27, 2021

Loading

@rogerBridge
Copy link

rogerBridge commented May 27, 2021

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

Thanks a lot😀

Loading

@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

Loading

@amit-gshe
Copy link

amit-gshe commented Sep 10, 2021

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

Loading

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