加强了中国大陆安装时候的稳定性和速度

This commit is contained in:
Erope 2021-04-06 17:04:56 +08:00
parent 1d6fa0dca9
commit ddf93bb80b

View File

@ -42,12 +42,43 @@ pre_check() {
os_arch="arm"
fi
## China_IP
IP_JSON=
if [[ $(curl -m 10 -s https://api.ip.sb/geoip | grep 'China') != "" ]]; then
echo "根据ip.sb提供的信息当前IP可能在中国"
while true
do
read -r -p "是否选用中国镜像完成安装? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO]|[nN])
echo "不使用中国镜像"
;;
*)
echo "错误输入..."
;;
esac
done
if [[ -z "${CN}" ]]; then
GITHUB_RAW_URL="raw.githubusercontent.com"
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com"
Get_Docker_Argu =""
else
GITHUB_RAW_URL="raw.sevencdn.com"
GITHUB_URL="hub.fastgit.org"
GITHUB_RAW_URL="cdn.jsdelivr.net/gh/naiba/nezha@master"
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
Get_Docker_URL="get.daocloud.io/docker"
Get_Docker_Argu=" --mirror Aliyun"
echo "写入/etc/hosts 52.68.132.128 ghcr.io"
echo "52.68.132.128 ghcr.io" >> /etc/hosts
fi
}
@ -96,9 +127,9 @@ install_dashboard() {
command -v docker >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "正在安装 Docker"
bash <(curl -sL https://get.docker.com) >/dev/null 2>&1
bash <(curl -sL https://${Get_Docker_URL}) ${Get_Docker_Argu} >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 get.docker.com${plain}"
echo -e "${red}下载脚本失败,请检查本机能否连接 ${Get_Docker_URL}${plain}"
return 0
fi
systemctl enable docker.service
@ -154,7 +185,7 @@ install_agent() {
modify_agent_config() {
echo -e "> 修改Agent配置"
wget -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/naiba/nezha/master/script/nezha-agent.service >/dev/null 2>&1
wget -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
@ -193,7 +224,7 @@ modify_dashboard_config() {
echo -e "> 修改面板配置"
echo -e "正在下载 Docker 脚本"
wget -O ${NZ_DASHBOARD_PATH}/docker-compose.yaml https://${GITHUB_RAW_URL}/naiba/nezha/master/script/docker-compose.yaml >/dev/null 2>&1
wget -O ${NZ_DASHBOARD_PATH}/docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0
@ -201,7 +232,7 @@ modify_dashboard_config() {
mkdir -p $NZ_DASHBOARD_PATH/data
wget -O ${NZ_DASHBOARD_PATH}/data/config.yaml https://${GITHUB_RAW_URL}/naiba/nezha/master/script/config.yaml >/dev/null 2>&1
wget -O ${NZ_DASHBOARD_PATH}/data/config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
if [[ $? != 0 ]]; then
echo -e "${red}下载脚本失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
return 0