订阅支持添加代理

This commit is contained in:
whyour
2022-11-12 22:45:46 +08:00
parent 8fdd8db51b
commit ff2b4e0b2f
5 changed files with 56 additions and 24 deletions
+11 -5
View File
@@ -85,6 +85,10 @@ import_config() {
}
set_proxy() {
local proxy="$1"
if [[ $proxy ]]; then
proxy_url="$proxy"
fi
if [[ $proxy_url ]]; then
export http_proxy="${proxy_url}"
export https_proxy="${proxy_url}"
@@ -303,13 +307,14 @@ update_depend() {
}
git_clone_scripts() {
local url=$1
local dir=$2
local branch=$3
local url="$1"
local dir="$2"
local branch="$3"
local proxy="$4"
[[ $branch ]] && local part_cmd="-b $branch "
echo -e "开始克隆仓库 $url$dir\n"
set_proxy
set_proxy "$proxy"
git clone $part_cmd $url $dir
exit_status=$?
unset_proxy
@@ -319,10 +324,11 @@ git_pull_scripts() {
local dir_current=$(pwd)
local dir_work="$1"
local branch="$2"
local proxy="$3"
cd $dir_work
echo -e "开始更新仓库:$dir_work\n"
set_proxy
set_proxy "$proxy"
git fetch --all
exit_status=$?
git pull &>/dev/null
+14 -8
View File
@@ -144,6 +144,7 @@ update_repo() {
local dependence="$4"
local branch="$5"
local extensions="$6"
local proxy="$7"
local tmp="${url%/*}"
local authorTmp1="${tmp##*/}"
local authorTmp2="${authorTmp1##*:}"
@@ -156,9 +157,9 @@ update_repo() {
local formatUrl="$url"
if [[ -d ${repo_path}/.git ]]; then
reset_romote_url ${repo_path} "${formatUrl}" "${branch}"
git_pull_scripts ${repo_path} "${branch}"
git_pull_scripts ${repo_path} "${branch}" "${proxy}"
else
git_clone_scripts "${formatUrl}" ${repo_path} "${branch}"
git_clone_scripts "${formatUrl}" ${repo_path} "${branch}" "${proxy}"
fi
if [[ $exit_status -eq 0 ]]; then
echo -e "\n更新${repo_path}成功...\n"
@@ -447,7 +448,10 @@ main() {
[[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp"
local begin_time=$(format_time "$time_format" "$time")
eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
fi
if [[ -s $task_error_log_path ]]; then
eval cat $task_error_log_path $cmd
@@ -470,7 +474,7 @@ main() {
repo)
get_uniq_path "$p2" "$p6"
if [[ -n $p2 ]]; then
update_repo "$p2" "$p3" "$p4" "$p5" "$p6" "$p7"
update_repo "$p2" "$p3" "$p4" "$p5" "$p6" "$p7" "$p8"
else
eval echo -e "命令输入错误...\\\n" $cmd
eval usage $cmd
@@ -497,7 +501,7 @@ main() {
resetlet)
auth_value=$(cat $file_auth_user | jq '.retries =0' -c)
echo "$auth_value" >$file_auth_user
echo -e "重置登录错误次数成功" $cmd
eval echo -e "重置登录错误次数成功" $cmd
;;
resettfa)
auth_value=$(cat $file_auth_user | jq '.twoFactorActivated =false' | jq '.twoFactorActived =false' -c)
@@ -514,10 +518,12 @@ main() {
local end_time=$(format_time "$time_format" "$etime")
local end_timestamp=$(format_timestamp "$time_format" "$etime")
local diff_time=$(($end_timestamp - $begin_timestamp))
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time" $cmd
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
eval echo -e "\\\n          " $cmd
if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time" $cmd
eval echo -e "\\\n          " $cmd
fi
if [[ -f $file_path ]]; then
cat $file_path