@@ -7,10 +7,10 @@ OUTPUT=$(mktemp tmp.logstash.out.XXXXX)
77PIPELINE=$( mktemp tmp.logstash.pipeline.XXXXX)
88
99echo Preparing input data
10- echo " postfix/smtp[123]: 7EE668039: to=<admin@example.com>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 153053D)" > $INPUT
10+ echo " postfix/smtp[123]: 7EE668039: to=<admin@example.com>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 153053D)" > " $INPUT "
1111
1212echo Preparing pipeline config
13- cat > $PIPELINE << EOF
13+ cat > " $PIPELINE " << EOF
1414input {
1515 file {
1616 path => "/tmp/logstash.in"
@@ -26,9 +26,9 @@ filter {
2626}
2727EOF
2828
29- cat 50-filter-postfix.conf >> $PIPELINE
29+ cat 50-filter-postfix.conf >> " $PIPELINE "
3030
31- cat >> $PIPELINE << EOF
31+ cat >> " $PIPELINE " << EOF
3232output {
3333 file {
3434 path => "/tmp/logstash.out"
3838
3939echo Starting logstash docker container
4040CONTAINER_ID=$( docker run --rm --detach \
41- --volume ./${INPUT} :/tmp/logstash.in \
42- --volume ./${OUTPUT} :/tmp/logstash.out \
41+ --volume ./" ${INPUT} " :/tmp/logstash.in \
42+ --volume ./" ${OUTPUT} " :/tmp/logstash.out \
4343 --volume ./postfix.grok:/etc/logstash/patterns.d/postfix.grok \
44- --volume ./${PIPELINE} :/usr/share/logstash/pipeline/pipeline.conf \
44+ --volume ./" ${PIPELINE} " :/usr/share/logstash/pipeline/pipeline.conf \
4545 logstash:8.12.0 \
4646 logstash -f /usr/share/logstash/pipeline/pipeline.conf)
4747
48- echo -n " Waiting for output from logstash "
49- until test -s $OUTPUT ; do
50- echo -n " ."
48+ printf " Waiting for output from logstash "
49+ until test -s " $OUTPUT " ; do
50+ printf " ."
5151 sleep 2
5252done
5353echo
5454
55- docker stop --time 1 $CONTAINER_ID > /dev/null
55+ docker stop --time 1 " $CONTAINER_ID " > /dev/null
5656
57- if test " $( jq .tags[0] $OUTPUT ) " = ' "_grok_postfix_success"' ; then
57+ if test " $( jq .tags[0] " $OUTPUT " ) " = ' "_grok_postfix_success"' ; then
5858 echo Grok processing successful!
59- jq . $OUTPUT
59+ jq . " $OUTPUT "
6060else
6161 echo " Grok processing failed :<"
62- jq . $OUTPUT
62+ jq . " $OUTPUT "
6363 exit 1
6464fi
6565
6666echo Cleaning up
67- rm -f $INPUT $OUTPUT $PIPELINE
67+ rm -f " $INPUT " " $OUTPUT " " $PIPELINE "
6868
69- echo Done
69+ echo Done
0 commit comments