-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from devilbox/release-0.19
Feature: Disable PHP modules
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Dockerfiles/prod/data/docker-entrypoint.d/38-disable-modules.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
|
||
############################################################ | ||
# Functions | ||
############################################################ | ||
|
||
### | ||
### Disable PHP Modules | ||
### | ||
disable_modules() { | ||
local mod_varname="${1}" | ||
local debug="${2}" | ||
local mod_path="/usr/local/etc/php/conf.d" | ||
|
||
if ! env_set "${mod_varname}"; then | ||
log "info" "\$${mod_varname} not set. Not disabling any PHP modules." "${debug}" | ||
else | ||
mods="$( env_get "${mod_varname}" )" | ||
|
||
if [ -z "${mods}" ]; then | ||
log "warn" "\$${mod_varname} set, but empty. Not disabling any PHP modules." "${debug}" | ||
else | ||
log "info" "Disabling the following PHP modules: ${mods}" "${debug}" | ||
fi | ||
|
||
while read -r mod; do | ||
#for mod in ${mods//,/ }; do | ||
mod="$( echo "${mod}" | xargs )" # trim | ||
|
||
# Find all config files that enable that module | ||
files="$( grep -Er "^(zend_)?extension.*(=|/)${mod}\.so" "${mod_path}" || true )" | ||
|
||
if [ -n "${files}" ]; then | ||
while read -r f; do | ||
# Get filename | ||
f="$( echo "${f}" | awk -F':' '{ print $1 }' )" | ||
# Remove file | ||
run "rm ${f}" "${debug}" | ||
done <<< "${files}" | ||
fi | ||
done <<< "$( echo "${mods}" | tr ',' '\n' )" | ||
#done | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters