🌱check_url()
This commit is contained in:
parent
7e652fc3f1
commit
0cf2286ab7
@ -33,12 +33,35 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# 检查域名连通性
|
||||
check_url() {
|
||||
HTTP_CODE=$(curl -o /dev/null --connect-timeout 3 -s -w "%{http_code}" $1)
|
||||
if [ $HTTP_CODE -eq 200 ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# 获取有效 config.sh 链接
|
||||
get_valid_config(){
|
||||
config_list=(https://raw.githubusercontents.com/Oreomeow/VIP/main/Conf/Qinglong/config.sample.sh https://raw.sevencdn.com/Oreomeow/VIP/main/Conf/Qinglong/config.sample.sh https://ghproxy.com/https://raw.githubusercontent.com/Oreomeow/VIP/main/Conf/Qinglong/config.sample.sh)
|
||||
for url in ${config_list[@]}; do
|
||||
check_url $url
|
||||
if [ $? = 0 ]; then
|
||||
valid_url=$url
|
||||
echo "使用链接 $url"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
# 下载 config.sh
|
||||
dl_config_shell(){
|
||||
if [ ! -a "$config_shell_path" ]; then
|
||||
touch $config_shell_path
|
||||
fi
|
||||
curl -sL --connect-timeout 3 https://raw.githubusercontents.com/Oreomeow/VIP/main/Conf/Qinglong/config.sample.sh > $config_shell_path
|
||||
curl -sL --connect-timeout 3 $valid_url > $config_shell_path
|
||||
cp $config_shell_path $dir_config/config.sh
|
||||
# 判断是否下载成功
|
||||
config_size=$(ls -l $config_shell_path | awk '{print $5}')
|
||||
@ -48,18 +71,30 @@ dl_config_shell(){
|
||||
fi
|
||||
}
|
||||
if [ "${Rconfig}" = 'y' -o "${all}" = 1 ]; then
|
||||
dl_config_shell
|
||||
get_valid_config && dl_config_shell
|
||||
else
|
||||
echo "已为您跳过替换 config.sh"
|
||||
fi
|
||||
|
||||
|
||||
# 获取有效 extra.sh 链接
|
||||
get_valid_extra(){
|
||||
extra_list=(https://raw.githubusercontents.com/Oreomeow/VIP/main/Tasks/qlrepo/extra.sh https://raw.sevencdn.com/Oreomeow/VIP/main/Tasks/qlrepo/extra.sh https://ghproxy.com/https://raw.githubusercontent.com/Oreomeow/VIP/main/Tasks/qlrepo/extra.sh)
|
||||
for url in ${extra_list[@]}; do
|
||||
check_url $url
|
||||
if [ $? = 0 ]; then
|
||||
valid_url=$url
|
||||
echo "使用链接 $url"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
# 下载 extra.sh
|
||||
dl_extra_shell(){
|
||||
if [ ! -a "$extra_shell_path" ]; then
|
||||
touch $extra_shell_path
|
||||
fi
|
||||
curl -sL --connect-timeout 3 https://raw.githubusercontents.com/Oreomeow/VIP/main/Tasks/qlrepo/extra.sh > $extra_shell_path
|
||||
curl -sL --connect-timeout 3 $valid_url > $extra_shell_path
|
||||
cp $extra_shell_path $dir_config/extra.sh
|
||||
# 判断是否下载成功
|
||||
extra_size=$(ls -l $extra_shell_path | awk '{print $5}')
|
||||
@ -97,12 +132,12 @@ run_ql_extra(){
|
||||
sleep 5
|
||||
}
|
||||
if [ "${all}" = 1 ]; then
|
||||
dl_extra_shell && set_default_extra && add_ql_extra && run_ql_extra
|
||||
get_valid_extra && dl_extra_shell && set_default_extra && add_ql_extra && run_ql_extra
|
||||
elif [ "${extra}" = 'n' ]; then
|
||||
echo "已为您跳过操作 extra.sh"
|
||||
else
|
||||
if [[ ${extra} =~ 'a' ]]; then
|
||||
dl_extra_shell
|
||||
get_valid_extra && dl_extra_shell
|
||||
fi
|
||||
if [[ ${extra} =~ 'b' ]]; then
|
||||
set_default_extra
|
||||
@ -116,12 +151,24 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# 获取有效 code.sh 链接
|
||||
get_valid_code(){
|
||||
code_list=(https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/code.sh https://raw.sevencdn.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/code.sh https://ghproxy.com/https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/code.sh)
|
||||
for url in ${code_list[@]}; do
|
||||
check_url $url
|
||||
if [ $? = 0 ]; then
|
||||
valid_url=$url
|
||||
echo "使用链接 $url"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
# 下载 code.sh
|
||||
dl_code_shell(){
|
||||
if [ ! -a "$code_shell_path" ]; then
|
||||
touch $code_shell_path
|
||||
fi
|
||||
curl -sL --connect-timeout 3 https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/code.sh > $code_shell_path
|
||||
curl -sL --connect-timeout 3 $valid_url > $code_shell_path
|
||||
cp $code_shell_path $dir_config/code.sh
|
||||
# 判断是否下载成功
|
||||
code_size=$(ls -l $code_shell_path | awk '{print $5}')
|
||||
@ -154,12 +201,12 @@ add_bash_code(){
|
||||
fi
|
||||
}
|
||||
if [ "${all}" = 1 ]; then
|
||||
dl_code_shell && set_default_code && add_bash_code
|
||||
get_valid_code && dl_code_shell && set_default_code && add_bash_code
|
||||
elif [ "${code}" = 'n' ]; then
|
||||
echo "已为您跳过操作 code.sh"
|
||||
else
|
||||
if [[ ${code} =~ 'a' ]]; then
|
||||
dl_code_shell
|
||||
get_valid_code && dl_code_shell
|
||||
fi
|
||||
if [[ ${code} =~ 'b' ]]; then
|
||||
set_default_code
|
||||
@ -170,12 +217,24 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# 获取有效 task_before.sh 链接
|
||||
get_valid_task_before(){
|
||||
task_before_list=(https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/task_before.sh https://raw.sevencdn.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/task_before.sh https://ghproxy.com/https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/task_before.sh)
|
||||
for url in ${task_before_list[@]}; do
|
||||
check_url $url
|
||||
if [ $? = 0 ]; then
|
||||
valid_url=$url
|
||||
echo "使用链接 $url"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
# 下载 task_before.sh
|
||||
dl_task_before_shell(){
|
||||
if [ ! -a "$task_before_shell_path" ]; then
|
||||
touch $task_before_shell_path
|
||||
fi
|
||||
curl -sL --connect-timeout 3 https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/Helpcode2.8/task_before.sh > $task_before_shell_path
|
||||
curl -sL --connect-timeout 3 $valid_url > $task_before_shell_path
|
||||
cp $task_before_shell_path $dir_config/task_before.sh
|
||||
# 判断是否下载成功
|
||||
task_before_size=$(ls -l $task_before_shell_path | awk '{print $5}')
|
||||
@ -185,7 +244,7 @@ dl_task_before_shell(){
|
||||
fi
|
||||
}
|
||||
if [ "${Rbefore}" = 'y' -o "${all}" = 1 ]; then
|
||||
dl_task_before_shell
|
||||
get_valid_task_before && dl_task_before_shell
|
||||
else
|
||||
echo "已为您跳过替换 task_before.sh"
|
||||
fi
|
||||
@ -247,17 +306,17 @@ add_curl_sample(){
|
||||
fi
|
||||
}
|
||||
run_curl_sample(){
|
||||
curl -sL https://raw.githubusercontents.com/Oreomeow/VIP/main/Conf/Qinglong/config.sample.sh -o /ql/sample/config.sample.sh && cp -rf /ql/sample/config.sample.sh /ql/config
|
||||
curl -sL $valid_url -o /ql/sample/config.sample.sh && cp -rf /ql/sample/config.sample.sh /ql/config
|
||||
}
|
||||
if [ "${all}" = 1 ]; then
|
||||
add_curl_sample && run_curl_sample
|
||||
get_valid_config && add_curl_sample && run_curl_sample
|
||||
else
|
||||
case ${sample} in
|
||||
0) echo "已为您跳过自动更新模板"
|
||||
;;
|
||||
1) add_curl_sample
|
||||
1) get_valid_config && add_curl_sample
|
||||
;;
|
||||
2) add_curl_sample && run_curl_sample
|
||||
2) get_valid_config && add_curl_sample && run_curl_sample
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user