Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 905d82a

Browse files
author
Chris Wiechmann
committed
Refactored entrypoint script to use awk only instead of gawk
#154
1 parent d9d6352 commit 905d82a

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [4.0.2] 2021-12-17
8+
### Fixed
9+
- Elasticsearch failed to start - awk: line 1: syntax error at or near , [#154](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/154)
10+
711
## [4.0.1] 2021-12-16
812
### Changed
913
- Updated default Elastic-Stack version from 7.15.1 to 7.16.1

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/config/axway-api-utils.default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
localLookupFile: process.env.API_BUILDER_LOCAL_API_LOOKUP_FILE,
1919
// This optionally disables the validation of the configuration on API-Builder startup
2020
validateConfig: (process.env.VALIDATE_CONFIG) ? process.env.VALIDATE_CONFIG : true,
21-
// For how long should looked up entities (API, User) stay in the cached
21+
// For how long should looked up entities (API-, Application-Details) stay in the cache
2222
lookupCacheTTL: parseInt(process.env.LOOKUP_CACHE_TTL) ? process.env.LOOKUP_CACHE_TTL : 600
2323
}
2424
}

elasticsearch/scripts/elasticsearch-custom-entrypoint.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
# given externally they are used with precedence.
77

88
# Get the number of the Elasticsearch node based on the node.name (e.g. elasticsearch2)
9-
nodeBasename=`echo node.name | awk 'match(ENVIRON[$0], /([a-zA-Z]*)([0-9]{1,})/, v) { print v[1] }'`
10-
nodeNumber=`echo node.name | awk 'match(ENVIRON[$0], /([a-zA-Z]*)([0-9]{1,})/, v) { print v[2] }'`
9+
echo "Setup Elasticsearch cluster based on ELASTICSEARCH_HOSTS: ${ELASTICSEARCH_HOSTS}"
10+
# Translate the dotted environment variable into Non-Dotted to avoid issues with Bash commands
11+
nodeName=`echo | awk '{ print ENVIRON["node.name"] }'`
12+
13+
nodeBasename=`echo $nodeName | sed -r 's/([a-zA-Z]*)([0-9]{1,})/\1/'`
14+
nodeNumber=`echo $nodeName | sed -r 's/([a-zA-Z]*)([0-9]{1,})/\2/'`
1115

1216
count=1
1317
params=""
@@ -23,13 +27,13 @@ do
2327
fi
2428
# Use all declared hosts as seed hosts if
2529
# Seeds hosts are not given externally and the standard transport ports are used
26-
discoverySeedHosts=`echo discovery.seed_hosts | awk '{print ENVIRON[$0]}'`
27-
discoveryTransportPort=`echo transport.port | awk '{print ENVIRON[$0]}'`
30+
discoverySeedHosts=`echo | awk '{ print ENVIRON["discovery.seed_hosts"] }'`
31+
discoveryTransportPort=`echo | awk '{ print ENVIRON["transport.port"] }'`
2832
if [ -z "${discoverySeedHosts}" -a -z "${discoveryTransportPort}" ]
2933
then
30-
# Get the hostname and transport from the URL
31-
discoverPublishHostname=`echo $host | awk 'match($0, /https?:\/\/(.*)\:(\d*)/, v) { print v[1] }'`
32-
discoveryTransportPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/, v) { print 93v[2] }'`
34+
# Get the hostname and defined transportPort based on the URL (e.g. https://elasticsearch2:9201) 9201 --> 9301
35+
discoverPublishHostname=`echo $host | sed -r 's/https?:\/\/(.*)\:[0-9]{4}/\1/'`
36+
discoveryTransportPort=`echo $host | sed -r 's/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/93\2/'`
3337
if [ "${seedHosts}" == "" ]; then
3438
seedHosts="-E discovery.seed_hosts=${discoverPublishHostname}:${discoveryTransportPort}"
3539
else
@@ -39,9 +43,9 @@ do
3943

4044
if [ "${count}" == "${nodeNumber}" ]; then
4145
echo "Setting up Elasticsearch node: ${nodeNumber}"
42-
publishHost=`echo network.publish_host | awk '{print ENVIRON[$0]}'`
46+
publishHost=`echo | awk '{ print ENVIRON["network.publish_host"] }'`
4347
if [ -z "${publishHost}" ]; then
44-
publishHost=`echo $host | awk 'match($0, /https?:\/\/(.*)\:(\d*)/, v) { print v[1] }'`
48+
publishHost=`echo $host | sed -r 's/https?:\/\/(.*)\:[0-9]{4}/\1/'`
4549
params="$params -E network.publish_host=${publishHost}"
4650
echo "Set network.publish_host=${publishHost} based on given host: ${host}"
4751
else
@@ -51,17 +55,17 @@ do
5155
httpPort=`echo http.port | awk '{print ENVIRON[$0]}'`
5256
if [ -z "${httpPort}" ]
5357
then
54-
httpPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:([0-9]*)/, v) { print v[2] }'`
58+
httpPort=`echo $host | sed -r 's/https?:\/\/(.*)\:([0-9]*)/\2/'`
5559
params="$params -E http.port=${httpPort}"
5660
echo "Set http.port=${httpPort} based on given host: ${host}"
5761
else
5862
echo "http.port=${httpPort} taken from envionment variable"
5963
fi
6064

61-
transportPort=`echo transport.port | awk '{print ENVIRON[$0]}'`
65+
transportPort=`echo | awk '{ print ENVIRON["transport.port"] }'`
6266
if [ -z "${transportPort}" ]
6367
then
64-
transportPort=`echo $host | awk 'match($0,/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/, v) { print 93v[2] }'`
68+
transportPort=`echo $host | sed -r 's/https?:\/\/(.*)\:[0-9]{2}([0-9]{2})/93\2/'`
6569
params="$params -E transport.port=${transportPort}"
6670
echo "Set transport.port=${transportPort} based on given host: ${host}"
6771
else

0 commit comments

Comments
 (0)