Compare commits

...

4 Commits
main ... cloud

Author SHA1 Message Date
liyanyan
2f3894a8b0 fix: 修复文件复制失败问题 2026-07-06 00:21:50 +08:00
liyanyan
6c121f1094 refactor: 优化同步慢的问题 2026-07-06 00:06:07 +08:00
liyanyan
d65f11a96c fix: 修复提交失败问题 2026-07-05 23:51:02 +08:00
liyanyan
9fa26f3b26 init: 实现云端同步器 2026-07-05 23:32:52 +08:00
6 changed files with 124 additions and 0 deletions

5
.env Normal file
View File

@ -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

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM alpine:3.20
RUN apk add --no-cache \
git \
bash \
ca-certificates\
rsync
WORKDIR /workspace
COPY sync.sh /workspace/sync.sh
COPY entrypoint.sh /workspace/entrypoint.sh
RUN chmod +x /workspace/*.sh
CMD ["/workspace/entrypoint.sh"]

View File

@ -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`字段。

9
docker-compose.yaml Normal file
View File

@ -0,0 +1,9 @@
version: "3"
services:
iptv-sync:
build: .
container_name: iptv-sync
restart: always
env_file:
- .env

27
entrypoint.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
echo "[init] setting git auth"
cat <<EOF > /root/.netrc
machine ${GITEA_HOST}
login ${GITEA_USER}
password ${GITEA_TOKEN}
EOF
chmod 600 /root/.netrc
git config --global user.name "iptv-sync-bot"
git config --global user.email "bot@local"
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

43
sync.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/bash
set -e
echo "[sync] start $(date)"
# ===== config safety =====
git config --global user.name "iptv-sync"
git config --global user.email "bot@local"
git config --global http.version HTTP/1.1
# ===== 1. github gh-pages =====
if [ ! -d iptv/.git ]; then
git clone --depth 1 -b gh-pages https://github.com/iptv-org/iptv.git iptv
else
cd iptv
git fetch origin gh-pages
git reset --hard origin/gh-pages
cd ..
fi
# ===== 2. gitea repo =====
if [ ! -d iptv-gh-pages/.git ]; then
git clone https://${GITEA_HOST}/${GITEA_REPO}.git iptv-gh-pages
fi
# ===== 3. sync files =====
rsync -a --delete \
--exclude='.git' \
iptv/ iptv-gh-pages/
# ===== 4. commit & push =====
cd iptv-gh-pages
git add -A
git diff --cached --quiet && {
echo "[sync] no changes"
exit 0
}
git commit -m "sync $(date '+%Y-%m-%d %H:%M:%S')"
git push origin main
echo "[sync] done $(date)"