pull file
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
This commit is contained in:
472
qinglong/DefaultTasks/bili_task_base.sh
Normal file
472
qinglong/DefaultTasks/bili_task_base.sh
Normal file
@@ -0,0 +1,472 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili_base")
|
||||
|
||||
# Stop script on NZEC
|
||||
set -e
|
||||
# Stop script if unbound variable found (use ${var:-} if intentional)
|
||||
set -u
|
||||
# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success
|
||||
# This is causing it to fail
|
||||
set -o pipefail
|
||||
|
||||
verbose=false # 开启debug日志
|
||||
bili_repo="raywangqvq/bilibilitoolpro" # 仓库地址
|
||||
bili_branch="" # 分支名,空或_develop
|
||||
prefer_mode=${BILI_MODE:-"dotnet"} # dotnet或bilitool,需要通过环境变量配置
|
||||
github_proxy=${BILI_GITHUB_PROXY:-""} # 下载github release包时使用的代理,会拼在地址前面,需要通过环境变量配置
|
||||
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 # 解决抽风问题
|
||||
|
||||
# Use in the the functions: eval $invocation
|
||||
invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
|
||||
|
||||
# standard output may be used as a return value in the functions
|
||||
# we need a way to write text on the screen in the functions so that
|
||||
# it won't interfere with the return value.
|
||||
# Exposing stream 3 as a pipe to standard output of the script itself
|
||||
exec 3>&1
|
||||
|
||||
# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
|
||||
# See if stdout is a terminal
|
||||
if [ -t 1 ] && command -v tput >/dev/null; then
|
||||
# see if it supports colors
|
||||
ncolors=$(tput colors || echo 0)
|
||||
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
|
||||
bold="$(tput bold || echo)"
|
||||
normal="$(tput sgr0 || echo)"
|
||||
black="$(tput setaf 0 || echo)"
|
||||
red="$(tput setaf 1 || echo)"
|
||||
green="$(tput setaf 2 || echo)"
|
||||
yellow="$(tput setaf 3 || echo)"
|
||||
blue="$(tput setaf 4 || echo)"
|
||||
magenta="$(tput setaf 5 || echo)"
|
||||
cyan="$(tput setaf 6 || echo)"
|
||||
white="$(tput setaf 7 || echo)"
|
||||
fi
|
||||
fi
|
||||
|
||||
say_warning() {
|
||||
printf "%b\n" "${yellow:-}bilitool: Warning: $1${normal:-}" >&3
|
||||
}
|
||||
|
||||
say_err() {
|
||||
printf "%b\n" "${red:-}bilitool: Error: $1${normal:-}" >&2
|
||||
}
|
||||
|
||||
say() {
|
||||
# using stream 3 (defined in the beginning) to not interfere with stdout of functions
|
||||
# which may be used as return value
|
||||
printf "%b\n" "${cyan:-}bilitool:${normal:-} $1" >&3
|
||||
}
|
||||
|
||||
say_verbose() {
|
||||
if [ "$verbose" = true ]; then
|
||||
say "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
QL_DIR=${QL_DIR:-"/ql"}
|
||||
QL_BRANCH=${QL_BRANCH:-"develop"}
|
||||
DefaultCronRule=${DefaultCronRule:-""}
|
||||
CpuWarn=${CpuWarn:-""}
|
||||
MemoryWarn=${MemoryWarn:-""}
|
||||
DiskWarn=${DiskWarn:-""}
|
||||
|
||||
dir_repo=${dir_repo:-"$QL_DIR/data/repo"}
|
||||
# 需要兼容老版本青龙,https://github.com/RayWangQvQ/BiliBiliToolPro/issues/728
|
||||
if [ ! -d "$dir_repo" ] && [ -d "$QL_DIR/repo" ]; then
|
||||
dir_repo="$QL_DIR/repo"
|
||||
fi
|
||||
dir_shell=$QL_DIR/shell
|
||||
touch $dir_shell/env.sh && . $dir_shell/env.sh
|
||||
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)"
|
||||
say "bili仓库目录: $qinglong_bili_repo_dir"
|
||||
|
||||
current_linux_os="debian" # 或alpine
|
||||
current_os="linux" # 或linux-musl
|
||||
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
|
||||
|
||||
# 判断是否存在某指令
|
||||
machine_has() {
|
||||
eval $invocation
|
||||
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
# 判断系统架构
|
||||
# 输出:arm、arm64、x64
|
||||
get_machine_architecture() {
|
||||
eval $invocation
|
||||
|
||||
if command -v uname >/dev/null; then
|
||||
CPUName=$(uname -m)
|
||||
case $CPUName in
|
||||
armv*l)
|
||||
echo "arm"
|
||||
return 0
|
||||
;;
|
||||
aarch64 | arm64)
|
||||
echo "arm64"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Always default to 'x64'
|
||||
echo "x64"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 获取linux系统名称
|
||||
# 输出:debian.10、debian.11、debian.12、ubuntu.20.04、ubuntu.22.04、alpine.3.4.3...
|
||||
get_linux_platform_name() {
|
||||
eval $invocation
|
||||
|
||||
if [ -e /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
echo "$ID${VERSION_ID:+.${VERSION_ID}}"
|
||||
return 0
|
||||
elif [ -e /etc/redhat-release ]; then
|
||||
local redhatRelease=$(</etc/redhat-release)
|
||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux "*" release 6."* ]]; then
|
||||
echo "rhel.6"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Linux specific platform name and version could not be detected: UName = $uname"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 判断是否为musl(一般指alpine)
|
||||
is_musl_based_distro() {
|
||||
eval $invocation
|
||||
|
||||
(ldd --version 2>&1 || true) | grep -q musl
|
||||
}
|
||||
|
||||
# 获取当前系统名称
|
||||
# 输出:linux、linux-musl、osx、freebsd
|
||||
get_current_os_name() {
|
||||
eval $invocation
|
||||
|
||||
local uname=$(uname)
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
say_warning "当前系统:osx"
|
||||
echo "osx"
|
||||
return 1
|
||||
elif [ "$uname" = "FreeBSD" ]; then
|
||||
say_warning "当前系统:freebsd"
|
||||
echo "freebsd"
|
||||
return 1
|
||||
elif [ "$uname" = "Linux" ]; then
|
||||
local linux_platform_name=""
|
||||
linux_platform_name="$(get_linux_platform_name)" || true
|
||||
say "当前系统发行版本:$linux_platform_name"
|
||||
|
||||
if [ "$linux_platform_name" = "rhel.6" ]; then
|
||||
echo $linux_platform_name
|
||||
return 1
|
||||
elif is_musl_based_distro; then
|
||||
echo "linux-musl"
|
||||
return 0
|
||||
elif [ "$linux_platform_name" = "linux-musl" ]; then
|
||||
echo "linux-musl"
|
||||
return 0
|
||||
else
|
||||
echo "linux"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
say_err "OS name could not be detected: UName = $uname"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 检查操作系统
|
||||
check_os() {
|
||||
eval $invocation
|
||||
|
||||
current_os="$(get_current_os_name)"
|
||||
say "当前系统:$current_os"
|
||||
|
||||
machine_architecture="$(get_machine_architecture)"
|
||||
say "当前架构:$machine_architecture"
|
||||
|
||||
if [ "$current_os" = "linux" ]; then
|
||||
current_linux_os="debian" # 当前青龙只有debian和aplpine两种
|
||||
if ! machine_has curl; then
|
||||
say "curl未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y curl
|
||||
fi
|
||||
else
|
||||
current_linux_os="alpine"
|
||||
if ! machine_has curl; then
|
||||
say "curl未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y curl
|
||||
fi
|
||||
fi
|
||||
|
||||
say "当前选择的运行方式:$prefer_mode"
|
||||
}
|
||||
|
||||
# 检查安装jq
|
||||
check_jq() {
|
||||
if [ "$current_linux_os" = "debian" ]; then
|
||||
if ! machine_has jq; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y jq
|
||||
fi
|
||||
else
|
||||
if ! machine_has jq; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y jq
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查安装unzip
|
||||
check_unzip() {
|
||||
if [ "$current_linux_os" = "debian" ]; then
|
||||
if ! machine_has unzip; then
|
||||
say "unzip未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y unzip
|
||||
fi
|
||||
else
|
||||
if ! machine_has unzip; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y unzip
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查dotnet
|
||||
check_dotnet() {
|
||||
eval $invocation
|
||||
|
||||
dotnetVersion=$(dotnet --version)
|
||||
say "当前dotnet版本:$dotnetVersion"
|
||||
if [[ $(echo "$dotnetVersion" | grep -oE '^[0-9]+') -ge 8 ]]; then
|
||||
say "已安装,且版本满足"
|
||||
say "which dotnet: $(which dotnet)"
|
||||
return 0
|
||||
else
|
||||
say "未安装"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查bilitool
|
||||
check_bilitool() {
|
||||
eval $invocation
|
||||
|
||||
TAG_FILE="./tag.txt"
|
||||
touch $TAG_FILE
|
||||
local STORED_TAG=$(cat $TAG_FILE 2>/dev/null)
|
||||
|
||||
#如果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
|
||||
say "bilitool已安装"
|
||||
bilitool_installed_version=$STORED_TAG
|
||||
return 0
|
||||
else
|
||||
say "bilitool未安装"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查环境
|
||||
check_installed() {
|
||||
eval $invocation
|
||||
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
check_dotnet
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ "$prefer_mode" == "bilitool" ]; then
|
||||
check_bilitool
|
||||
return $?
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# 使用官方脚本安装dotnet
|
||||
install_dotnet_by_script() {
|
||||
eval $invocation
|
||||
|
||||
say "再尝试使用官方脚本安装"
|
||||
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --verbose
|
||||
|
||||
say "添加到PATH"
|
||||
local exportFile="/root/.bashrc"
|
||||
touch $exportFile
|
||||
echo '' >>$exportFile
|
||||
echo 'export DOTNET_ROOT=$HOME/.dotnet' >>$exportFile
|
||||
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >>$exportFile
|
||||
. $exportFile
|
||||
}
|
||||
|
||||
# 安装dotnet环境
|
||||
install_dotnet() {
|
||||
eval $invocation
|
||||
|
||||
say "开始安装dotnet"
|
||||
say "当前系统:$current_linux_os"
|
||||
if [[ $current_linux_os == "debian" ]]; then
|
||||
say "使用apt安装"
|
||||
|
||||
if ! (curl -s -m 5 www.google.com >/dev/nul); then
|
||||
say "机器位于墙内,切换为包源为国内镜像源"
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
sed -i 's/https:\/\/deb.debian.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
sed -i 's/http:\/\/deb.debian.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
apt-get update
|
||||
fi
|
||||
{
|
||||
. /etc/os-release
|
||||
curl -o packages-microsoft-prod.deb https://packages.microsoft.com/config/debian/$VERSION_ID/packages-microsoft-prod.deb
|
||||
dpkg -i packages-microsoft-prod.deb
|
||||
rm packages-microsoft-prod.deb
|
||||
apt-get update && apt-get install -y dotnet-sdk-8.0
|
||||
} || {
|
||||
install_dotnet_by_script
|
||||
}
|
||||
else
|
||||
say "使用apk安装"
|
||||
if ! (curl -s -m 5 www.google.com >/dev/nul); then
|
||||
say "机器位于墙内,切换为包源为国内镜像源"
|
||||
cp /etc/apk/repositories /etc/apk/repositories.bak
|
||||
sed -i 's/https:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||
sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||
apk update
|
||||
fi
|
||||
{
|
||||
apk add dotnet8-sdk # https://pkgs.alpinelinux.org/packages
|
||||
} || {
|
||||
install_dotnet_by_script
|
||||
}
|
||||
fi
|
||||
dotnet --version && say "which dotnet: $(which dotnet)" && say "安装成功"
|
||||
return $?
|
||||
}
|
||||
|
||||
# 从github获取bilitool下载地址
|
||||
get_download_url() {
|
||||
eval $invocation
|
||||
|
||||
tag=$1
|
||||
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
|
||||
return 0
|
||||
}
|
||||
|
||||
# 安装bilitool
|
||||
install_bilitool() {
|
||||
eval $invocation
|
||||
|
||||
say "开始安装bilitool"
|
||||
# 获取最新的release信息
|
||||
LATEST_RELEASE=$(curl -s https://api.github.com/repos/$bili_repo/releases/latest)
|
||||
|
||||
# 解析最新的tag名称
|
||||
check_jq
|
||||
LATEST_TAG=$(echo $LATEST_RELEASE | jq -r '.tag_name')
|
||||
say "最新版本:$LATEST_TAG"
|
||||
|
||||
# 读取之前存储的tag并比较
|
||||
if [ "$LATEST_TAG" != "$bilitool_installed_version" ]; then
|
||||
# 如果不一样,则需要更新安装
|
||||
ASSET_URL=$(get_download_url $LATEST_TAG)
|
||||
|
||||
# 使用curl下载文件到当前目录下的test.zip文件
|
||||
local zip_file_name="bilitool-$LATEST_TAG.zip"
|
||||
curl -L -o "$zip_file_name" $ASSET_URL
|
||||
|
||||
# 解压
|
||||
check_unzip
|
||||
unzip -jo "$zip_file_name" -d ./ &&
|
||||
rm "$zip_file_name" &&
|
||||
rm -f appsettings.*
|
||||
|
||||
# 更新tag.txt文件
|
||||
echo $LATEST_TAG >./tag.txt
|
||||
else
|
||||
say "已经是最新版本,无需下载。"
|
||||
fi
|
||||
}
|
||||
|
||||
## 安装dotnet(如果未安装过)
|
||||
install() {
|
||||
eval $invocation
|
||||
|
||||
if check_installed; then
|
||||
say "环境正常,本次无需安装"
|
||||
else
|
||||
say "开始安装环境"
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
install_dotnet || {
|
||||
say_err "安装失败"
|
||||
say_err "请根据文档自行在青龙容器中安装dotnet:https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-$current_linux_os"
|
||||
say_err "或者尝试切换运行模式为bilitool,它不需要安装dotnet:https://github.com/RayWangQvQ/BiliBiliToolPro/blob/develop/qinglong/README.md"
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$prefer_mode" == "bilitool" ]; then
|
||||
install_bilitool || {
|
||||
say_err "安装失败,请检查日志并重试"
|
||||
say_err "或者尝试切换运行模式为dotnet:https://github.com/RayWangQvQ/BiliBiliToolPro/blob/develop/qinglong/README.md"
|
||||
}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 运行bilitool任务
|
||||
run_task() {
|
||||
eval $invocation
|
||||
|
||||
local target_code=$1
|
||||
|
||||
export Ray_PlatformType=QingLong
|
||||
export Ray_RunTasks=$target_code
|
||||
|
||||
cd $qinglong_bili_repo_dir/src/Ray.BiliBiliTool.Console
|
||||
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
dotnet run --ENVIRONMENT=Production
|
||||
else
|
||||
cp -f $qinglong_bili_repo_dir/bin/Ray.BiliBiliTool.Console .
|
||||
chmod +x ./Ray.BiliBiliTool.Console && ./Ray.BiliBiliTool.Console --ENVIRONMENT=Production
|
||||
fi
|
||||
}
|
||||
|
||||
check_os
|
||||
install
|
||||
8
qinglong/DefaultTasks/bili_task_charge.sh
Normal file
8
qinglong/DefaultTasks/bili_task_charge.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 12 * * *
|
||||
# new Env("bili免费B币券充电任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Charge"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_daily.sh
Normal file
8
qinglong/DefaultTasks/bili_task_daily.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 9 * * *
|
||||
# new Env("bili每日任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Daily"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_liveFansMedal.sh
Normal file
8
qinglong/DefaultTasks/bili_task_liveFansMedal.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:5 0 * * *
|
||||
# new Env("bili直播粉丝牌")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="LiveFansMedal"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_liveLottery.sh
Normal file
8
qinglong/DefaultTasks/bili_task_liveLottery.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 13 * * *
|
||||
# new Env("bili天选时刻")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="LiveLottery"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_login.sh
Normal file
8
qinglong/DefaultTasks/bili_task_login.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili扫码登录")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Login"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_manga.sh
Normal file
8
qinglong/DefaultTasks/bili_task_manga.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 14 * * *
|
||||
# new Env("bili漫画任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Manga"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_manga_privilege.sh
Normal file
8
qinglong/DefaultTasks/bili_task_manga_privilege.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 15 * * *
|
||||
# new Env("bili领取大会员漫画权益任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="MangaPrivilege"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_silver2coin.sh
Normal file
8
qinglong/DefaultTasks/bili_task_silver2coin.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 8 * * *
|
||||
# new Env("bili银瓜子兑换硬币任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Silver2Coin"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_test.sh
Normal file
8
qinglong/DefaultTasks/bili_task_test.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 8 * * *
|
||||
# new Env("bili测试ck")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="Test"
|
||||
run_task "${target_task_code}"
|
||||
33
qinglong/DefaultTasks/bili_task_tryFix.sh
Normal file
33
qinglong/DefaultTasks/bili_task_tryFix.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili尝试修复异常")
|
||||
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
. /root/.bashrc
|
||||
|
||||
bili_repo="raywangqvq_bilibilitoolpro"
|
||||
bili_branch=""
|
||||
|
||||
echo "青龙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)"
|
||||
echo "bili仓库目录: $qinglong_bili_repo_dir"
|
||||
|
||||
echo -e "清理缓存...\n"
|
||||
cd $qinglong_bili_repo_dir
|
||||
find . -type d -name "bin" -exec rm -rf {} +
|
||||
find . -type d -name "obj" -exec rm -rf {} +
|
||||
echo -e "清理完成\n"
|
||||
|
||||
echo "检测dotnet..."
|
||||
dotnetVersion=$(dotnet --version)
|
||||
echo "当前dotnet版本:$dotnetVersion"
|
||||
if [[ $(echo "$dotnetVersion" | grep -oE '^[0-9]+') -ge 8 ]]; then
|
||||
echo "已安装,且版本满足"
|
||||
else
|
||||
echo "which dotnet: $(which dotnet)"
|
||||
echo "Path: $PATH"
|
||||
rm -f /usr/local/bin/dotnet
|
||||
fi
|
||||
echo "检测dotnet结束"
|
||||
8
qinglong/DefaultTasks/bili_task_unfollowBatched.sh
Normal file
8
qinglong/DefaultTasks/bili_task_unfollowBatched.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 12 1 * *
|
||||
# new Env("bili批量取关主播")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="UnfollowBatched"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_vipBigPoint.sh
Normal file
8
qinglong/DefaultTasks/bili_task_vipBigPoint.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:7 1 * * *
|
||||
# new Env("bili大会员大积分")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="VipBigPoint"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/bili_task_vip_privilege.sh
Normal file
8
qinglong/DefaultTasks/bili_task_vip_privilege.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 1 * * *
|
||||
# new Env("bili领取大会员福利任务")
|
||||
|
||||
. bili_task_base.sh
|
||||
|
||||
target_task_code="VipPrivilege"
|
||||
run_task "${target_task_code}"
|
||||
472
qinglong/DefaultTasks/dev/bili_dev_task_base.sh
Normal file
472
qinglong/DefaultTasks/dev/bili_dev_task_base.sh
Normal file
@@ -0,0 +1,472 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili_dev_task_base");
|
||||
|
||||
# Stop script on NZEC
|
||||
set -e
|
||||
# Stop script if unbound variable found (use ${var:-} if intentional)
|
||||
set -u
|
||||
# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success
|
||||
# This is causing it to fail
|
||||
set -o pipefail
|
||||
|
||||
verbose=false # 开启debug日志
|
||||
bili_repo="raywangqvq/bilibilitoolpro" # 仓库地址
|
||||
bili_branch="_develop" # 分支名,空或_develop
|
||||
prefer_mode=${BILI_MODE:-"dotnet"} # dotnet或bilitool,需要通过环境变量配置
|
||||
github_proxy=${BILI_GITHUB_PROXY:-""} # 下载github release包时使用的代理,会拼在地址前面,需要通过环境变量配置
|
||||
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 # 解决抽风问题
|
||||
|
||||
# Use in the the functions: eval $invocation
|
||||
invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
|
||||
|
||||
# standard output may be used as a return value in the functions
|
||||
# we need a way to write text on the screen in the functions so that
|
||||
# it won't interfere with the return value.
|
||||
# Exposing stream 3 as a pipe to standard output of the script itself
|
||||
exec 3>&1
|
||||
|
||||
# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
|
||||
# See if stdout is a terminal
|
||||
if [ -t 1 ] && command -v tput >/dev/null; then
|
||||
# see if it supports colors
|
||||
ncolors=$(tput colors || echo 0)
|
||||
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
|
||||
bold="$(tput bold || echo)"
|
||||
normal="$(tput sgr0 || echo)"
|
||||
black="$(tput setaf 0 || echo)"
|
||||
red="$(tput setaf 1 || echo)"
|
||||
green="$(tput setaf 2 || echo)"
|
||||
yellow="$(tput setaf 3 || echo)"
|
||||
blue="$(tput setaf 4 || echo)"
|
||||
magenta="$(tput setaf 5 || echo)"
|
||||
cyan="$(tput setaf 6 || echo)"
|
||||
white="$(tput setaf 7 || echo)"
|
||||
fi
|
||||
fi
|
||||
|
||||
say_warning() {
|
||||
printf "%b\n" "${yellow:-}bilitool: Warning: $1${normal:-}" >&3
|
||||
}
|
||||
|
||||
say_err() {
|
||||
printf "%b\n" "${red:-}bilitool: Error: $1${normal:-}" >&2
|
||||
}
|
||||
|
||||
say() {
|
||||
# using stream 3 (defined in the beginning) to not interfere with stdout of functions
|
||||
# which may be used as return value
|
||||
printf "%b\n" "${cyan:-}bilitool:${normal:-} $1" >&3
|
||||
}
|
||||
|
||||
say_verbose() {
|
||||
if [ "$verbose" = true ]; then
|
||||
say "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
QL_DIR=${QL_DIR:-"/ql"}
|
||||
QL_BRANCH=${QL_BRANCH:-"develop"}
|
||||
DefaultCronRule=${DefaultCronRule:-""}
|
||||
CpuWarn=${CpuWarn:-""}
|
||||
MemoryWarn=${MemoryWarn:-""}
|
||||
DiskWarn=${DiskWarn:-""}
|
||||
|
||||
dir_repo=${dir_repo:-"$QL_DIR/data/repo"}
|
||||
# 需要兼容老版本青龙,https://github.com/RayWangQvQ/BiliBiliToolPro/issues/728
|
||||
if [ ! -d "$dir_repo" ] && [ -d "$QL_DIR/repo" ]; then
|
||||
dir_repo="$QL_DIR/repo"
|
||||
fi
|
||||
dir_shell=$QL_DIR/shell
|
||||
touch $dir_shell/env.sh && . $dir_shell/env.sh
|
||||
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)"
|
||||
say "bili仓库目录: $qinglong_bili_repo_dir"
|
||||
|
||||
current_linux_os="debian" # 或alpine
|
||||
current_os="linux" # 或linux-musl
|
||||
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
|
||||
|
||||
# 判断是否存在某指令
|
||||
machine_has() {
|
||||
eval $invocation
|
||||
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
# 判断系统架构
|
||||
# 输出:arm、arm64、x64
|
||||
get_machine_architecture() {
|
||||
eval $invocation
|
||||
|
||||
if command -v uname >/dev/null; then
|
||||
CPUName=$(uname -m)
|
||||
case $CPUName in
|
||||
armv*l)
|
||||
echo "arm"
|
||||
return 0
|
||||
;;
|
||||
aarch64 | arm64)
|
||||
echo "arm64"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Always default to 'x64'
|
||||
echo "x64"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 获取linux系统名称
|
||||
# 输出:debian.10、debian.11、debian.12、ubuntu.20.04、ubuntu.22.04、alpine.3.4.3...
|
||||
get_linux_platform_name() {
|
||||
eval $invocation
|
||||
|
||||
if [ -e /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
echo "$ID${VERSION_ID:+.${VERSION_ID}}"
|
||||
return 0
|
||||
elif [ -e /etc/redhat-release ]; then
|
||||
local redhatRelease=$(</etc/redhat-release)
|
||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux "*" release 6."* ]]; then
|
||||
echo "rhel.6"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Linux specific platform name and version could not be detected: UName = $uname"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 判断是否为musl(一般指alpine)
|
||||
is_musl_based_distro() {
|
||||
eval $invocation
|
||||
|
||||
(ldd --version 2>&1 || true) | grep -q musl
|
||||
}
|
||||
|
||||
# 获取当前系统名称
|
||||
# 输出:linux、linux-musl、osx、freebsd
|
||||
get_current_os_name() {
|
||||
eval $invocation
|
||||
|
||||
local uname=$(uname)
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
say_warning "当前系统:osx"
|
||||
echo "osx"
|
||||
return 1
|
||||
elif [ "$uname" = "FreeBSD" ]; then
|
||||
say_warning "当前系统:freebsd"
|
||||
echo "freebsd"
|
||||
return 1
|
||||
elif [ "$uname" = "Linux" ]; then
|
||||
local linux_platform_name=""
|
||||
linux_platform_name="$(get_linux_platform_name)" || true
|
||||
say "当前系统发行版本:$linux_platform_name"
|
||||
|
||||
if [ "$linux_platform_name" = "rhel.6" ]; then
|
||||
echo $linux_platform_name
|
||||
return 1
|
||||
elif is_musl_based_distro; then
|
||||
echo "linux-musl"
|
||||
return 0
|
||||
elif [ "$linux_platform_name" = "linux-musl" ]; then
|
||||
echo "linux-musl"
|
||||
return 0
|
||||
else
|
||||
echo "linux"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
say_err "OS name could not be detected: UName = $uname"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 检查操作系统
|
||||
check_os() {
|
||||
eval $invocation
|
||||
|
||||
current_os="$(get_current_os_name)"
|
||||
say "当前系统:$current_os"
|
||||
|
||||
machine_architecture="$(get_machine_architecture)"
|
||||
say "当前架构:$machine_architecture"
|
||||
|
||||
if [ "$current_os" = "linux" ]; then
|
||||
current_linux_os="debian" # 当前青龙只有debian和aplpine两种
|
||||
if ! machine_has curl; then
|
||||
say "curl未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y curl
|
||||
fi
|
||||
else
|
||||
current_linux_os="alpine"
|
||||
if ! machine_has curl; then
|
||||
say "curl未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y curl
|
||||
fi
|
||||
fi
|
||||
|
||||
say "当前选择的运行方式:$prefer_mode"
|
||||
}
|
||||
|
||||
# 检查安装jq
|
||||
check_jq() {
|
||||
if [ "$current_linux_os" = "debian" ]; then
|
||||
if ! machine_has jq; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y jq
|
||||
fi
|
||||
else
|
||||
if ! machine_has jq; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y jq
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查安装unzip
|
||||
check_unzip() {
|
||||
if [ "$current_linux_os" = "debian" ]; then
|
||||
if ! machine_has unzip; then
|
||||
say "unzip未安装,开始安装依赖..."
|
||||
apt-get update
|
||||
apt-get install -y unzip
|
||||
fi
|
||||
else
|
||||
if ! machine_has unzip; then
|
||||
say "jq未安装,开始安装依赖..."
|
||||
apk update
|
||||
apk add -y unzip
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查dotnet
|
||||
check_dotnet() {
|
||||
eval $invocation
|
||||
|
||||
dotnetVersion=$(dotnet --version)
|
||||
say "当前dotnet版本:$dotnetVersion"
|
||||
if [[ $(echo "$dotnetVersion" | grep -oE '^[0-9]+') -ge 8 ]]; then
|
||||
say "已安装,且版本满足"
|
||||
say "which dotnet: $(which dotnet)"
|
||||
return 0
|
||||
else
|
||||
say "未安装"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查bilitool
|
||||
check_bilitool() {
|
||||
eval $invocation
|
||||
|
||||
TAG_FILE="./tag.txt"
|
||||
touch $TAG_FILE
|
||||
local STORED_TAG=$(cat $TAG_FILE 2>/dev/null)
|
||||
|
||||
#如果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
|
||||
say "bilitool已安装"
|
||||
bilitool_installed_version=$STORED_TAG
|
||||
return 0
|
||||
else
|
||||
say "bilitool未安装"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查环境
|
||||
check_installed() {
|
||||
eval $invocation
|
||||
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
check_dotnet
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ "$prefer_mode" == "bilitool" ]; then
|
||||
check_bilitool
|
||||
return $?
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# 使用官方脚本安装dotnet
|
||||
install_dotnet_by_script() {
|
||||
eval $invocation
|
||||
|
||||
say "再尝试使用官方脚本安装"
|
||||
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --verbose
|
||||
|
||||
say "添加到PATH"
|
||||
local exportFile="/root/.bashrc"
|
||||
touch $exportFile
|
||||
echo '' >>$exportFile
|
||||
echo 'export DOTNET_ROOT=$HOME/.dotnet' >>$exportFile
|
||||
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >>$exportFile
|
||||
. $exportFile
|
||||
}
|
||||
|
||||
# 安装dotnet环境
|
||||
install_dotnet() {
|
||||
eval $invocation
|
||||
|
||||
say "开始安装dotnet"
|
||||
say "当前系统:$current_linux_os"
|
||||
if [[ $current_linux_os == "debian" ]]; then
|
||||
say "使用apt安装"
|
||||
|
||||
if ! (curl -s -m 5 www.google.com >/dev/nul); then
|
||||
say "机器位于墙内,切换为包源为国内镜像源"
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
sed -i 's/https:\/\/deb.debian.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
sed -i 's/http:\/\/deb.debian.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
apt-get update
|
||||
fi
|
||||
{
|
||||
. /etc/os-release
|
||||
curl -o packages-microsoft-prod.deb https://packages.microsoft.com/config/debian/$VERSION_ID/packages-microsoft-prod.deb
|
||||
dpkg -i packages-microsoft-prod.deb
|
||||
rm packages-microsoft-prod.deb
|
||||
apt-get update && apt-get install -y dotnet-sdk-8.0
|
||||
} || {
|
||||
install_dotnet_by_script
|
||||
}
|
||||
else
|
||||
say "使用apk安装"
|
||||
if ! (curl -s -m 5 www.google.com >/dev/nul); then
|
||||
say "机器位于墙内,切换为包源为国内镜像源"
|
||||
cp /etc/apk/repositories /etc/apk/repositories.bak
|
||||
sed -i 's/https:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||
sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||
apk update
|
||||
fi
|
||||
{
|
||||
apk add dotnet8-sdk # https://pkgs.alpinelinux.org/packages
|
||||
} || {
|
||||
install_dotnet_by_script
|
||||
}
|
||||
fi
|
||||
dotnet --version && say "which dotnet: $(which dotnet)" && say "安装成功"
|
||||
return $?
|
||||
}
|
||||
|
||||
# 从github获取bilitool下载地址
|
||||
get_download_url() {
|
||||
eval $invocation
|
||||
|
||||
tag=$1
|
||||
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
|
||||
return 0
|
||||
}
|
||||
|
||||
# 安装bilitool
|
||||
install_bilitool() {
|
||||
eval $invocation
|
||||
|
||||
say "开始安装bilitool"
|
||||
# 获取最新的release信息
|
||||
LATEST_RELEASE=$(curl -s https://api.github.com/repos/$bili_repo/releases/latest)
|
||||
|
||||
# 解析最新的tag名称
|
||||
check_jq
|
||||
LATEST_TAG=$(echo $LATEST_RELEASE | jq -r '.tag_name')
|
||||
say "最新版本:$LATEST_TAG"
|
||||
|
||||
# 读取之前存储的tag并比较
|
||||
if [ "$LATEST_TAG" != "$bilitool_installed_version" ]; then
|
||||
# 如果不一样,则需要更新安装
|
||||
ASSET_URL=$(get_download_url $LATEST_TAG)
|
||||
|
||||
# 使用curl下载文件到当前目录下的test.zip文件
|
||||
local zip_file_name="bilitool-$LATEST_TAG.zip"
|
||||
curl -L -o "$zip_file_name" $ASSET_URL
|
||||
|
||||
# 解压
|
||||
check_unzip
|
||||
unzip -jo "$zip_file_name" -d ./ &&
|
||||
rm "$zip_file_name" &&
|
||||
rm -f appsettings.*
|
||||
|
||||
# 更新tag.txt文件
|
||||
echo $LATEST_TAG >./tag.txt
|
||||
else
|
||||
say "已经是最新版本,无需下载。"
|
||||
fi
|
||||
}
|
||||
|
||||
## 安装dotnet(如果未安装过)
|
||||
install() {
|
||||
eval $invocation
|
||||
|
||||
if check_installed; then
|
||||
say "环境正常,本次无需安装"
|
||||
else
|
||||
say "开始安装环境"
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
install_dotnet || {
|
||||
say_err "安装失败"
|
||||
say_err "请根据文档自行在青龙容器中安装dotnet:https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-$current_linux_os"
|
||||
say_err "或者尝试切换运行模式为bilitool,它不需要安装dotnet:https://github.com/RayWangQvQ/BiliBiliToolPro/blob/develop/qinglong/README.md"
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$prefer_mode" == "bilitool" ]; then
|
||||
install_bilitool || {
|
||||
say_err "安装失败,请检查日志并重试"
|
||||
say_err "或者尝试切换运行模式为dotnet:https://github.com/RayWangQvQ/BiliBiliToolPro/blob/develop/qinglong/README.md"
|
||||
}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 运行bilitool任务
|
||||
run_task() {
|
||||
eval $invocation
|
||||
|
||||
local target_code=$1
|
||||
|
||||
export Ray_PlatformType=QingLong
|
||||
export Ray_RunTasks=$target_code
|
||||
|
||||
cd $qinglong_bili_repo_dir/src/Ray.BiliBiliTool.Console
|
||||
|
||||
if [ "$prefer_mode" == "dotnet" ]; then
|
||||
dotnet run --ENVIRONMENT=Production
|
||||
else
|
||||
cp -f $qinglong_bili_repo_dir/bin/Ray.BiliBiliTool.Console .
|
||||
chmod +x ./Ray.BiliBiliTool.Console && ./Ray.BiliBiliTool.Console --ENVIRONMENT=Production
|
||||
fi
|
||||
}
|
||||
|
||||
check_os
|
||||
install
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_charge.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_charge.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 12 * * *
|
||||
# new Env("bili免费B币券充电任务[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Charge"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_daily.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_daily.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:5 9 * * *
|
||||
# new Env('bili每日任务[dev先行版]');
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Daily"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_liveFansMedal.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_liveFansMedal.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:5 0 * * *
|
||||
# new Env("bili直播粉丝牌[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="LiveFansMedal"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_liveLottery.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_liveLottery.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 13 * * *
|
||||
# new Env("bili天选时刻[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="LiveLottery"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_login.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_login.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili扫码登录[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Login"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_manga.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_manga.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 14 * * *
|
||||
# new Env("bili漫画任务[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Manga"
|
||||
run_task "${target_task_code}"
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 15 * * *
|
||||
# new Env("bili领取大会员漫画权益任务[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="MangaPrivilege"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_silver2coin.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_silver2coin.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 8 * * *
|
||||
# new Env("bili银瓜子兑换硬币任务[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Silver2Coin"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_test.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_test.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 8 * * *
|
||||
# new Env("bili测试ck[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="Test"
|
||||
run_task "${target_task_code}"
|
||||
34
qinglong/DefaultTasks/dev/bili_dev_task_tryFix.sh
Normal file
34
qinglong/DefaultTasks/dev/bili_dev_task_tryFix.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 0 1 1 *
|
||||
# new Env("bili尝试修复异常[dev先行版]")
|
||||
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
. /root/.bashrc
|
||||
|
||||
bili_repo="raywangqvq/bilibilitoolpro"
|
||||
bili_branch="_develop"
|
||||
|
||||
echo "青龙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)"
|
||||
echo "bili仓库目录: $qinglong_bili_repo_dir"
|
||||
|
||||
|
||||
echo -e "清理缓存...\n"
|
||||
cd $qinglong_bili_repo_dir
|
||||
find . -type d -name "bin" -exec rm -rf {} +
|
||||
find . -type d -name "obj" -exec rm -rf {} +
|
||||
echo -e "清理完成\n"
|
||||
|
||||
echo "检测dotnet..."
|
||||
dotnetVersion=$(dotnet --version)
|
||||
echo "当前dotnet版本:$dotnetVersion"
|
||||
if [[ $(echo "$dotnetVersion" | grep -oE '^[0-9]+') -ge 8 ]]; then
|
||||
echo "已安装,且版本满足"
|
||||
else
|
||||
echo "which dotnet: $(which dotnet)"
|
||||
echo "Path: $PATH"
|
||||
rm -f /usr/local/bin/dotnet
|
||||
fi
|
||||
echo "检测dotnet结束"
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 12 1 * *
|
||||
# new Env("bili批量取关主播[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="UnfollowBatched"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_vipBigPoint.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_vipBigPoint.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:7 1 * * *
|
||||
# new Env("bili大会员大积分[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="VipBigPoint"
|
||||
run_task "${target_task_code}"
|
||||
8
qinglong/DefaultTasks/dev/bili_dev_task_vip_privilege.sh
Normal file
8
qinglong/DefaultTasks/dev/bili_dev_task_vip_privilege.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# cron:0 1 * * *
|
||||
# new Env("bili领取大会员福利任务[dev先行版]")
|
||||
|
||||
. bili_dev_task_base.sh
|
||||
|
||||
target_task_code="VipPrivilege"
|
||||
run_task "${target_task_code}"
|
||||
210
qinglong/README.md
Normal file
210
qinglong/README.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# 在青龙中运行
|
||||
|
||||
原理是,利用青龙的拉库命令,拉取本仓库源码,自动添加cron定时任务,然后在青龙容器中安装`dotnet`环境或`bilitool`的二进制包,定时运行相应的Task。
|
||||
|
||||
开始前,请先确保你的青龙面板是运行正常的。
|
||||
|
||||
<!-- TOC depthFrom:2 -->
|
||||
|
||||
- [1. 步骤](#1-步骤)
|
||||
- [1.1. 登录青龙面板并修改配置](#11-登录青龙面板并修改配置)
|
||||
- [1.2. 在青龙面板中添加拉库定时任务](#12-在青龙面板中添加拉库定时任务)
|
||||
- [1.2.1. 方式一:订阅管理](#121-方式一订阅管理)
|
||||
- [1.2.2. 方式二:定时任务拉库](#122-方式二定时任务拉库)
|
||||
- [1.3. 检查定时任务](#13-检查定时任务)
|
||||
- [1.4. 配置青龙Client Secret(可选)](#14-配置青龙client-secret可选)
|
||||
- [1.4.1. 新建 Application](#141-新建-application)
|
||||
- [1.4.2. 密钥配置到环境变量](#142-密钥配置到环境变量)
|
||||
- [1.5. Bili登录](#15-bili登录)
|
||||
- [2. 先行版](#2-先行版)
|
||||
- [3. GitHub加速](#3-github加速)
|
||||
- [4. 常见问题](#4-常见问题)
|
||||
- [4.1. 安装dotnet失败怎么办法](#41-安装dotnet失败怎么办法)
|
||||
- [4.2. Couldn't find a valid ICU package installed on the system](#42-couldnt-find-a-valid-icu-package-installed-on-the-system)
|
||||
- [4.3. 提示文件不存在或路径异常,怎么排查](#43-提示文件不存在或路径异常怎么排查)
|
||||
- [4.4. The configured user limit (128) on the number of inotify instances has been reached](#44-the-configured-user-limit-128-on-the-number-of-inotify-instances-has-been-reached)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## 1. 步骤
|
||||
|
||||
### 1.1. 登录青龙面板并修改配置
|
||||
青龙面板,`配置文件`页。
|
||||
|
||||
修改 `RepoFileExtensions="js py"` 为 `RepoFileExtensions="js py sh"`
|
||||
|
||||
保存配置。
|
||||
|
||||
### 1.2. 在青龙面板中添加拉库定时任务
|
||||
|
||||
两种方式,任选其一即可:
|
||||
|
||||
#### 1.2.1. 方式一:订阅管理
|
||||
|
||||
```
|
||||
名称:Bilibili
|
||||
类型:公开仓库
|
||||
链接:https://github.com/RayWangQvQ/BiliBiliToolPro.git
|
||||
定时类型:crontab
|
||||
定时规则:2 2 28 * *
|
||||
白名单:bili_task_.+\.sh
|
||||
文件后缀:sh
|
||||
```
|
||||
|
||||
没提到的不要动。
|
||||
|
||||
保存后,点击运行按钮,运行拉库。
|
||||
|
||||
#### 1.2.2. 方式二:定时任务拉库
|
||||
青龙面板,`定时任务`页,右上角`添加任务`,填入以下信息:
|
||||
|
||||
```
|
||||
名称:拉取Bili库
|
||||
命令:ql repo https://github.com/RayWangQvQ/BiliBiliToolPro.git "bili_task_"
|
||||
定时规则:2 2 28 * *
|
||||
```
|
||||
|
||||
点击确定。
|
||||
|
||||
保存成功后,找到该定时任务,点击运行按钮,运行拉库。
|
||||
|
||||
### 1.3. 检查定时任务
|
||||
|
||||
如果正常,拉库成功后,会自动添加bilibili相关的task任务。
|
||||
|
||||

|
||||
|
||||
### 1.4. 配置青龙Client Secret(可选)
|
||||
|
||||
扫码登录Bili后,需要有权限向青龙的环境变量中持久化Cookie,所以需要添加一个鉴权。
|
||||
|
||||
青龙官方说明:https://qinglong.online/api/preparation
|
||||
|
||||
#### 1.4.1. 新建 Application
|
||||
|
||||
青龙 -> 系统设置 -> 应用设置,点击新建。
|
||||
|
||||

|
||||
|
||||
#### 1.4.2. 密钥配置到环境变量
|
||||
|
||||
将上面2个值添加到环境变量中即可。
|
||||
|
||||
Name分别为:
|
||||
|
||||
- Ray_QingLongConfig__ClientId
|
||||
- Ray_QingLongConfig__ClientSecret
|
||||
|
||||

|
||||
|
||||
|
||||
### 1.5. Bili登录
|
||||
|
||||
在青龙定时任务中,点击运行`bili扫码登录`任务,查看运行日志,扫描日志中的二维码进行登录。
|
||||

|
||||
|
||||
登录成功后,如果已配置了上述的Application,会将cookie保存到青龙的环境变量中:
|
||||
|
||||

|
||||
|
||||
如果未配置Application,会打印出cookie,请手动自己到环境变量中添加。
|
||||
|
||||
首次运行会自动安装环境,时间可能长一点,之后就不需要重复安装了。
|
||||
|
||||
## 2. 先行版
|
||||
|
||||
青龙拉库时可以指定分支,develop分支的代码会超前于默认的main分支,包含当前正在开发的新功能。
|
||||
|
||||
想提前体验新功能,或想要Bug能快速得到解决的朋友,可以尝试切换先行版,但同时也意味着稳定性会相应降低(其实可以忽略不计~🤨)。
|
||||
|
||||
```
|
||||
分支:develop
|
||||
白名单:bili_dev_task_.+\.sh
|
||||
```
|
||||
|
||||
其他选项同上。
|
||||
|
||||
## 3. GitHub加速
|
||||
|
||||
拉库时,如果服务器在国内,访问GitHub速度慢,可在仓库地址前加上加速代理进行加速。
|
||||
|
||||
如:
|
||||
|
||||
```
|
||||
https://github.moeyy.xyz/https://github.com/RayWangQvQ/BiliBiliToolPro.git
|
||||
https://gh-proxy.com/https://github.com/RayWangQvQ/BiliBiliToolPro.git
|
||||
...
|
||||
```
|
||||
|
||||
加速代理地址通常不能保证长期稳定,请自行查找使用。
|
||||
|
||||
## 4. 常见问题
|
||||
|
||||
### 4.1. 安装dotnet失败怎么办法
|
||||
|
||||
首先,青龙有两个版本的镜像:
|
||||
|
||||
- alpine:whyour/qinglong:latest
|
||||
- debian:whyour/qinglong:debian
|
||||
|
||||
安装dotnet失败的情况,几乎全发生在alpine版上。。。
|
||||
|
||||
所以,如果你“执迷不悟”,就是一定要用alpine版,那请先通过日志自行排查,不行就根据微软官方文档,进入qinglong容器后,手动安装。
|
||||
|
||||
如果还不行,那么可以切换到基于`bilitool`的二进制包运行方式,该方式不需要安装`dotnet`,方式:
|
||||
|
||||
编辑青龙面板的`配置文件`,新增如下两行:
|
||||
|
||||
```
|
||||
export BILI_MODE="bilitool" # bili运行模式,dotnet或bilitool
|
||||
export BILI_GITHUB_PROXY="https://github.moeyy.xyz/" # 下载二进制包时使用的加速代理,不要的话则置空
|
||||
```
|
||||
|
||||

|
||||
|
||||
bilitool没有先行版的概念,因为只有main分支才会打包,更新会稍慢一点。
|
||||
|
||||
另外,alpine版的问题,我不建议来提交issue,因为已经大大超出本项目的scope了,建议可以去给alpine官方或微软的dotnet官方提交issue。
|
||||
|
||||
### 4.2. Couldn't find a valid ICU package installed on the system
|
||||
|
||||
如 #266 ,需要在青龙面板的环境变量添加如下环境变量:
|
||||
|
||||
```
|
||||
名称:DOTNET_SYSTEM_GLOBALIZATION_INVARIANT
|
||||
值:1
|
||||
```
|
||||
|
||||
### 4.3. 提示文件不存在或路径异常,怎么排查
|
||||
|
||||
需要`docker exec -it qinglong bash`后,查看几个常用路径:
|
||||
|
||||
```
|
||||
/ql
|
||||
/data
|
||||
/repo
|
||||
/scripts
|
||||
/shell
|
||||
```
|
||||
|
||||
- `/ql/dada/repo`目录下存储了拉库后,bilitool的源代码
|
||||
- `/ql/scripts`目录下存储了bilitool的定时运行脚本
|
||||
- `/ql/shell`目录下是青龙的基础脚本
|
||||
|
||||
请cd到相应目录,查看该目录下文件是否存在,状态是否正常。
|
||||
|
||||
### 4.4. The configured user limit (128) on the number of inotify instances has been reached
|
||||
|
||||
报错:
|
||||
|
||||
```
|
||||
Asp.Net Core - The configured user limit (128) on the number of inotify instances has been reached
|
||||
```
|
||||
|
||||
可以尝试添加如下环境变量解决:
|
||||
|
||||
```
|
||||
DOTNET_USE_POLLING_FILE_WATCHER=1
|
||||
```
|
||||
|
||||
添加后,对配置变更事件的监听,会从监听 Linux 系统的 inotify 事件,变成定时轮询。
|
||||
87
qinglong/bak/bili_dev_task_get_cookie.py.bak
Normal file
87
qinglong/bak/bili_dev_task_get_cookie.py.bak
Normal file
@@ -0,0 +1,87 @@
|
||||
'''
|
||||
1 9 11 11 1 bili_dev_task_get_cookie.py
|
||||
手动运行,查看日志,并使用手机B站app扫描日志中二维码,注意,只能修改第一个cookie
|
||||
如果产生错误,重新运行并用手机扫描二维码
|
||||
有可能识别不出来二维码,我测试了几次都能识别
|
||||
|
||||
默认环境变量存放位置为/ql/data/config/env.sh
|
||||
可以自己通过docker命令进入容器查找这个文件位置。docker exec -it qinglong /bin/bash,进入青龙容器,然后查找一下这个文件位置
|
||||
filename = '../config/env.sh'
|
||||
'''
|
||||
|
||||
import qrcode
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
|
||||
filename = '/ql/data/config/env.sh'
|
||||
|
||||
url_get = 'http://passport.bilibili.com/x/passport-login/web/qrcode/generate'
|
||||
headers = {
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.42"
|
||||
}
|
||||
session = requests.session()
|
||||
response = session.get(url_get, headers=headers)
|
||||
json_data = json.loads(response.text)
|
||||
qr_data = json_data['data']['url']
|
||||
qr_code = json_data['data']['qrcode_key']
|
||||
# print(qr_data)
|
||||
# img = qrcode.make(qr_data)
|
||||
# img.save('../upload/B.png')
|
||||
# 生成二维码,并且打印,只有invert是True手机才能识别,默认的打印识别不出来
|
||||
qr = qrcode.QRCode()
|
||||
qr.add_data(qr_data)
|
||||
qr.print_ascii(invert=True)
|
||||
|
||||
url_get_2 = f'http://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key={qr_code}&source=main_mini'
|
||||
refresh_token = ''
|
||||
# 尝试次数
|
||||
try_time = 8
|
||||
while True:
|
||||
try_time -= 1
|
||||
if not try_time:
|
||||
print('一直没有扫码,退出登录!')
|
||||
exit(1)
|
||||
response = session.get(url_get_2, headers=headers)
|
||||
json_data = json.loads(response.text)
|
||||
response_data_2 = json_data['data']
|
||||
if response_data_2['code'] == 0:
|
||||
try_time += 5
|
||||
refresh_token = response_data_2['refresh_token']
|
||||
print(response_data_2, end='')
|
||||
if response_data_2['message'] == '二维码已失效':
|
||||
print(response_data_2['message'])
|
||||
print('-' * 20)
|
||||
break
|
||||
print(response_data_2['message'])
|
||||
print('-' * 20)
|
||||
time.sleep(5)
|
||||
session.get('https://api.bilibili.com/x/web-interface/nav')
|
||||
cookies = requests.utils.dict_from_cookiejar(session.cookies)
|
||||
lst = []
|
||||
for item in cookies.items():
|
||||
lst.append(f"{item[0]}={item[1]}")
|
||||
|
||||
cookie_str = ';'.join(lst)
|
||||
print('=' * 20)
|
||||
print(cookie_str)
|
||||
print('=' * 20)
|
||||
# 修改环境变量
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
flag = True
|
||||
with open(filename, 'w') as f:
|
||||
for l in lines:
|
||||
if 'Ray_BiliBiliCookies__1' in l:
|
||||
flag = False
|
||||
l = f'export Ray_BiliBiliCookies__1="{cookie_str}"\n'
|
||||
print(l)
|
||||
f.write(l)
|
||||
if flag:
|
||||
flag = False
|
||||
l = f'export Ray_BiliBiliCookies__1="{cookie_str}"\n'
|
||||
print(l)
|
||||
f.write(l)
|
||||
os.popen(f'source {filename}')
|
||||
87
qinglong/bak/bili_task_get_cookie.py.bak
Normal file
87
qinglong/bak/bili_task_get_cookie.py.bak
Normal file
@@ -0,0 +1,87 @@
|
||||
'''
|
||||
1 9 11 11 1 bili_task_get_cookie.py
|
||||
手动运行,查看日志,并使用手机B站app扫描日志中二维码,注意,只能修改第一个cookie
|
||||
如果产生错误,重新运行并用手机扫描二维码
|
||||
有可能识别不出来二维码,我测试了几次都能识别
|
||||
|
||||
默认环境变量存放位置为/ql/data/config/env.sh
|
||||
可以自己通过docker命令进入容器查找这个文件位置。docker exec -it qinglong /bin/bash,进入青龙容器,然后查找一下这个文件位置
|
||||
filename = '../config/env.sh'
|
||||
'''
|
||||
|
||||
import qrcode
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
|
||||
filename = '/ql/data/config/env.sh'
|
||||
|
||||
url_get = 'http://passport.bilibili.com/x/passport-login/web/qrcode/generate'
|
||||
headers = {
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.42"
|
||||
}
|
||||
session = requests.session()
|
||||
response = session.get(url_get, headers=headers)
|
||||
json_data = json.loads(response.text)
|
||||
qr_data = json_data['data']['url']
|
||||
qr_code = json_data['data']['qrcode_key']
|
||||
# print(qr_data)
|
||||
# img = qrcode.make(qr_data)
|
||||
# img.save('../upload/B.png')
|
||||
# 生成二维码,并且打印,只有invert是True手机才能识别,默认的打印识别不出来
|
||||
qr = qrcode.QRCode()
|
||||
qr.add_data(qr_data)
|
||||
qr.print_ascii(invert=True)
|
||||
|
||||
url_get_2 = f'http://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key={qr_code}&source=main_mini'
|
||||
refresh_token = ''
|
||||
# 尝试次数
|
||||
try_time = 8
|
||||
while True:
|
||||
try_time -= 1
|
||||
if not try_time:
|
||||
print('一直没有扫码,退出登录!')
|
||||
exit(1)
|
||||
response = session.get(url_get_2, headers=headers)
|
||||
json_data = json.loads(response.text)
|
||||
response_data_2 = json_data['data']
|
||||
if response_data_2['code'] == 0:
|
||||
try_time += 5
|
||||
refresh_token = response_data_2['refresh_token']
|
||||
print(response_data_2, end='')
|
||||
if response_data_2['message'] == '二维码已失效':
|
||||
print(response_data_2['message'])
|
||||
print('-' * 20)
|
||||
break
|
||||
print(response_data_2['message'])
|
||||
print('-' * 20)
|
||||
time.sleep(5)
|
||||
session.get('https://api.bilibili.com/x/web-interface/nav')
|
||||
cookies = requests.utils.dict_from_cookiejar(session.cookies)
|
||||
lst = []
|
||||
for item in cookies.items():
|
||||
lst.append(f"{item[0]}={item[1]}")
|
||||
|
||||
cookie_str = ';'.join(lst)
|
||||
print('=' * 20)
|
||||
print(cookie_str)
|
||||
print('=' * 20)
|
||||
# 修改环境变量
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
flag = True
|
||||
with open(filename, 'w') as f:
|
||||
for l in lines:
|
||||
if 'Ray_BiliBiliCookies__1' in l:
|
||||
flag = False
|
||||
l = f'export Ray_BiliBiliCookies__1="{cookie_str}"\n'
|
||||
print(l)
|
||||
f.write(l)
|
||||
if flag:
|
||||
flag = False
|
||||
l = f'export Ray_BiliBiliCookies__1="{cookie_str}"\n'
|
||||
print(l)
|
||||
f.write(l)
|
||||
os.popen(f'source {filename}')
|
||||
1656
qinglong/dotnet-install.sh
vendored
Normal file
1656
qinglong/dotnet-install.sh
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
qinglong/extra.sh
Normal file
8
qinglong/extra.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
## 添加你需要重启自动执行的任意命令,比如 ql repo
|
||||
## 安装node依赖使用 pnpm install -g xxx xxx
|
||||
## 安装python依赖使用 pip3 install xxx
|
||||
|
||||
# 安装 dotnet 环境
|
||||
# dotnet --version || (curl -sSL https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/qinglong/ray-dotnet-install.sh | bash /dev/stdin --no-official) && (echo "已安装dotnet")
|
||||
dotnet --version || (curl -sSL https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/qinglong/ray-dotnet-install.sh | bash /dev/stdin) && (echo "已安装dotnet")
|
||||
# 其他代码...
|
||||
43
qinglong/ray-dotnet-install.sh
Normal file
43
qinglong/ray-dotnet-install.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
echo -e "\n-------set up dot net env-------"
|
||||
|
||||
## 安装dotnet
|
||||
|
||||
# 安装依赖
|
||||
install_dependency() {
|
||||
echo "安装依赖..."
|
||||
apk add bash icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
|
||||
}
|
||||
|
||||
# 通过官方脚本安装dotnet
|
||||
install_by_offical() {
|
||||
echo "install by offical script..."
|
||||
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --no-cdn --verbose
|
||||
}
|
||||
|
||||
# 创建软链接
|
||||
create_soft_link() {
|
||||
# echo "创建软链接..."
|
||||
# rm -f /usr/bin/dotnet
|
||||
# ln -s ~/.dotnet/dotnet /usr/bin/dotnet
|
||||
|
||||
echo "添加PATH"
|
||||
local exportFile="/root/.bashrc"
|
||||
touch $exportFile
|
||||
echo '' >> $exportFile
|
||||
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> $exportFile
|
||||
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> $exportFile
|
||||
. $exportFile
|
||||
}
|
||||
|
||||
args=("$@")
|
||||
|
||||
install_dependency
|
||||
|
||||
install_by_offical
|
||||
|
||||
create_soft_link
|
||||
|
||||
dotnet --info
|
||||
|
||||
echo -e "\n-------set up dot net env finish-------"
|
||||
Reference in New Issue
Block a user