ds / sync.sh
cfjy99's picture
Update sync.sh
8be2408 verified
raw
history blame contribute delete
851 Bytes
#!/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