Skip to content

Instantly share code, notes, and snippets.

@hisune
Forked from maddie/update-v2ray-geo.sh
Created June 5, 2020 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisune/9e58e4f6b9da902065d783ebf29a649d to your computer and use it in GitHub Desktop.
Save hisune/9e58e4f6b9da902065d783ebf29a649d 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment