Skip to content

Commit

Permalink
Merge pull request #108 from monlor/test
Browse files Browse the repository at this point in the history
monlor authored Jun 13, 2024
2 parents 362cef0 + 49ee9ad commit e7721a2
Showing 7 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion alist/Dockerfile
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ ADD --chmod=755 https://raw.githubusercontent.com/monlor/docker-xiaoya/main/bin/

COPY --chmod=755 ./*.sh /

RUN /data.sh download
RUN /service.sh download

ENTRYPOINT [ "/dumb-init", "--", "/start.sh" ]

35 changes: 32 additions & 3 deletions alist/data.sh → alist/service.sh
Original file line number Diff line number Diff line change
@@ -63,18 +63,35 @@ download_files() {
fi
}

restart_service() {
start() {
/entrypoint.sh /opt/alist/alist server --no-prefix &
}

stop() {
kill -15 $(pgrep -f 'nginx|httpd|alist')
}

restart() {
stop
sleep 10
/entrypoint.sh /opt/alist/alist server --no-prefix &
start
}

update() {
if ! download_files; then
echo "Failed to download files or no need to update"
return 1
fi
restart_service
restart
}

# 进程守护函数
daemon() {

if [ -z "$(pgrep alist)" ]; then
start
fi

}

case "$1" in
@@ -84,6 +101,18 @@ case "$1" in
download)
download_files
;;
start)
start
;;
stop)
stop
;;
restart)
restart
;;
daemon)
daemon
;;
*)
echo "Usage: $0 {update|download}"
exit 1
5 changes: 4 additions & 1 deletion alist/start.sh
Original file line number Diff line number Diff line change
@@ -143,14 +143,17 @@ if [ "${AUTO_UPDATE_ENABLED:=false}" = "true" ]; then
# 随机生成一个时间,避免给服务器造成压力
random_min=$(shuf -i 0-59 -n 1)
random_hour=$(shuf -i 2-6 -n 1)
crontabs="${random_min} ${random_hour} * * * /data.sh update"
crontabs="${random_min} ${random_hour} * * * /service.sh update"
fi

if [ "${AUTO_CLEAR_ENABLED:=false}" = "true" ]; then
echo "启动定时清理定时任务..."
crontabs="${crontabs}\n*/${AUTO_CLEAR_INTERVAL:=10} * * * * /clear.sh"
fi

# 添加后台守护
crontabs="${crontabs}\n* * * * * /service.sh daemon"

if [ -n "${crontabs}" ]; then
echo -e "$crontabs" | crontab -
fi
12 changes: 7 additions & 5 deletions emby/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

echo "等待alist启动完成..."
while ! wget -q -T 1 -O /dev/null "${ALIST_ADDR:=http://alist:5678}" > /dev/null 2>&1; do
ALIST_ADDR=${ALIST_ADDR:-http://alist:5678}

echo "检查alist连通性..."
while ! wget -q -T 1 -O - "${ALIST_ADDR}/api/public/settings" | grep -q 200; do
sleep 2
done

@@ -24,10 +26,10 @@ echo "开始自动更新alist地址..."
/update_alist_addr.sh > /dev/null 2>&1 &

echo "启动emby服务..."
/emby.sh start
/service.sh start
sleep 2

echo "启动进程守护..."
/emby.sh daemon &
/service.sh daemon &

exec shell2http -port 8080 /stop "/emby.sh stop" /start "/emby.sh start"
exec shell2http -port 8080 /stop "/service.sh stop" /start "/service.sh start"
File renamed without changes.
6 changes: 4 additions & 2 deletions jellyfin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

echo "等待alist启动完成..."
while ! curl -s -f -m 1 "${ALIST_ADDR:=http://alist:5678}" > /dev/null 2>&1; do
ALIST_ADDR=${ALIST_ADDR:-http://alist:5678}

echo "检查alist连通性..."
while ! curl --silent --show-error --fail "${ALIST_ADDR}/api/public/settings" | grep -q 200; do
sleep 2
done

6 changes: 4 additions & 2 deletions metadata/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -2,8 +2,10 @@

set -e

echo "等待alist启动完成..."
while ! curl -s -f -m 1 "${ALIST_ADDR:=http://alist:5678}" > /dev/null; do
ALIST_ADDR=${ALIST_ADDR:-http://alist:5678}

echo "检查alist连通性..."
while ! curl --silent --show-error --fail "${ALIST_ADDR}/api/public/settings" | grep -q 200; do
sleep 2
done

0 comments on commit e7721a2

Please sign in to comment.