Last active
November 1, 2023 16:10
-
-
Save maddie/e298debf8ab0e86a92bafe2633fc84dd to your computer and use it in GitHub Desktop.
Script for updating V2Ray geoip.dat and geosite.dat on OpenWRT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
Thanks