From 4d02aca60e894068f16f3a1f2bbc6be16f75bced Mon Sep 17 00:00:00 2001 From: rfaircloth-splunk Date: Sun, 14 Jun 2020 09:07:44 -0400 Subject: [PATCH 1/2] Update entrypoint.sh --- package/sbin/entrypoint.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/package/sbin/entrypoint.sh b/package/sbin/entrypoint.sh index 435d2ff..93db60f 100755 --- a/package/sbin/entrypoint.sh +++ b/package/sbin/entrypoint.sh @@ -34,8 +34,13 @@ hup_handler() { trap 'kill ${!}; hup_handler' SIGHUP trap 'kill ${!}; term_handler' SIGTERM - -gomplate $(find . -name *.tmpl | sed -E 's/^(\/.*\/)*(.*)\..*$/--file=\2.tmpl --out=\2/') --template t=etc/go_templates/ +# Run gomplate to create config from templates if the command errors this is fatal +# Stop the container. Errors in this step should only happen with user provided +#Templates +if ! gomplate $(find . -name *.tmpl | sed -E 's/^(\/.*\/)*(.*)\..*$/--file=\2.tmpl --out=\2/') --template t=etc/go_templates/; then + echo Error in Gomplate template unable to continue + exit 800 +fi mkdir -p /opt/syslog-ng/etc/conf.d/local/context/ mkdir -p /opt/syslog-ng/etc/conf.d/local/config/ @@ -59,9 +64,8 @@ pid="$!" sleep 5 if ! ps -p $pid > /dev/null then - echo "syslog-ng failed to start $pid is not running" - /opt/syslog-ng/sbin/syslog-ng -s - if [ "${SC4S_DEBUG_CONTAINER}" == "yes" ] + echo "syslog-ng failed to start; PID $pid is not running" + if [ "${SC4S_DEBUG_CONTAINER}" != "yes" ] then exit $(wait ${pid}) else From 1fc4af80f9da8d1abd0d74acb44fe60f9a356a11 Mon Sep 17 00:00:00 2001 From: mbonsack Date: Sun, 14 Jun 2020 08:43:55 -0700 Subject: [PATCH 2/2] Refine error messages * Refine error messages --- package/sbin/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/sbin/entrypoint.sh b/package/sbin/entrypoint.sh index 93db60f..bcd9797 100755 --- a/package/sbin/entrypoint.sh +++ b/package/sbin/entrypoint.sh @@ -38,7 +38,7 @@ trap 'kill ${!}; term_handler' SIGTERM # Stop the container. Errors in this step should only happen with user provided #Templates if ! gomplate $(find . -name *.tmpl | sed -E 's/^(\/.*\/)*(.*)\..*$/--file=\2.tmpl --out=\2/') --template t=etc/go_templates/; then - echo Error in Gomplate template unable to continue + echo "Error in Gomplate template; unable to continue, exiting..." exit 800 fi @@ -64,7 +64,7 @@ pid="$!" sleep 5 if ! ps -p $pid > /dev/null then - echo "syslog-ng failed to start; PID $pid is not running" + echo "syslog-ng failed to start; PID $pid is not running, exiting..." if [ "${SC4S_DEBUG_CONTAINER}" != "yes" ] then exit $(wait ${pid})