-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b2fa386
Showing
19 changed files
with
857 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Build and Push Docker Images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract version from tag | ||
id: vars | ||
run: | | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Build and push xiaoya-alist | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./alist | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-alist:latest | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-alist:${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Build and push xiaoya-glue | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./glue | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-glue:latest | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-glue:${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Build and push xiaoya-emby | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./emby | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-emby:latest | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-emby:${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Build and push xiaoya-jellyfin | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./jellyfin | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-jellyfin:latest | ||
ghcr.io/${{ github.repository_owner }}/xiaoya-jellyfin:${{ env.VERSION }} | ||
platforms: linux/amd64,linux/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## 小雅影视库部署增强版 | ||
|
||
所有脚本集成到 Docker 镜像,避免污染系统环境 | ||
|
||
使用 Docker Compose 一键部署服务 | ||
|
||
## 部署 | ||
|
||
根据你的需求修改配置文件 docker-compose.yml,默认部署alist+emby+jellyfin | ||
|
||
小雅alist的环境变量配置看[这里](/alist) | ||
|
||
```bash | ||
docker compose up -d | ||
``` | ||
|
||
## 配置示例 | ||
|
||
1. [只部署小雅alist](/docker-compose-alist.yml) | ||
2. [部署小雅alist+emby](/docker-compose-emby.yml) | ||
2. [部署小雅alist+jellyfin](/docker-compose-jellyfin.yml) | ||
|
||
## 参考 | ||
|
||
https://hub.docker.com/r/amilys/embyserver | ||
https://github.com/DDS-Derek/xiaoya-alist/blob/master/all_in_one.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM xiaoyaliu/alist:latest | ||
|
||
LABEL MAINTAINER [email protected] | ||
LABEL VERSION 1.1.0 | ||
|
||
EXPOSE 80 2345 2346 | ||
|
||
VOLUME /data | ||
|
||
COPY ./start.sh /start.sh | ||
COPY ./clear.sh /clear.sh | ||
|
||
RUN chmod +x /start.sh /clear.sh | ||
|
||
ENTRYPOINT [ "/start.sh" ] | ||
|
||
CMD [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## 小雅影视库 | ||
|
||
简化部署逻辑,来源:https://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f | ||
|
||
## 启动命令 | ||
|
||
``` | ||
docker run -d -p 5678:80 -p 2345:2345 -p 2346:2346 --restart=unless-stopped --name=xiaoya monlor/xiaoya-alist:latest | ||
``` | ||
|
||
## 环境变量 | ||
|
||
`ALIYUN_TOKEN`: 阿里云token https://alist.nn.ci/zh/guide/drivers/aliyundrive.html | ||
|
||
`ALIYUN_OPEN_TOKEN`: 阿里云 open-token https://alist.nn.ci/zh/guide/drivers/aliyundrive_open.html | ||
|
||
`ALIYUN_FOLDER_ID`: 阿里云小雅文件夹id,转存以下文件到你的云盘,获取文件夹id,共享链接:https://www.aliyundrive.com/s/rP9gP3h9asE | ||
|
||
`AUTO_UPDATE_ENABLED`: 自动更新小雅的文件,true/false | ||
|
||
`AUTO_CLEAR_ENABLED`: 自动清理阿里云云盘的文件,true/false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
#!/bin/bash | ||
|
||
DATA_DIR=/data | ||
|
||
retry_command() { | ||
# 重试次数和最大重试次数 | ||
retries=0 | ||
max_retries=10 | ||
local cmd="$1" | ||
local success=false | ||
local output="" | ||
|
||
while ! $success && [ $retries -lt $max_retries ]; do | ||
output=$(eval "$cmd" 2>&1) | ||
if [ $? -eq 0 ]; then | ||
success=true | ||
else | ||
retries=$(($retries + 1)) | ||
echo "#Failed to execute command \"$(echo "$cmd" | awk '{print $1}')\", retrying in 1 seconds (retry $retries of $max_retries)..." >&2 | ||
sleep 1 | ||
fi | ||
done | ||
|
||
if $success; then | ||
echo "$output" | ||
return 0 | ||
else | ||
echo "#Failed to execute command after $max_retries retries: $cmd" >&2 | ||
echo "#Command output: $output" >&2 | ||
return 1 | ||
fi | ||
} | ||
|
||
get_Header() { | ||
response=$(curl --connect-timeout 5 -m 5 -s -H "Content-Type: application/json" \ | ||
-d '{"grant_type":"refresh_token", "refresh_token":"'$refresh_token'"}' \ | ||
https://api.aliyundrive.com/v2/account/token) | ||
|
||
access_token=$(echo "$response" | sed -n 's/.*"access_token":"\([^"]*\).*/\1/p') | ||
|
||
HEADER="Authorization: Bearer $access_token" | ||
if [ -z "$HEADER" ]; then | ||
echo "获取access token失败" >&2 | ||
return 1 | ||
fi | ||
|
||
response="$(curl --connect-timeout 5 -m 5 -s -H "$HEADER" -H "Content-Type: application/json" -X POST -d '{}' "https://user.aliyundrive.com/v2/user/get")" | ||
|
||
lagacy_drive_id=$(echo "$response" | sed -n 's/.*"default_drive_id":"\([^"]*\).*/\1/p') | ||
|
||
drive_id=$(echo "$response" | sed -n 's/.*"resource_drive_id":"\([^"]*\).*/\1/p') | ||
|
||
if [ -z "$drive_id" ]; then | ||
drive_id=$lagacy_drive_id | ||
fi | ||
|
||
if [ "$folder_type"x = "b"x ]; then | ||
drive_id=$lagacy_drive_id | ||
fi | ||
|
||
if [ -z "$drive_id" ]; then | ||
echo "获取drive_id失败" >&2 | ||
return 1 | ||
fi | ||
|
||
echo "HEADER=\"$HEADER\"" | ||
echo "drive_id=\"$drive_id\"" | ||
return 0 | ||
} | ||
|
||
get_rawList() { | ||
waittime=10 | ||
if [ -n "$1" ]; then | ||
waittime="$1" | ||
fi | ||
_res=$(curl --connect-timeout 5 -m 5 -s -H "$HEADER" -H "Content-Type: application/json" -X POST -d '{"drive_id": "'$drive_id'","parent_file_id": "'$file_id'"}' "https://api.aliyundrive.com/adrive/v2/file/list") | ||
if [ ! $? -eq 0 ] || [ -z "$(echo "$_res" | grep "items")" ]; then | ||
echo "获取文件列表失败:folder_id=$file_id,drive_id=$drive_id" >&2 | ||
return 1 | ||
fi | ||
echo "$_res" | ||
#简单规避小雅转存后还没来得及获取直链就被删除的问题,降低发生概率 | ||
sleep "$waittime" | ||
return 0 | ||
} | ||
|
||
get_Path() { | ||
_path="$(curl --connect-timeout 5 -m 5 -s -H "$HEADER" -H "Content-Type: application/json" -X POST -d "{\"drive_id\": \"$drive_id\", \"file_id\": \"$file_id\"}" "https://api.aliyundrive.com/adrive/v1/file/get_path" | grep -o "\"name\":\"[^\"]*\"" | cut -d':' -f2- | tr -d '"' | tr '\n' '/' | awk -F'/' '{for(i=NF-1;i>0;i--){printf("/%s",$i)}; printf("%s\n",$NF)}')" | ||
if [ -z "$_path" ]; then | ||
return 1 | ||
fi | ||
echo "$_path" | ||
return 0 | ||
} | ||
|
||
get_List() { | ||
_res=$raw_list | ||
|
||
#echo "$_res" | tr '{' '\n' | grep -v "folder" | grep -o "\"file_id\":\"[^\"]*\"" | cut -d':' -f2- | tr -d '"' | ||
echo "$_res" | tr '{' '\n' | grep -o "\"file_id\":\"[^\"]*\"" | cut -d':' -f2- | tr -d '"' | ||
return 0 | ||
} | ||
|
||
delete_File() { | ||
_file_id=$1 | ||
_name="$(echo "$raw_list" | grep -o "\"name\":\"[^\"]*\"" | cut -d':' -f2- | tr -d '"' | grep -n . | grep "^$(echo "$raw_list" | grep -o "\"file_id\":\"[^\"]*\"" | cut -d':' -f2- | tr -d '"' | grep -n . | grep "$_file_id" | awk -F: '{print $1}'):" | awk -F: '{print $2}')" | ||
|
||
_res=$(curl --connect-timeout 5 -m 5 -s -H "$HEADER" -H "Content-Type: application/json" -X POST -d '{ | ||
"requests": [ | ||
{ | ||
"body": { | ||
"drive_id": "'$drive_id'", | ||
"file_id": "'$_file_id'" | ||
}, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"id": "'$_file_id'", | ||
"method": "POST", | ||
"url": "/file/delete" | ||
} | ||
], | ||
"resource": "file" | ||
}' "https://api.aliyundrive.com/v3/batch" | grep "\"status\":204") | ||
if [ -z "$_res" ]; then | ||
return 1 | ||
fi | ||
|
||
drive_root="资源盘" | ||
if [ "$folder_type"x = "b"x ]; then | ||
drive_root="备份盘" | ||
fi | ||
|
||
myecho "彻底删除文件:/$drive_root$path/$_name" | ||
|
||
return 0 | ||
} | ||
|
||
_clear_aliyun() { | ||
#eval "$(retry_command "get_Header")" | ||
raw_list=$(retry_command "get_rawList") | ||
path=$(retry_command "get_Path") | ||
_list="$(get_List)" | ||
echo "$_list" | sed '/^$/d' | while read line; do | ||
retry_command "delete_File \"$line\"" | ||
done | ||
return "$(echo "$_list" | sed '/^$/d' | wc -l)" | ||
} | ||
|
||
|
||
clear_aliyun() { | ||
eval "$(retry_command "get_Header")" | ||
raw_list=$(retry_command "get_rawList 0") | ||
_list="$(get_List)" | ||
if [ -z "$(echo "$_list" | sed '/^$/d')" ]; then | ||
return 0 | ||
fi | ||
|
||
myecho -e "\n[$(date '+%Y/%m/%d %H:%M:%S')]开始清理小雅$XIAOYA_NAME转存" | ||
|
||
_res=1 | ||
_filenum=0 | ||
while [ ! $_res -eq 0 ]; do | ||
_clear_aliyun | ||
_res=$? | ||
_filenum=$(($_filenum + $_res)) | ||
done | ||
|
||
myecho "本次共清理小雅$XIAOYA_NAME转存文件$_filenum个" | ||
|
||
} | ||
|
||
init_para() { | ||
XIAOYA_NAME="alist" | ||
refresh_token="$(cat "${DATA_DIR}/mytoken.txt" | head -n1)" | ||
|
||
file_id=$(cat "${DATA_DIR}/temp_transfer_folder_id.txt") | ||
|
||
folder_type=$(cat "${DATA_DIR}/folder_type.txt") | ||
|
||
} | ||
|
||
init_para | ||
clear_aliyun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
echo "开始生成配置文件..." | ||
|
||
if [ ! -d "/data" ]; then | ||
mkdir /data | ||
fi | ||
|
||
# 生成配置,阿里云token | ||
if [ ${#ALIYUN_TOKEN} -ne 32 ]; then | ||
echo "长度不对,阿里云盘 Token是32位长" | ||
echo -e "启动停止,请参考指南配置文件\nhttps://alist.nn.ci/zh/guide/drivers/aliyundrive.html \n" | ||
exit 1 | ||
else | ||
echo "添加阿里云盘 Token..." | ||
echo "${ALIYUN_TOKEN}" > /data/mytoken.txt | ||
fi | ||
|
||
# 生成配置,阿里云open token | ||
if [[ ${#ALIYUN_OPEN_TOKEN} -le 334 ]]; then | ||
echo "长度不对,阿里云盘 Open Token是335位" | ||
echo -e "安装停止,请参考指南配置文件\nhttps://alist.nn.ci/zh/guide/drivers/aliyundrive_open.html \n" | ||
exit 1 | ||
else | ||
echo "添加阿里云盘 Open Token..." | ||
echo "${ALIYUN_OPEN_TOKEN}" > /data/myopentoken.txt | ||
fi | ||
|
||
# 生成配置,阿里云转存目录folder_id | ||
if [ ${#ALIYUN_FOLDER_ID} -ne 40 ]; then | ||
echo "长度不对,阿里云盘 folder id是40位长" | ||
echo -e "安装停止,请转存以下目录到你的网盘,并获取该文件夹的folder_id\nhttps://www.aliyundrive.com/s/rP9gP3h9asE \n" | ||
exit 1 | ||
else | ||
echo "添加阿里云盘 folder_id..." | ||
echo "${ALIYUN_FOLDER_ID}" > /data/temp_transfer_folder_id.txt | ||
fi | ||
|
||
crond | ||
|
||
if [ "${AUTO_UPDATE_ENABLED:=false}" = "true" ]; then | ||
echo "启动定时更新定时任务..." | ||
echo "0 3 * * * /updateall " | crontab - | ||
fi | ||
|
||
if [ "${AUTO_CLEAR_ENABLED:=false}" = "true" ]; then | ||
echo "启动定时清理定时任务..." | ||
echo "*/1 * * * * /clear.sh " | crontab - | ||
fi | ||
|
||
echo "e825ed6f7f8f44ffa0563cddaddce14d" > /data/infuse_api_key.txt | ||
|
||
exec /entrypoint.sh /opt/alist/alist server --no-prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
|
||
docker build -t monlor/xiaoya-alist alist | ||
|
||
docker build -t monlor/xiaoya-glue glue | ||
|
||
docker build -t monlor/xiaoya-emby emby | ||
|
||
docker build -t monlor/xiaoya-jellyfin jellyfin |
Oops, something went wrong.