Spaces:
Runtime error
Runtime error
Delete sync_now.sh
Browse files- sync_now.sh +0 -46
sync_now.sh
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
|
| 3 |
-
echo "=== 手动同步启动: $(date '+%Y-%m-%d %H:%M:%S') ===" | tee -a /tmp/sync_log.txt
|
| 4 |
-
|
| 5 |
-
# 拉取最新代码
|
| 6 |
-
echo "更新仓库数据..." | tee -a /tmp/sync_log.txt
|
| 7 |
-
cd ./data/github_data
|
| 8 |
-
git pull origin main 2>&1 | tee -a /tmp/sync_log.txt
|
| 9 |
-
cd ../..
|
| 10 |
-
|
| 11 |
-
# 复制数据库文件
|
| 12 |
-
if [ -f "./data/webui.db" ]; then
|
| 13 |
-
cp ./data/webui.db ./data/github_data/webui.db
|
| 14 |
-
echo "数据库复制完成。" | tee -a /tmp/sync_log.txt
|
| 15 |
-
else
|
| 16 |
-
echo "未找到 webui.db 数据库文件,跳过 GitHub 同步" | tee -a /tmp/sync_log.txt
|
| 17 |
-
fi
|
| 18 |
-
|
| 19 |
-
# 提交并推送到 GitHub
|
| 20 |
-
cd ./data/github_data
|
| 21 |
-
if [[ -n $(git status -s) ]]; then
|
| 22 |
-
git add webui.db
|
| 23 |
-
git commit -m "Manual sync $(date '+%Y-%m-%d %H:%M:%S')" | tee -a /tmp/sync_log.txt
|
| 24 |
-
git push origin HEAD 2>&1 | tee -a /tmp/sync_log.txt
|
| 25 |
-
echo "GitHub 推送成功" | tee -a /tmp/sync_log.txt
|
| 26 |
-
else
|
| 27 |
-
echo "GitHub: 没有检测到变更" | tee -a /tmp/sync_log.txt
|
| 28 |
-
fi
|
| 29 |
-
cd ..
|
| 30 |
-
cd ..
|
| 31 |
-
|
| 32 |
-
# WebDAV 同步
|
| 33 |
-
if [ -z "$WEBDAV_URL" ] || [ -z "$WEBDAV_USERNAME" ] || [ -z "$WEBDAV_PASSWORD" ]; then
|
| 34 |
-
echo "WebDAV 环境变量缺失,跳过 WebDAV 同步。" | tee -a /tmp/sync_log.txt
|
| 35 |
-
else
|
| 36 |
-
echo "同步到 WebDAV..." | tee -a /tmp/sync_log.txt
|
| 37 |
-
FILENAME="webui_$(date +'%m_%d').db"
|
| 38 |
-
if [ -f "./data/webui.db" ]; then
|
| 39 |
-
curl -T ./data/webui.db --user "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" "$WEBDAV_URL/$FILENAME" 2>&1 | tee -a /tmp/sync_log.txt
|
| 40 |
-
echo "WebDAV 上传完成" | tee -a /tmp/sync_log.txt
|
| 41 |
-
else
|
| 42 |
-
echo "未找到 webui.db,跳过 WebDAV 同步" | tee -a /tmp/sync_log.txt
|
| 43 |
-
fi
|
| 44 |
-
fi
|
| 45 |
-
|
| 46 |
-
echo "=== 手动同步完成: $(date '+%Y-%m-%d %H:%M:%S') ===" | tee -a /tmp/sync_log.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|