#!/usr/bin/dumb-init /bin/sh
export TICK_S3_URI="s3://${S3_BUCKET}/${S3_PATH}"
mkdir /tick
mkdir /tick/tasks
mkdir /tick/templates
aws s3 sync --delete "$TICK_S3_URI" /tick

(/s3_tick_scripts.sh &)

sed -i -e "s/__SERVICE_NAME__/${SERVICE_NAME}/" /etc/kapacitor/kapacitor.conf
sed -i -e "s/__DEMETER_PASSWORD__/${DEMETER_PASSWORD}/" /etc/kapacitor/kapacitor.conf
sed -i -e "s/__CHARON_PASSWORD__/${CHARON_PASSWORD}/" /etc/kapacitor/kapacitor.conf
exec kapacitord