src.dualinventive.com/devops/ansible-dtap/rootnet-roles/di-rsync-uploads/templates/rsync-uploads.j2

15 lines
518 B
Django/Jinja

#!/bin/bash
# {{ ansible_managed }}
# script that calls an rsync whenever a file gets written in uploads directory
UPLOAD_DIR="{{ di_rsync_uploads_source }}"
RSYNC="/usr/bin/rsync"
[ -d ${UPLOAD_DIR} ] || (echo ${UPLOAD_DIR} does not exist. && exit 1)
[ -x ${RSYNC} ] || (echo ${RSYNC} does not exist or is not executable. && exit 1)
while inotifywait -qqr -e create -e close_write ${UPLOAD_DIR}; do
sleep 5
${RSYNC} -aqzO ${UPLOAD_DIR} {{ di_rsync_uploads_target }}:{{ di_rsync_uploads_destination }}
done