Skip to content

Commit

Permalink
feat: 🎸 重构xiaoya
Browse files Browse the repository at this point in the history
  • Loading branch information
monlor committed May 28, 2024
1 parent 0df4e38 commit 1abe4d7
Show file tree
Hide file tree
Showing 4 changed files with 4,928 additions and 18 deletions.
18 changes: 14 additions & 4 deletions xiaoya/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
FROM xiaoyaliu/alist:latest
FROM docker:dind

LABEL MAINTAINER [email protected]
LABEL VERSION 1.0.0
LABEL VERSION 2.0.0

EXPOSE 80 2345 2346
EXPOSE 5678 2345 2346

VOLUME /data
VOLUME /etc/xiaoya /opt/media

RUN apk add --no-cache curl bash tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata && \
rm -rf /var/cache/apk/*

COPY ./xiaoya.sh /usr/local/bin/xiaoya.sh

COPY ./start.sh /start.sh

RUN chmod +x /usr/local/bin/xiaoya.sh /start.sh

ENTRYPOINT [ "bash", "/start.sh" ]

CMD []
8 changes: 7 additions & 1 deletion xiaoya/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ docker run -d -p 5678:80 -p 2345:2345 -p 2346:2346 --restart=unless-stopped --na

`ALIYUN_FOLDER_ID`: 阿里云小雅文件夹id,转存以下文件到你的云盘,获取文件夹id,共享链接:https://www.aliyundrive.com/s/rP9gP3h9asE

`CRONTAB_ENABLE`: 是否开启定时更新数据的任务,true/false
`EMBY_ENABLE`: 安装emby,需要下载元数据,准备100G

`JELLYFIN_ENABLE`: 安装jellyfin,需要下载元数据,准备100G

## 参考

https://raw.githubusercontent.com/DDS-Derek/xiaoya-alist/master/all_in_one.sh
75 changes: 62 additions & 13 deletions xiaoya/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,95 @@

set -eu

dockerd-entrypoint.sh &

# Wait for docker to start
while ! docker info &>/dev/null; do
sleep 1
done

# Start the main process

# Generate the config file
echo "开始生成配置文件..."

if [ ! -d "/data" ]; then
mkdir /data
DATA_DIR="/etc/xiaoya"
MEDIA_DIR="/opt/media"
RESILIO_DIR="/opt/media/resilio"

if [ ! -d "${DATA_DIR}" ]; then
mkdir -p ${DATA_DIR}
fi

# 生成配置,阿里云token
if [ ${#ALIYUN_TOKEN} -ne 32 ]; then
echo "长度不对,阿里云盘 Token是32位长"
echo -e "启动停止,请参考指南配置文件\nhttps://alist.nn.ci/zh/guide/drivers/aliyundrive.html \n"
exit
else
echo "添加阿里云盘 Token..."
echo "${ALIYUN_TOKEN}" > /data/mytoken.txt
echo "${ALIYUN_TOKEN}" > ${DATA_DIR}/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
else
echo "添加阿里云盘 Open Token..."
echo "${ALIYUN_OPEN_TOKEN}" > /data/myopentoken.txt
echo "${ALIYUN_OPEN_TOKEN}" > ${DATA_DIR}/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
else
echo "添加阿里云盘 folder_id..."
echo "${ALIYUN_FOLDER_ID}" > /data/temp_transfer_folder_id.txt
echo "${ALIYUN_FOLDER_ID}" > ${DATA_DIR}/temp_transfer_folder_id.txt
fi

# Generate DDSRem config file
if [ ! -d "/etc/DDSRem" ]; then
mkdir -p /etc/DDSRem
fi

echo "${DATA_DIR}" > /etc/DDSRem/xiaoya_alist_config_dir.txt
echo "${MEDIA_DIR}" > /etc/DDSRem/xiaoya_alist_media_dir.txt
echo "${RESILIO_DIR}" > /etc/DDSRem/resilio_config_dir.txt

# Install xiaoya alist
echo "开始安装 Alist..."

if ! docker ps | grep "xiaoya "; then
echo "开始安装 xiaoya..."
xiaoya.sh install_alist
fi

if ! docker ps | grep xiaoyakeeper; then
echo "开始安装 Keeper..."
xiaoya.sh install_xiaoyahelper
fi

if [ "${CRONTAB_ENABLE:=false}" = "true" ]; then
echo "启动定时任务..."
echo "0 3 * * * /updateall " | crontab -
crond
if [ "${EMBY_ENABLE:=false}" = "true" ]; then
echo "已启用 Emby..."
if [ ! -f "/opt/media/temp/all.mp4" ]; then
echo "下载并解压元数据..."
xiaoya.sh download_unzip_xiaoya_all_emby
fi
if ! docker ps | grep emby; then
echo "开始安装 Emby..."
xiaoya.sh install_emby
fi
fi

exec /entrypoint.sh /opt/alist/alist server --no-prefix
if [ "${JELLYFIN_ENABLE:=false}" = "true" ]; then
echo "已启用 Jellyfin..."
if [ ! -f "/opt/media/temp/all_jf.mp4" ]; then
echo "下载并解压元数据..."
xiaoya.sh download_unzip_xiaoya_all_jellyfin
fi
if ! docker ps | grep jellyfin; then
echo "开始安装 Jellyfin..."
xiaoya.sh install_jellyfin
fi
fi
Loading

0 comments on commit 1abe4d7

Please sign in to comment.