From 9fa26f3b2609611297e266e44dfbd9cdb2a9ace2 Mon Sep 17 00:00:00 2001 From: liyanyan <215952619@qq.com> Date: Sun, 5 Jul 2026 23:32:52 +0800 Subject: [PATCH] =?UTF-8?q?init:=20=E5=AE=9E=E7=8E=B0=E4=BA=91=E7=AB=AF?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 5 +++++ Dockerfile | 15 +++++++++++++++ README.md | 24 ++++++++++++++++++++++++ docker-compose.yaml | 9 +++++++++ entrypoint.sh | 24 ++++++++++++++++++++++++ sync.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+) create mode 100644 .env create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 entrypoint.sh create mode 100644 sync.sh diff --git a/.env b/.env new file mode 100644 index 0000000..d58e641 --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +GITEA_HOST=gitea.proxy.liyanyan.work +GITEA_USER=liyy +GITEA_TOKEN=xxxxxxxxxxxxxxxx +GITEA_REPO=liyy/iptv-gh-pages +SYNC_INTERVAL=1800 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8e1cb55 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.20 + +RUN apk add --no-cache \ + git \ + bash \ + ca-certificates + +WORKDIR /workspace + +COPY sync.sh /workspace/sync.sh +COPY entrypoint.sh /workspace/entrypoint.sh + +RUN chmod +x /workspace/*.sh + +CMD ["/workspace/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index e69de29..5a3ed9d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,24 @@ +# IPTV Sync Mirror (gh-pages → Gitea) + +基于 Docker 的自动同步工具,将 :contentReference[oaicite:0]{index=0} 的 gh-pages 静态文件同步到 Gitea,用于构建稳定 IPTV 镜像源。 + +--- + +## 功能 + +- 定时拉取 iptv-org gh-pages +- 同步到 Gitea 仓库 +- 只保留静态文件 +- 自动 push 更新 + +--- + +## 架构 + +GitHub gh-pages → Docker sync → Gitea repo → 静态访问 + +--- + +## 注意 + +启动之前需要修改 `.env`文件的`GITEA_TOKEN`字段。 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..1083f3a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,9 @@ +version: "3" + +services: + iptv-sync: + build: . + container_name: iptv-sync + restart: always + env_file: + - .env \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b6bb0bc --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +echo "[init] setting git auth" + +cat < /root/.netrc +machine ${GITEA_HOST} +login ${GITEA_USER} +password ${GITEA_TOKEN} +EOF + +chmod 600 /root/.netrc + +echo "[init] start loop sync" + +while true +do + echo "==========================" + echo "[sync start] $(date)" + /workspace/sync.sh + echo "[sync end] $(date)" + echo "sleep ${SYNC_INTERVAL}s" + sleep ${SYNC_INTERVAL} +done \ No newline at end of file diff --git a/sync.sh b/sync.sh new file mode 100644 index 0000000..961fd5f --- /dev/null +++ b/sync.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +echo "[1] update iptv-org repo" + +if [ ! -d iptv ]; then + git clone https://github.com/iptv-org/iptv.git +fi + +cd iptv +git fetch origin +git checkout gh-pages +git reset --hard origin/gh-pages +cd .. + +echo "[2] update gitea repo" + +if [ ! -d iptv-gh-pages ]; then + git clone https://${GITEA_HOST}/${GITEA_REPO}.git iptv-gh-pages +fi + +cd iptv-gh-pages +git pull origin main || true + +echo "[3] sync files" + +# 清空旧内容(保留 .git) +find . -mindepth 1 -maxdepth 1 ! -name ".git" -exec rm -rf {} + + +cp -r ../iptv/* . + +echo "[4] commit & push" + +git add . + +git commit -m "sync: $(date '+%Y-%m-%d %H:%M:%S')" || echo "no changes" + +git push origin main + +echo "[done]" \ No newline at end of file