Created
September 1, 2022 03:28
-
-
Save satifanie/2a3b2d89bdcc56b79e8301fe2afc587e to your computer and use it in GitHub Desktop.
自动更新geosite geoip。供其他应用使用,增加了文件大小判断,避免下载了空文件影响程序使用。
This file contains 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 | |
################# setup env | |
# download resource refer: | |
# https://github.com/Loyalsoldier/geoip | |
# https://github.com/Loyalsoldier/v2ray-rules-dat | |
# 使用 https://hub.fastgit.xyz/author/repo 加速 | |
geoip="https://raw.fastgit.org/Loyalsoldier/geoip/release/geoip-only-cn-private.dat" | |
geosite="https://download.fastgit.org/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" | |
minip=100000 | |
minisite=4000000 | |
# | |
tmpip=/tmp/geoip.dat | |
tmpsite=/tmp/geosite.dat | |
# | |
saveip=/opt/etc/mosdns/geoip-only-cn-private.dat | |
savesite=/opt/etc/mosdns/geosite.dat | |
################ | |
#wget | |
echo "downloading...." | |
wget --no-check-certificate $geoip -O $tmpip >/dev/null 2>&1 | |
wget --no-check-certificate $geosite -O $tmpsite >/dev/null 2>&1 | |
#check | |
sizeip=`ls -l $tmpip | awk '{ print $5 }'` | |
sizesite=`ls -l $tmpsite | awk '{ print $5 }'` | |
# mv to saved | |
if [ $sizeip -gt $minip -a $sizesite -gt $minisite ]; then | |
echo "passed. restarting." | |
mv $tmpip $saveip | |
mv $tmpsite $savesite | |
docker restart mosdns | |
else | |
echo "task failed." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment