diff options
Diffstat (limited to 'main/in-sync/in-sync')
-rw-r--r-- | main/in-sync/in-sync | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/main/in-sync/in-sync b/main/in-sync/in-sync new file mode 100644 index 0000000000..421974dc9e --- /dev/null +++ b/main/in-sync/in-sync @@ -0,0 +1,29 @@ +#!/bin/sh + +# inotify-triggered file synchronization +# Copyright (c) 2020 Kaarle Ritvanen + +. /etc/in-sync.conf + +log() { + logger -p daemon.$1 "$(basename "$0"): $2" +} + +list_files() { + local path + cat /etc/in-sync.d/* | while read path; do + [ -e "$path" ] && echo "$path" + done +} + +while :; do + for host in $TARGET_HOSTS; do + if list_files | rsync -avz --files-from - / $host:/; then + log info "successfully synchronized to $host" + else + log err "synchronization to $host failed" + fi + done + list_files | inotifywait -e close_write -t 900 --fromfile - + [ $? -eq 1 ] && sleep 60 +done |