parent
043f391ffd
commit
3bacbce44a
|
@ -5,18 +5,18 @@ DOWNLOAD_LINK_GEOIP="https://github.com/v2ray/geoip/releases/latest/download/geo
|
||||||
DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat"
|
DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat"
|
||||||
|
|
||||||
download_geoip() {
|
download_geoip() {
|
||||||
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.bak" "$DOWNLOAD_LINK_GEOIP" -#
|
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.new" "$DOWNLOAD_LINK_GEOIP" -#
|
||||||
if [ "$?" -ne '0' ]; then
|
if [ "$?" -ne '0' ]; then
|
||||||
echo 'error: Download failed! Please check your network or try again.'
|
echo 'error: Download failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.sha256sum.bak" "$DOWNLOAD_LINK_GEOIP.sha256sum" -#
|
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.sha256sum.new" "$DOWNLOAD_LINK_GEOIP.sha256sum" -#
|
||||||
if [ "$?" -ne '0' ]; then
|
if [ "$?" -ne '0' ]; then
|
||||||
echo 'error: Download failed! Please check your network or try again.'
|
echo 'error: Download failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SUM="$(sha256sum ${V2RAY}geoip.dat.bak | sed 's/ .*//')"
|
SUM="$(sha256sum ${V2RAY}geoip.dat.new | sed 's/ .*//')"
|
||||||
CHECKSUM="$(sed 's/ .*//' ${V2RAY}geoip.dat.sha256sum.bak)"
|
CHECKSUM="$(sed 's/ .*//' ${V2RAY}geoip.dat.sha256sum.new)"
|
||||||
if [[ "$SUM" != "$CHECKSUM" ]]; then
|
if [[ "$SUM" != "$CHECKSUM" ]]; then
|
||||||
echo 'error: Check failed! Please check your network or try again.'
|
echo 'error: Check failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -24,35 +24,35 @@ download_geoip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
download_geosite() {
|
download_geosite() {
|
||||||
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geosite.dat.bak" "$DOWNLOAD_LINK_GEOSITE" -#
|
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geosite.dat.new" "$DOWNLOAD_LINK_GEOSITE" -#
|
||||||
if [ "$?" -ne '0' ]; then
|
if [ "$?" -ne '0' ]; then
|
||||||
echo 'error: Download failed! Please check your network or try again.'
|
echo 'error: Download failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geosite.dat.sha256sum.bak" "$DOWNLOAD_LINK_GEOSITE.sha256sum" -#
|
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geosite.dat.sha256sum.new" "$DOWNLOAD_LINK_GEOSITE.sha256sum" -#
|
||||||
if [ "$?" -ne '0' ]; then
|
if [ "$?" -ne '0' ]; then
|
||||||
echo 'error: Download failed! Please check your network or try again.'
|
echo 'error: Download failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SUM="$(sha256sum ${V2RAY}geosite.dat.bak | sed 's/ .*//')"
|
SUM="$(sha256sum ${V2RAY}geosite.dat.new | sed 's/ .*//')"
|
||||||
CHECKSUM="$(sed 's/ .*//' ${V2RAY}geosite.dat.sha256sum.bak)"
|
CHECKSUM="$(sed 's/ .*//' ${V2RAY}geosite.dat.sha256sum.new)"
|
||||||
if [[ "$SUM" != "$CHECKSUM" ]]; then
|
if [[ "$SUM" != "$CHECKSUM" ]]; then
|
||||||
echo 'error: Check failed! Please check your network or try again.'
|
echo 'error: Check failed! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rename_bak() {
|
rename_new() {
|
||||||
for BAT in 'geoip' 'geosite'; do
|
for DAT in 'geoip' 'geosite'; do
|
||||||
rename '.bak' '' "${V2RAY}$DAT.dat.bak"
|
mv "${V2RAY}$DAT.dat.new" "${V2RAY}$DAT.dat"
|
||||||
rm "${V2RAY}$DAT.dat.sha256sum.bak"
|
rm "${V2RAY}$DAT.dat.sha256sum.new"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
download_geoip
|
download_geoip
|
||||||
download_geosite
|
download_geosite
|
||||||
rename_bak
|
rename_new
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in New Issue