diff --git a/plugins/webstats/install.sh b/plugins/webstats/install.sh index 2741c9399..b841c6a13 100755 --- a/plugins/webstats/install.sh +++ b/plugins/webstats/install.sh @@ -24,6 +24,10 @@ if [ -f ${rootPath}/bin/activate ];then source ${rootPath}/bin/activate fi +get_latest_release() { + curl -sL "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | cut -d'"' -f4 +} + Install_App() { echo '正在安装脚本文件...' > $install_tmp @@ -86,18 +90,19 @@ Install_App() # https://github.com/P3TERX/GeoLite.mmdb pip install geoip2 - if [ ! -f $serverPath/webstats/GeoLite2-City.mmdb ];then - wget --no-check-certificate -O $serverPath/webstats/GeoLite2-City.mmdb https://github.com/P3TERX/GeoLite.mmdb/releases/download/2022.10.16/GeoLite2-City.mmdb - fi + # if [ ! -f $serverPath/webstats/GeoLite2-City.mmdb ];then + # wget --no-check-certificate -O $serverPath/webstats/GeoLite2-City.mmdb https://github.com/P3TERX/GeoLite.mmdb/releases/download/2022.10.16/GeoLite2-City.mmdb + # fi # 缓存数据 - # if [ ! -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then - # wget --no-check-certificate -O $serverPath/source/webstats/GeoLite2-City.mmdb https://github.com/P3TERX/GeoLite.mmdb/releases/download/2022.10.16/GeoLite2-City.mmdb - # fi + GEO_VERSION=$(get_latest_release "P3TERX/GeoLite.mmdb") + if [ ! -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then + wget --no-check-certificate -O $serverPath/source/webstats/GeoLite2-City.mmdb https://github.com/P3TERX/GeoLite.mmdb/releases/download/${GEO_VERSION}/GeoLite2-City.mmdb + fi - # if [ -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then - # cp -rf $serverPath/source/webstats/GeoLite2-City.mmdb $serverPath/webstats/GeoLite2-City.mmdb - # fi + if [ -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then + cp -rf $serverPath/source/webstats/GeoLite2-City.mmdb $serverPath/webstats/GeoLite2-City.mmdb + fi echo "${VERSION}" > $serverPath/webstats/version.pl echo '安装完成' > $install_tmp