Files
robot-shop/web/entrypoint.sh

58 lines
1.6 KiB
Bash
Raw Normal View History

2018-02-13 16:56:45 +00:00
#!/usr/bin/env bash
2019-04-09 12:41:31 +01:00
#set -x
2018-02-13 16:56:45 +00:00
# echo "arg 1 $1"
BASE_DIR=/usr/share/nginx/html
if [ -n "$1" ]
then
exec "$@"
fi
2019-04-09 12:41:31 +01:00
if [ -n "$INSTANA_EUM_KEY" -a -n "$INSTANA_EUM_REPORTING_URL" ]
2018-02-13 16:56:45 +00:00
then
echo "Enabling Instana EUM"
2019-04-09 12:41:31 +01:00
# use | instead of / as command delimiter to avoid eacaping the url
sed -i "s|INSTANA_EUM_KEY|$INSTANA_EUM_KEY|" $BASE_DIR/eum-tmpl.html
sed -i "s|INSTANA_EUM_REPORTING_URL|$INSTANA_EUM_REPORTING_URL|" $BASE_DIR/eum-tmpl.html
cp $BASE_DIR/eum-tmpl.html $BASE_DIR/eum.html
2018-02-13 16:56:45 +00:00
else
2019-04-09 12:41:31 +01:00
echo "EUM not enabled"
2018-02-13 16:56:45 +00:00
cp $BASE_DIR/empty.html $BASE_DIR/eum.html
fi
2018-03-27 17:39:05 +01:00
# make sure nginx can access the eum file
chmod 644 $BASE_DIR/eum.html
# apply environment variables to default.conf
2019-11-28 10:19:25 +00:00
envsubst '${CATALOGUE_HOST} ${USER_HOST} ${CART_HOST} ${SHIPPING_HOST} ${PAYMENT_HOST} ${RATINGS_HOST}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
2021-06-25 12:18:18 +01:00
if [ -f /tmp/ngx_http_opnetracing_module.so -a -f /tmp/libinstana_sensor.so ]
then
# Patching for Instana tracing
mv /tmp/ngx_http_opentracing_module.so /usr/lib/nginx/modules
mv /tmp/libinstana_sensor.so /usr/local/lib
cat - /etc/nginx/nginx.conf << !EOF! > /tmp/nginx.conf
2021-06-25 11:30:16 +01:00
# Extra configuration for Instana tracing
load_module modules/ngx_http_opentracing_module.so;
# Pass through these env vars
env INSTANA_SERVICE_NAME;
env INSTANA_AGENT_HOST;
env INSTANA_AGENT_PORT;
env INSTANA_MAX_BUFFERED_SPANS;
env INSTANA_DEV;
!EOF!
2021-06-25 12:18:18 +01:00
mv /tmp/nginx.conf /etc/nginx/nginx.conf
echo "{}" > /etc/instana-config.json
else
# remove tracing config
sed -i '1,3d' /etc/nginx/conf.d/default.conf
fi
2021-06-25 11:30:16 +01:00
2019-11-28 10:19:25 +00:00
exec nginx-debug -g "daemon off;"
2018-02-13 16:56:45 +00:00