Skip to content

Commit

Permalink
Merge pull request #116 from monlor/test
Browse files Browse the repository at this point in the history
feat: 🎸 更新脚本支持更新env
  • Loading branch information
monlor authored Jun 14, 2024
2 parents f7d2953 + 580ffd0 commit 782c476
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion alist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ docker run -d -p 5678:80 -p 2345:2345 -p 2346:2346 --restart=unless-stopped --na

`EMBY_APIKEY`: 填入一个emby的api key,用于在infuse中播放emby

`AUTO_UPDATE_ENABLED`: 自动更新小雅的文件,true/false,默认false
`AUTO_UPDATE_ENABLED`: 每天自动更新小雅的文件,true/false,默认false

`AUTO_CLEAR_ENABLED`: 自动清理阿里云云盘的文件,true/false,默认false

Expand Down
4 changes: 2 additions & 2 deletions env
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ JELLYFIN_ENABLED=false
AUTO_UPDATE_EMBY_CONFIG_ENABLED=true
# 自动更新emby配置,config.mp4间隔,单位天,默认7天
AUTO_UPDATE_EMBY_INTERVAL=
# 自动更新元数据
AUTO_UPDATE_METADATA_ENABLED=true
# 自动更新emby元数据
AUTO_UPDATE_EMBY_METADATA_ENABLED=true
# emby的apikey
EMBY_APIKEY=
2 changes: 1 addition & 1 deletion helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ releases:
EMBY_ENABLED: true
JELLYFIN_ENABLED: false
AUTO_UPDATE_EMBY_CONFIG_ENABLED: true
AUTO_UPDATE_METADATA_ENABLED: true
AUTO_UPDATE_EMBY_METADATA_ENABLED: true
volumes:
- name: data
mountPath: /etc/xiaoya
Expand Down
35 changes: 25 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,30 @@ read -rp "请输入服务部署目录(默认/opt/xiaoya): " install_path
install_path=${install_path:=/opt/xiaoya}

# 检查服务是否已经运行
update=0
if [ -f "$install_path/docker-compose.yml" ]; then
# 询问用户是否要更新服务
echo
echo "检查到服务已存在,更新会覆盖docker-compose.yml文件,不会覆盖env文件"
read -rp "是否更新服务?(y/n): " update
if [ "${update}" != "y" ]; then
echo "退出安装"
exit 1
fi
cat <<-EOF
更新方式:
1. 全部更新,会覆盖更新docker-compose.yml和env配置
2. 部分更新,仅覆盖更新docker-compose.yml
3. 退出脚本,不更新
EOF
read -rp "请选择更新方式(默认为1): " update
update=${update:-1}
case $update in
1|2)
# 备份
cp -rf "$install_path/env" "$install_path/env.bak"
cp -rf "$install_path/docker-compose.yml" "$install_path/docker-compose.yml.bak"
;;
*)
echo "退出安装"
exit 1
;;
esac

fi

DOCKER_HOME="$(docker info | grep "Docker Root Dir" | awk -F ':' '{print$2}')"
Expand All @@ -99,7 +114,7 @@ if [ -d "$install_path/data" ]; then
fi
cat <<-EOF
请选择数据保存位置
数据保存位置
1. Docker卷(数据保存在: ${DOCKER_HOME}/volumes)
2. 服务部署目录(数据保存在: ${install_path}
EOF
Expand All @@ -111,7 +126,7 @@ open_token=""
folder_id=""

# 如果是更新服务,则从原有的compose配置中获取token等信息
if [ "${update:-}" = "y" ]; then
if [ "${update}" != "0" ]; then
token=$(grep ALIYUN_TOKEN "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}')
open_token=$(grep ALIYUN_OPEN_TOKEN "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}')
folder_id=$(grep ALIYUN_FOLDER_ID "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}')
Expand Down Expand Up @@ -183,7 +198,7 @@ cd "$install_path"

echo "开始生成配置文件docker-compose${service_type}.yml..."
curl -#Lo "$install_path/docker-compose.yml" "${DOWNLOAD_URL}/docker-compose${service_type}.yml"
if [ ! -f "$install_path/env" ]; then
if [ "${update}" != "2" ]; then
curl -#Lo "$install_path/env" "${DOWNLOAD_URL}/env"
fi
sedsh "s#ALIYUN_TOKEN=.*#ALIYUN_TOKEN=$token#g" env
Expand Down
2 changes: 1 addition & 1 deletion metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

`AUTO_UPDATE_EMBY_INTERVAL`: 自动更新emby配置间隔,默认7,单位天

`AUTO_UPDATE_METADATA_ENABLED`: 自动更新每日元数据,你们所说的爬虫,true/false,默认false
`AUTO_UPDATE_EMBY_METADATA_ENABLED`: 每天自动更新emby元数据,你们所说的爬虫,true/false,默认false

`EMBY_APIKEY`: emby api 密钥,建议修改emby的api密钥,设置此变量,用于定期同步emby配置

Expand Down
12 changes: 6 additions & 6 deletions metadata/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ disk_check() {

download_meta() {
file=$1
path=$2
echo "Downloading ${file}..."
# 检查历史文件,如果存在残留则删除
if [ -f "${MEDIA_DIR}/temp/${file}.aria2" ]; then
Expand All @@ -61,7 +60,8 @@ download_meta() {
success=false
for i in {1..5}; do
echo "Downloading ${file}, try ${i}..."
if aria2c -o "${file}" --allow-overwrite=true --auto-file-renaming=false --enable-color=false -c -x6 "${ALIST_ADDR}/d/元数据/${path}${file}"; then
echo "Link is ${ALIST_ADDR}/d/元数据/${file}"
if aria2c -o "${file}" --allow-overwrite=true --auto-file-renaming=false --enable-color=false -c -x6 "${ALIST_ADDR}/d/元数据/${file}"; then
# 下载的文件小于10M,下载失败,删除
if [ "$(stat -c %s "${file}")" -lt 10000000 ]; then
echo "Download ${file} failed, file size less than 10M, retry after 10 seconds."
Expand Down Expand Up @@ -149,7 +149,7 @@ download_jellyfin_config() {
echo "Downloading Jellyfin config..."

cd ${MEDIA_DIR}/temp
download_meta config_jf.mp4 Jellyfin/
download_meta Jellyfin/config_jf.mp4

echo "Extracting Jellyfin config..."

Expand All @@ -174,8 +174,8 @@ download_jellyfin_media() {
echo "Downloading Jellyfin media..."

cd "${MEDIA_DIR}/temp"
download_meta all_jf.mp4 Jellyfin/
download_meta PikPak_jf.mp4 Jellyfin/
download_meta Jellyfin/all_jf.mp4
download_meta Jellyfin/PikPak_jf.mp4

echo "Extracting Jellyfin media..."

Expand Down Expand Up @@ -203,7 +203,7 @@ if [ "${EMBY_ENABLED:=false}" = "true" ]; then
crontabs="${crontabs}\n${random_min} ${random_hour} */${AUTO_UPDATE_EMBY_INTERVAL:=7} * * /emby.sh update"
fi

if [ "${AUTO_UPDATE_METADATA_ENABLED:=false}" = "true" ]; then
if [ "${AUTO_UPDATE_EMBY_METADATA_ENABLED:=false}" = "true" ]; then
echo "启动定时更新Emby媒体数据任务..."
# 随机生成一个时间,避免给服务器造成压力
random_min=$(shuf -i 0-59 -n 1)
Expand Down

0 comments on commit 782c476

Please sign in to comment.