geoip-geosite-with-ru-block.../update.sh

15 lines
823 B
Bash
Raw Permalink Normal View History

2023-11-11 22:34:30 +03:00
#!/bin/bash
set -euxo pipefail;
2023-11-29 13:49:36 +03:00
cd "$(dirname "$0")"
2023-11-11 22:34:30 +03:00
current=`curl 'https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/releases/latest'`
geoipUrl=`echo "$current" | jq -r '.assets | map( { (.name|tostring): . } ) | add | ."geoip.dat".browser_download_url'`
geositeUrl=`echo "$current" | jq -r '.assets | map( { (.name|tostring): . } ) | add | ."geosite.dat".browser_download_url'`
[ -f geoip.dat ] && mv geoip.dat geoip.dat.bak
[ -f geosite.dat ] && mv geosite.dat geosite.dat.bak
curl -fsSL "$geoipUrl" -o geoip.dat
curl -fsSL "$geositeUrl" -o geosite.dat
[ -f geoip.dat ] && [ -f geoip.dat.bak ] && rm geoip.dat.bak
[ -f geosite.dat ] && [ -f geosite.dat.bak ] && rm geosite.dat.bak
[ ! -f geoip.dat ] && mv geoip.dat.bak geoip.dat
[ ! -f geosite.dat ] && mv geosite.dat.bak geosite.dat