init: 实现云端同步器
This commit is contained in:
parent
110db00106
commit
9fa26f3b26
5
.env
Normal file
5
.env
Normal 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
|
||||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -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"]
|
||||||
24
README.md
24
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`字段。
|
||||||
9
docker-compose.yaml
Normal file
9
docker-compose.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
iptv-sync:
|
||||||
|
build: .
|
||||||
|
container_name: iptv-sync
|
||||||
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
24
entrypoint.sh
Normal file
24
entrypoint.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
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
|
||||||
40
sync.sh
Normal file
40
sync.sh
Normal file
@ -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]"
|
||||||
Loading…
x
Reference in New Issue
Block a user