Current section
Files
Jump to
Current section
Files
priv/templates/deploy-sync-config-s3.eex
#!/usr/bin/env bash
# Sync config files from S3 bucket to app config dir
set -e
# Config vars
export LANG="<%= env_lang %>"
CONFIG_DIR="<%= configuration_dir %>"
DEPLOY_USER="${DEPLOY_USER:-<%= deploy_user %>}"
APP_GROUP="${APP_USER:-<%= app_group %>}"
# Env vars
# CONFIG_S3_BUCKET: bucket name
# CONFIG_S3_PREFIX: optional path in prefix
# DESTDIR, prefix for target files, optional
# Make sure files are created with restrictive file permissions
umask 077
echo "Starting $0"
aws s3 sync --exact-timestamps --no-progress "s3://${CONFIG_S3_BUCKET}/${CONFIG_S3_PREFIX}" "${DESTDIR}${CONFIG_DIR}/"
chown -R $DEPLOY_USER:$APP_GROUP ${DESTDIR}$CONFIG_DIR
find ${DESTDIR}$CONFIG_DIR -type f -exec chmod 640 {} \;
find ${DESTDIR}$CONFIG_DIR -type d -exec chmod 750 {} \;