Skip to content

Commit

Permalink
Tweak status messages and comments for readability
Browse files Browse the repository at this point in the history
* Tweak status messages and comments for readability
  • Loading branch information
mbonsack authored and GitHub committed Jun 16, 2020
1 parent d6953d9 commit da7569b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions package/sbin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ mkdir -p /opt/syslog-ng/etc/conf.d/local/config/
cp /opt/syslog-ng/etc/context_templates/* /opt/syslog-ng/etc/conf.d/local/context
for file in /opt/syslog-ng/etc/conf.d/local/context/*.example ; do cp --verbose -n $file ${file%.example}; done

#splunk_index.csv updates
#Remove comment headers from existing config
# splunk_index.csv updates
# Remove comment headers from existing config
touch /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv
if [ -f /opt/syslog-ng/etc/conf.d/local/context/splunk_index.csv ]; then
LEGACY_SPLUNK_INDEX_FILE=/opt/syslog-ng/etc/conf.d/local/context/splunk_index.csv
fi
# Add new entries
awk '{print $0}' ${LEGACY_SPLUNK_INDEX_FILE} /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv.example | grep -v '^#' | sort -b -t ',' -k1,2 -u >/opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv
#We don't need this file anylonger
awk '{print $0}' ${LEGACY_SPLUNK_INDEX_FILE} /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv.example | grep -v '^#' | sort -b -t ',' -k1,2 -u > /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv
# We don't need this file any longer
rm -f /opt/syslog-ng/etc/context_templates/splunk_index.csv.example || true
rm -f /opt/syslog-ng/etc/context_templates/splunk_metadata.csv.example || true
if [ -f /opt/syslog-ng/etc/conf.d/local/context/splunk_index.csv ]; then
Expand All @@ -56,29 +56,29 @@ fi
cp --verbose -R -f /opt/syslog-ng/etc/local_config/* /opt/syslog-ng/etc/conf.d/local/config/
mkdir -p /opt/syslog-ng/var/log

#Test HEC Connectivity
# Test HEC Connectivity
if [ "$SC4S_DEST_SPLUNK_HEC_GLOBAL" != "no" ]
then
HEC=$(echo '{{- getenv "SPLUNK_HEC_URL" | strings.ReplaceAll "/services/collector" "" | strings.ReplaceAll "/event" "" | regexp.ReplaceLiteral "[, ]+" "/services/collector/event " }}/services/collector/event' | gomplate | cut -d' ' -f 1)
SC4S_DEST_SPLUNK_HEC_FALLBACK_INDEX=$(cat /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv | grep ',index,' | grep sc4s_events | cut -d, -f 3)
export SC4S_DEST_SPLUNK_HEC_FALLBACK_INDEX
if ! curl -k "${HEC}?/index=${SC4S_DEST_SPLUNK_HEC_FALLBACK_INDEX}" -H "Authorization: Splunk ${SPLUNK_HEC_TOKEN}" -d '{"event": "HEC TEST EVENT", "sourcetype": "SC4S:PROBE"}'
then
echo SC4S_ENV_CHECK_HEC: Splunk unreachable startup will continue to prevent data loss if this is a transient failure
echo "SC4S_ENV_CHECK_HEC: Splunk HEC endpoint is unreachable; startup will continue to prevent data loss if this is a transient failure"
else
echo SC4S_ENV_CHECK_INDEX: Splunk connection succesfull checking indexes
echo "SC4S_ENV_CHECK_INDEX: Splunk HEC connection successful; checking indexes..."
cat /opt/syslog-ng/etc/conf.d/local/context/splunk_metadata.csv | grep -v sc4s_metrics | grep ',index,' | cut -d, -f 3 | sort -u | while read index ; do export index; echo -e "\nSC4S_ENV_CHECK_INDEX: Checking $index" $(curl -s -S -k "${HEC}?index=${index}" -H "Authorization: Splunk ${SPLUNK_HEC_TOKEN}" -d '{"event": "HEC TEST EVENT", "sourcetype": "SC4S:PROBE"}') ; done
fi
fi

# 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
# 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, exiting..."
exit 800
fi
#Setup SNMPD
# Setup SNMPD
/opt/net-snmp/sbin/snmptrapd -Lf /opt/syslog-ng/var/log/snmptrapd.log

echo syslog-ng checking config
Expand All @@ -104,7 +104,7 @@ then
# Do something knowing the pid exists, i.e. the process with $PID is running
fi

# wait forever
# Wait forever
if [[ $@ != *"-s"* ]]; then
while true
do
Expand Down

0 comments on commit da7569b

Please sign in to comment.