File size: 851 Bytes
7275860
 
8be2408
fdf04b4
8be2408
 
7275860
fdf04b4
7275860
8be2408
 
 
 
 
fdf04b4
 
7275860
 
fdf04b4
7275860
 
8be2408
 
 
 
 
 
7275860
8be2408
 
fdf04b4
 
 
8be2408
fdf04b4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

# 设置安全目录
git config --global --add safe.directory /app/data

# 配置Git身份(使用用户可写路径)
git config --global user.email "alist@hf.space"
git config --global user.name "Alist Sync"

# 初始化数据目录
if [ ! -d "/app/data" ]; then
  sudo -u alistuser mkdir -p /app/data
fi

# 克隆/更新仓库
if [ ! -d "/app/data/.git" ]; then
  git clone "https://oauth2:${HF_TOKEN}@huggingface.co/datasets/${ALIST_DATA_REPO}" /app/data
else
  cd /app/data && git pull origin main
fi

# 验证Alist路径
echo "Checking Alist path:"
which alist || find / -name alist -type f 2>/dev/null

# 启动Alist服务
alist server --data /app/data &

# 定时同步循环
while true; do
  sleep 3600
  cd /app/data && \
  git add . && \
  git commit -m "Auto Sync $(date +'%Y-%m-%d %H:%M:%S')" && \
  git push origin main
done