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

15 lines
539 B
Django/Jinja

#!/bin/bash
# {{ ansible_managed }}
# script that calls an rsync whenever a file gets written in uploads directory
UPLOAD_DIR="{{ di_legacy_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_legacy_rsync_uploads_target }}:{{ di_legacy_rsync_uploads_destination }}
done