-
-
Save allex/12011d02da2e8b605a6cb715debb35f8 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 | |
# GistID: 12011d02da2e8b605a6cb715debb35f8 | |
# GistURL: https://gist.github.com/allex/12011d02da2e8b605a6cb715debb35f8 | |
LOGGER_TAG=v2ray-geodata-updater | |
log () { | |
echo "$@" | |
logger -t $LOGGER_TAG -- "$@" | |
} | |
download () { | |
url=$1 | |
name=${2:-${url##*/}} | |
log "> downloading $name..." | |
if ! curl -o /tmp/"$name" -sfL "$url" ; then | |
log "failed to download latest $name, not updating!" | |
else | |
mv /tmp/"$name" "$name" | |
log "$name updated" | |
fi | |
} | |
log "fetching geoip urls..." | |
curl -sL -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/geoip/releases/latest | \ | |
grep browser_download_url | \ | |
cut -d\" -f4 | \ | |
grep -e "\.dat$" | \ | |
while read -r url; do download "$url"; done | |
log "fetching geosite url..." | |
curl -sL -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/domain-list-community/releases/latest | \ | |
grep browser_download_url | \ | |
cut -d\" -f4 | \ | |
grep -e "\.dat$" | \ | |
while read -r url; do | |
name=${url##*/} | |
if [ "$name" = "dlc.dat" ]; then | |
name=geosite.dat | |
fi | |
download "$url" "$name" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/v2fly/v2ray-core/blob/master/.github/workflows/release.yml#L139