| # 定义源路径(监控目录) | |
| SOURCE="/sillytavern/" | |
| # 获取 host 和 port 参数 | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: $0 <host> <port>" | |
| exit 1 | |
| fi | |
| HOST="$1" | |
| PORT="$2" | |
| # 使用 inotifywait 监控源目录的变化 | |
| while true; do | |
| # 等待文件创建、修改或删除事件。 | |
| inotifywait -r -e modify,create,delete "$SOURCE" | |
| # 执行 Python 脚本,并传递 host 和 port 参数 | |
| python /rsync.py --host "$HOST" --port "$PORT" | |
| done | |