Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit f472eba

Browse files
committed
ISSUE 125: Adds simplified port incrementation handling to systemd unit.
1 parent a39026e commit f472eba

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CentOS-6 6.9 x86_64, Apache 2.2, PHP-CGI 5.3 (FastCGI), PHP memcached 1.0, PHP A
1111
- Updates image source to [release 1.10.0](https://github.com/jdeathe/centos-ssh-apache-php/releases/tag/1.10.0).
1212
- Fixes issue with missing APACHE_SSL_* environment variables for make,scmi and systemd.
1313
- Adds test case output with improved readability.
14+
- Adds simplified port incrementation handling to systemd unit and make consistent with SCMI.
1415

1516
### 1.9.0 - 2017-02-07
1617

src/etc/systemd/system/centos-ssh-apache-php-fcgi@.service

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,42 +106,6 @@ ExecStartPre=-/bin/bash -c \
106106
ExecStart=/bin/bash -c \
107107
"exec /usr/bin/docker run \
108108
--name %p.%i \
109-
$(\
110-
if [[ ${DOCKER_PORT_MAP_TCP_80} != NULL ]]; then \
111-
if [[ -n $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_80}\") ]]; then \
112-
printf -- '--publish %%s%%s:80' \
113-
\"$(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[1]; }' <<< \"${DOCKER_PORT_MAP_TCP_80}\")\" \
114-
\"$(( $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_80}\") + $(/usr/bin/awk -F. '$0=$1' <<< %i) - 1 ))\"; \
115-
else \
116-
printf -- '--publish %%s:80' \
117-
\"${DOCKER_PORT_MAP_TCP_80}\"; \
118-
fi; \
119-
fi; \
120-
) \
121-
$(\
122-
if [[ ${DOCKER_PORT_MAP_TCP_443} != NULL ]] && [[ ${APACHE_MOD_SSL_ENABLED} == true ]]; then \
123-
if [[ -n $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_443}\") ]]; then \
124-
printf -- '--publish %%s%%s:443' \
125-
\"$(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[1]; }' <<< \"${DOCKER_PORT_MAP_TCP_443}\")\" \
126-
\"$(( $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_443}\") + $(/usr/bin/awk -F. '$0=$1' <<< %i) - 1 ))\"; \
127-
else \
128-
printf -- '--publish %%s:443' \
129-
\"${DOCKER_PORT_MAP_TCP_443}\"; \
130-
fi; \
131-
fi; \
132-
) \
133-
$(\
134-
if [[ ${DOCKER_PORT_MAP_TCP_8443} != NULL ]]; then \
135-
if [[ -n $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_8443}\") ]]; then \
136-
printf -- '--publish %%s%%s:8443' \
137-
\"$(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[1]; }' <<< \"${DOCKER_PORT_MAP_TCP_8443}\")\" \
138-
\"$(( $(/usr/bin/gawk 'match($0, /^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:)?([0-9]+)$/, matches) { print matches[2]; }' <<< \"${DOCKER_PORT_MAP_TCP_8443}\") + $(/usr/bin/awk -F. '$0=$1' <<< %i) - 1 ))\"; \
139-
else \
140-
printf -- '--publish %%s:8443' \
141-
\"${DOCKER_PORT_MAP_TCP_8443}\"; \
142-
fi; \
143-
fi; \
144-
) \
145109
--env \"APACHE_CONTENT_ROOT=${APACHE_CONTENT_ROOT}\" \
146110
--env \"APACHE_CUSTOM_LOG_FORMAT=${APACHE_CUSTOM_LOG_FORMAT}\" \
147111
--env \"APACHE_CUSTOM_LOG_LOCATION=${APACHE_CUSTOM_LOG_LOCATION}\" \
@@ -158,8 +122,41 @@ ExecStart=/bin/bash -c \
158122
--env \"APACHE_RUN_USER=${APACHE_RUN_USER}\" \
159123
--env \"APACHE_SERVER_ALIAS=${APACHE_SERVER_ALIAS}\" \
160124
--env \"APACHE_SERVER_NAME=${APACHE_SERVER_NAME}\" \
125+
--env \"APACHE_SSL_CERTIFICATE=${APACHE_SSL_CERTIFICATE}\" \
126+
--env \"APACHE_SSL_CIPHER_SUITE=${APACHE_SSL_CIPHER_SUITE}\" \
127+
--env \"APACHE_SSL_PROTOCOL=${APACHE_SSL_PROTOCOL}\" \
161128
--env \"APACHE_SYSTEM_USER=${APACHE_SYSTEM_USER}\" \
162129
--env \"PHP_OPTIONS_DATE_TIMEZONE=${PHP_OPTIONS_DATE_TIMEZONE}\" \
130+
$(if [[ ${DOCKER_PORT_MAP_TCP_80} != NULL ]]; then \
131+
if /usr/bin/grep -qE '^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:)?[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_80}\"; then \
132+
printf -- '--publish %%s%%s:80' \
133+
$(/usr/bin/grep -o '^[0-9\.]*:' <<< \"${DOCKER_PORT_MAP_TCP_80}\") \
134+
$(( $(/usr/bin/grep -o '[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_80}\") + $(/usr/bin/sed 's~\.[0-9]*$~~' <<< %i) - 1 )); \
135+
else \
136+
printf -- '--publish %%s:80' \
137+
\"${DOCKER_PORT_MAP_TCP_80}\"; \
138+
fi; \
139+
fi) \
140+
$(if [[ ${DOCKER_PORT_MAP_TCP_443} != NULL ]]; then \
141+
if /usr/bin/grep -qE '^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:)?[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_443}\"; then \
142+
printf -- '--publish %%s%%s:443' \
143+
$(/usr/bin/grep -o '^[0-9\.]*:' <<< \"${DOCKER_PORT_MAP_TCP_443}\") \
144+
$(( $(/usr/bin/grep -o '[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_443}\") + $(/usr/bin/sed 's~\.[0-9]*$~~' <<< %i) - 1 )); \
145+
else \
146+
printf -- '--publish %%s:443' \
147+
\"${DOCKER_PORT_MAP_TCP_443}\"; \
148+
fi; \
149+
fi) \
150+
$(if [[ ${DOCKER_PORT_MAP_TCP_8443} != NULL ]]; then \
151+
if /usr/bin/grep -qE '^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:)?[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_8443}\"; then \
152+
printf -- '--publish %%s%%s:8443' \
153+
$(/usr/bin/grep -o '^[0-9\.]*:' <<< \"${DOCKER_PORT_MAP_TCP_8443}\") \
154+
$(( $(/usr/bin/grep -o '[0-9]*$' <<< \"${DOCKER_PORT_MAP_TCP_8443}\") + $(/usr/bin/sed 's~\.[0-9]*$~~' <<< %i) - 1 )); \
155+
else \
156+
printf -- '--publish %%s:8443' \
157+
\"${DOCKER_PORT_MAP_TCP_8443}\"; \
158+
fi; \
159+
fi) \
163160
${DOCKER_CONTAINER_OPTS} \
164161
${DOCKER_USER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}; \
165162
"

0 commit comments

Comments
 (0)