Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

主要兼容性建议 #782

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions qinglong/DefaultTasks/bili_task_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ set -u
set -o pipefail

verbose=false # 开启debug日志
bili_repo="raywangqvq/bilibilitoolpro" # 仓库地址
#bili_repo="raywangqvq/bilibilitoolpro" # 仓库地址 输入官方分支,或者加速分支目录
# 针对使用fock拉取分支的情况,建议把bili_repo做在环境变量中可以修改调整
# 可更兼容性
#bili_repo="aspnmy/BiliBiliToolPro"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调试代码不建议提交

bili_repo=${BILI_TRUETRUE_REPONAME:-"raywangqvq/bilibilitoolpro"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否可以BILI_TRUETRUE_REPONAME改为更好理解的命名

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你自己的项目 你可以自己想一想,如果我取的话,缩减一下可以用 BILI_TRUEUSE_NAME (实际使用路径)

bili_branch="" # 分支名,空或_develop
prefer_mode=${BILI_MODE:-"dotnet"} # dotnet或bilitool,需要通过环境变量配置
prefer_mode=${BILI_MODE:-""} # dotnet或bilitool,需要通过环境变量配置
github_proxy=${BILI_GITHUB_PROXY:-""} # 下载github release包时使用的代理,会拼在地址前面,需要通过环境变量配置




# Use in the the functions: eval $invocation
invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'

Expand Down Expand Up @@ -83,7 +90,10 @@ touch /root/.bashrc && . /root/.bashrc
# 目录
say "青龙repo目录: $dir_repo"
qinglong_bili_repo="$(echo "$bili_repo" | sed 's/\//_/g')${bili_branch}"

qinglong_bili_repo_dir="$(find $dir_repo -type d \( -iname $qinglong_bili_repo -o -iname ${qinglong_bili_repo}_main \) | head -1)"
#qinglong_bili_repo_dir="$qinglong_bili_repo/podAdmin_BiliBiliToolPro"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调试代码不建议提交


say "bili仓库目录: $qinglong_bili_repo_dir"

current_linux_os="debian" # 或alpine
Expand All @@ -92,6 +102,8 @@ machine_architecture="x64" # 或arm、arm64

bilitool_installed_version=0



# 以下操作仅在bilitool仓库的根bin文件下执行
cd $qinglong_bili_repo_dir
mkdir -p bin && cd $qinglong_bili_repo_dir/bin
Expand Down Expand Up @@ -257,6 +269,9 @@ check_unzip() {
fi
}




# 检查dotnet
check_dotnet() {
eval $invocation
Expand All @@ -279,14 +294,15 @@ check_bilitool() {
TAG_FILE="./tag.txt"
touch $TAG_FILE
local STORED_TAG=$(cat $TAG_FILE 2>/dev/null)

echo $STORED_TAG
#如果STORED_TAG为空,则返回1
if [[ -z $STORED_TAG ]]; then
say "tag.txt为空,未安装过"
return 1
fi

say "tag.txt记录的版本:$STORED_TAG"



# 查找当前目录下是否有叫Ray.BiliBiliTool.Console的文件
if [ -f "./Ray.BiliBiliTool.Console" ]; then
Expand Down Expand Up @@ -379,8 +395,26 @@ install_dotnet() {
# 从github获取bilitool下载地址
get_download_url() {
eval $invocation

tag=$1
# 增加业务逻辑:主要为了解决完成抓不到版本号时造成的更新错误
# 可配置环境变量,自定义一个初始值,然后进行下载,避免因为返回值为null而下载不了安装包
# bilitool: tag.txt记录的版本:null
# bilitool: bilitool未安装
# bilitool: 开始安装环境
# bilitool: 开始安装bilitool
# bilitool: 最新版本:null
# bilitool: 下载地址:https://ghproxy.net/https://github.com/RayWangQvQ/BiliBiliToolPro/releases/download/null/bilibili-tool-pro-vnull-linux-musl-x64.zip
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
# 100 9 100 9 0 0 10 0 --:--:-- --:--:-- --:--:-- 10
# Archive: bilitool-null.zip
# End-of-central-directory signature not found. Either this file is not
# a zipfile, or it constitutes one disk of a multi-part archive. In the
# latter case the central directory and zipfile comment will be found on
# the last disk(s) of this archive.
# unzip: cannot find zipfile directory in one of bilitool-null.zip or
# bilitool-null.zip.zip, and cannot find bilitool-null.zip.ZIP, period.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调试代码不建议提交


tag=${BILI_STORED_TAG:-""}
url="${github_proxy}https://github.com/RayWangQvQ/BiliBiliToolPro/releases/download/$tag/bilibili-tool-pro-v$tag-$current_os-$machine_architecture.zip"
say "下载地址:$url"
echo $url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# 增加业务逻辑:主要为了解决完成抓不到版本号时造成的更新错误

关于GitHub有时异常访问,会抓不到基础关键值的问题 比如tag版本号,除了用环境变量手工指定,兼容性上看,你要不和其他作者一样,使用国内的节点做个辅助来源,通过对来访者的ip判断,墙内的直接访问如gitcode的仓库,墙外的访问github,这样安装以后再更新拉库上兼容性更好。

我个人的兼容做法是在国内节点上部署一个私有库,如果GitHub访问有异常数据就会转到我们自己的私有库上去了
```suggestion
    # 增加业务逻辑:主要为了解决完成抓不到版本号时造成的更新错误

    tag=${BILI_STORED_TAG:-""}
    url="${github_proxy}https://github.com/RayWangQvQ/BiliBiliToolPro/releases/download/$tag/bilibili-tool-pro-v$tag-$current_os-$machine_architecture.zip"
    say "下载地址:$url"
    echo $url
```

Expand All @@ -398,7 +432,7 @@ install_bilitool() {
# 解析最新的tag名称
check_jq
LATEST_TAG=$(echo $LATEST_RELEASE | jq -r '.tag_name')
say "最新版本:$LATEST_TAG"
say "最新版本:$LATEST_TAG , 如果显示为null,就读取环境变量中BILI_STORED_TAG参数手工设置的版本号,避免下载文件遇到 no found错误"

# 读取之前存储的tag并比较
if [ "$LATEST_TAG" != "$bilitool_installed_version" ]; then
Expand Down Expand Up @@ -472,3 +506,4 @@ run_task() {

check_os
install