blob: 421974dc9ecde34058fa8a66a8dd164e88faa2dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
|