Skip to content

Commit

Permalink
Merge pull request #15 from devilbox/release-0.20
Browse files Browse the repository at this point in the history
Upgrade vhost-gen and add PHP 5.2 compat mode
  • Loading branch information
cytopia authored Aug 3, 2018
2 parents a31d1a8 + 354db1f commit 6d4ede5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LABEL \
###
### Build arguments
###
ARG VHOST_GEN_GIT_REF=0.10
ARG VHOST_GEN_GIT_REF=0.11
ARG CERT_GEN_GIT_REF=0.2

ENV BUILD_DEPS \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ This Docker container adds a lot of injectables in order to customize it to your
| PHP_FPM_ENABLE | bool | `0` | Enable PHP-FPM for the default vhost and the mass virtual hosts. |
| PHP_FPM_SERVER_ADDR | string | `` | IP address or hostname of remote PHP-FPM server.<br/><strong>Required when enabling PHP.</strong> |
| PHP_FPM_SERVER_PORT | int | `9000` | Port of remote PHP-FPM server |
| COMPAT | str | - | Set this value to `5.2` to enable PHP-FPM 5.2 compatbility mode. (Only when using PHP-FPM 5.2) |

##### Optional environmental variables (default vhost)

Expand Down
36 changes: 36 additions & 0 deletions data/docker-entrypoint.d/04-php-fpm-compat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e
set -u
set -o pipefail


############################################################
# Functions
############################################################

###
### Ensure COMPAT is set
###
export_php_fpm_compat() {
local varname="${1}"
local debug="${2}"
local value="0"

if ! env_set "${varname}"; then
log "info" "\$${varname} not set. Not enabling PHP 5.2 compatibility mode." "${debug}"
# Ensure variable is exported
eval "export ${varname}=0"
else
value="$( env_get "${varname}" )"
if [ "${value}" = "5.2" ]; then
log "info" "PHP 5.2 compatibility mode: Enabled" "${debug}"
# Ensure variable is exported
eval "export ${varname}=1"
else
log "info" "PHP 5.2 compatibility mode: Disabled" "${debug}"
# Ensure variable is exported
eval "export ${varname}=0"
fi
fi
}
12 changes: 12 additions & 0 deletions data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export_docker_logs "DOCKER_LOGS" "${DEBUG_LEVEL}"
###
### Ensure PHP-FPM variables are exported
###
export_php_fpm_compat "COMPAT" "${DEBUG_LEVEL}"
export_php_fpm_enable "PHP_FPM_ENABLE" "${DEBUG_LEVEL}"
export_php_fpm_server_addr "PHP_FPM_SERVER_ADDR" "${DEBUG_LEVEL}"
export_php_fpm_server_port "PHP_FPM_SERVER_PORT" "${DEBUG_LEVEL}"
Expand Down Expand Up @@ -122,6 +123,17 @@ fi
## vhost-gen Configuration
#############################################################

###
### Ensure PHP 5.2 conmpat mode is applied
###
if [ "${COMPAT}" = "1" ]; then
# Replace current value 'FPM' with 'GENERIC'
log "info" "Setting PHP 5.2 compat mode" "${DEBUG_LEVEL}"
sed -i'' 's|\(ProxyFCGIBackendType\).*$|\1 GENERIC|g' /etc/vhost-gen/templates/apache24.yml
else
log "info" "Disabling PHP 5.2 compat mode" "${DEBUG_LEVEL}"
fi

###
### Enable and configure PHP-FPM
###
Expand Down

0 comments on commit 6d4ede5

Please sign in to comment.