系统升级增加gitee源

This commit is contained in:
whyour 2022-11-17 22:01:47 +08:00
parent a1e1d6ed3f
commit 8b8336d9d0
2 changed files with 14 additions and 8 deletions

View File

@ -333,7 +333,6 @@ git_pull_scripts() {
exit_status=$? exit_status=$?
git pull &>/dev/null git pull &>/dev/null
unset_proxy unset_proxy
reset_branch "$branch"
cd $dir_current cd $dir_current
} }
@ -344,19 +343,21 @@ reset_romote_url() {
local url=$2 local url=$2
local branch="$3" local branch="$3"
cd $dir_work
if [[ -d "$dir_work/.git" ]]; then if [[ -d "$dir_work/.git" ]]; then
cd $dir_work
[[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null [[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null
git remote set-url origin $url &>/dev/null git remote set-url origin $url &>/dev/null
else
local part_cmd="" git init
reset_branch "$branch" git remote add origin $url &>/dev/null
cd $dir_current
fi fi
reset_branch "$branch"
cd $dir_current
} }
reset_branch() { reset_branch() {
local branch="$1" local branch="$1"
local part_cmd=""
if [[ $branch ]]; then if [[ $branch ]]; then
part_cmd="origin/${branch}" part_cmd="origin/${branch}"
git checkout -B "$branch" &>/dev/null git checkout -B "$branch" &>/dev/null

View File

@ -247,6 +247,11 @@ usage() {
update_qinglong() { update_qinglong() {
patch_version &>/dev/null patch_version &>/dev/null
local mirror="github"
local githubStatus=$(curl -s -m 3 -IL "https://github.com" | grep 200)
if [ "$githubStatus" == "" ]; then
mirror="gitee"
fi
export isFirstStartServer=false export isFirstStartServer=false
local all_branch=$(git branch -a) local all_branch=$(git branch -a)
@ -255,7 +260,7 @@ update_qinglong() {
primary_branch="${current_branch}" primary_branch="${current_branch}"
fi fi
[[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json) [[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json)
reset_romote_url ${dir_root} "https://github.com/whyour/qinglong.git" ${primary_branch} reset_romote_url ${dir_root} "https://${mirror}.com/whyour/qinglong.git" ${primary_branch}
git_pull_scripts $dir_root ${primary_branch} git_pull_scripts $dir_root ${primary_branch}
if [[ $exit_status -eq 0 ]]; then if [[ $exit_status -eq 0 ]]; then
@ -276,7 +281,7 @@ update_qinglong() {
update_qinglong_static() { update_qinglong_static() {
local no_restart="$1" local no_restart="$1"
local primary_branch="$2" local primary_branch="$2"
local url="https://github.com/whyour/qinglong-static.git" local url="https://${mirror}.com/whyour/qinglong-static.git"
if [[ -d ${ql_static_repo}/.git ]]; then if [[ -d ${ql_static_repo}/.git ]]; then
reset_romote_url ${ql_static_repo} ${url} ${primary_branch} reset_romote_url ${ql_static_repo} ${url} ${primary_branch}
git_pull_scripts ${ql_static_repo} ${primary_branch} git_pull_scripts ${ql_static_repo} ${primary_branch}