Changeset View
Changeset View
Standalone View
Standalone View
bin/watch-vagrant-conf
#!/bin/bash | #!/bin/bash | ||||
set -e | set -e | ||||
TMPDIR=${1-/var/tmp/puppet} | |||||
PUPPET_ENV=$(readlink -f $(dirname $0)/..) | PUPPET_ENV=$(readlink -f $(dirname $0)/..) | ||||
RSYNC_PARAMS="-a --progress" | RSYNC_PARAMS="-a --progress" | ||||
EXCLUDES=".git .vagrant" | EXCLUDES=".git .vagrant" | ||||
EXCLUDES_PARAMS="" | EXCLUDES_PARAMS="" | ||||
ENVIRONMENTS="production staging" | ENVIRONMENTS="production staging" | ||||
for ex in ${EXCLUDES}; do | for ex in ${EXCLUDES}; do | ||||
EXCLUDES_PARAMS="${EXCLUDES_PARAMS} --exclude $ex" | EXCLUDES_PARAMS="${EXCLUDES_PARAMS} --exclude $ex" | ||||
done | done | ||||
function sync_puppet_conf { | function sync_puppet_conf { | ||||
branch=$1 | branch=$1 | ||||
rsync $RSYNC_PARAMS $EXCLUDES_PARAMS swh-site/data/ /tmp/puppet/environments/${branch}/data | rsync $RSYNC_PARAMS $EXCLUDES_PARAMS swh-site/data/ $TMPDIR/environments/${branch}/data | ||||
rsync $RSYNC_PARAMS $EXCLUDES_PARAMS swh-site/site-modules/ /tmp/puppet/environments/${branch}/site-modules/ | rsync $RSYNC_PARAMS $EXCLUDES_PARAMS swh-site/site-modules/ $TMPDIR/environments/${branch}/site-modules/ | ||||
rsync $RSYNC_PARAMS $EXCLUDES_PARAMS private/swh-private-data-censored/ /tmp/puppet/environments/${branch}/data/private | rsync $RSYNC_PARAMS $EXCLUDES_PARAMS private/swh-private-data-censored/ $TMPDIR/environments/${branch}/data/private | ||||
} | } | ||||
# Initial sync | # Initial sync | ||||
sync_puppet_conf | sync_puppet_conf | ||||
while true; do | while true; do | ||||
inotifywait -q -r -e modify -e moved_to -e moved_from -e move -e create $EXCLUDES_PARAMS ${PUPPET_ENV} | inotifywait -q -r -e modify -e moved_to -e moved_from -e move -e create $EXCLUDES_PARAMS ${PUPPET_ENV} | ||||
echo Update detected, synchronizing.... | echo Update detected, synchronizing.... | ||||
sleep .5 | sleep .5 | ||||
for environment in ${ENVIRONMENTS}; do | for environment in ${ENVIRONMENTS}; do | ||||
echo "** Syncing ${environment} environmemt" | echo "** Syncing ${environment} environmemt" | ||||
sync_puppet_conf ${environment} | sync_puppet_conf ${environment} | ||||
done | done | ||||
CMD="vagrant rsync pergamon" | CMD="vagrant rsync pergamon" | ||||
$CMD && echo $CMD && notify-send --expire-time=10000 "$CMD done!" | $CMD && echo $CMD && notify-send --expire-time=10000 "$CMD done!" | ||||
done | done |