Files
icloud-sync/icloud.sh
2026-01-28 13:48:59 +08:00

58 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# iCloud 同步管理脚本
# 用法: ./icloud.sh <命令>
# 命令: auth, logs, status, restart, sync
cd "$(dirname "$0")"
show_help() {
echo -e "\033[36m用法: ./icloud.sh <命令>\033[0m"
echo ""
echo -e "\033[36m命令:\033[0m"
echo " auth - 重新认证"
echo " logs - 查看实时日志"
echo " status - 查看容器状态"
echo " restart - 重启容器"
echo " sync - 立即触发同步"
}
if [ -z "$1" ]; then
show_help
exit 0
fi
case $1 in
auth)
echo -e "\033[32m开始 iCloud 认证...\033[0m"
echo -e "\033[33m请输入密码和验证码完成认证\033[0m"
docker exec -it icloudpd sync-icloud.sh --Initialise
if [ $? -eq 0 ]; then
echo -e "\033[32m认证成功\033[0m"
else
echo -e "\033[31m认证失败请重试\033[0m"
fi
;;
logs)
echo -e "\033[36m查看实时日志 (Ctrl+C 退出)...\033[0m"
docker logs -f icloudpd
;;
status)
docker ps --filter "name=icloudpd" --format "table {{.Status}}\t{{.Ports}}"
docker logs --tail 10 icloudpd
;;
restart)
echo -e "\033[33m重启容器...\033[0m"
docker compose restart
echo -e "\033[32m完成\033[0m"
;;
sync)
echo -e "\033[33m立即触发同步...\033[0m"
docker exec icloudpd sync-icloud.sh --DownloadOnce
;;
*)
echo -e "\033[31m未知命令: $1\033[0m"
echo ""
show_help
;;
esac