mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-20 01:26:38 +02:00
29 lines
586 B
Bash
29 lines
586 B
Bash
#!/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
|