-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathentrypoint.sh
executable file
·83 lines (61 loc) · 1.86 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
set -e
# Check if incomming command contains flags.
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
# Replace environment variables if `ENV_SUBSTITUTION_ENABLE=true`
if [[ -n "$ENV_SUBSTITUTION_ENABLE" ]] && [[ "$ENV_SUBSTITUTION_ENABLE" = "true" ]]; then
/envsubst.sh
fi
# Disable PHP extensions on demand
extensions=${PHP_DISABLE_EXTENSIONS//[[:blank:]]/}
extensions=${extensions//,/ }
extensions_count=$(echo $extensions | grep -o " " | wc -l)
if [[ -n "$extensions" ]]; then extensions_count=$((extensions_count + 1)); fi
if [[ $extensions_count -gt 0 ]]; then
echo "Disabling $extensions_count extension(s): $(echo $extensions)"
ext_dir=$(php -r 'echo ini_get("extension_dir");')
for ext in $extensions; do
disabled=0
ext_file="$ext_dir/$ext.so"
if [[ -f "$ext_file" ]]; then
mv -f $ext_file "$ext_file.disabled"
disabled=1
fi
ext_file_ini=${PHP_INI_DIR}/conf.d/docker-php-ext-$ext.ini
if [[ -f "$ext_file_ini" ]]; then
mv -f $ext_file_ini "$ext_file_ini.disabled"
disabled=1
fi
if [[ "$disabled" = 1 ]]; then
echo "OK: '$ext' disabled"
fi
done
echo "Verifying PHP extensions..."
php -v
php-fpm --test
PHP_ERROR="$(php -v 2>&1 1>/dev/null)"
if [ -n "${PHP_ERROR}" ]; then
echo "${PHP_ERROR}"
false
fi
PHP_ERROR="$(php -i 2>&1 1>/dev/null)"
if [ -n "${PHP_ERROR}" ]; then
echo "${PHP_ERROR}"
false
fi
PHP_FPM_ERROR="$(php-fpm -v 2>&1 1>/dev/null)"
if [ -n "${PHP_FPM_ERROR}" ]; then
echo "${PHP_FPM_ERROR}"
false
fi
PHP_FPM_ERROR="$(php-fpm -i 2>&1 1>/dev/null)"
if [ -n "${PHP_FPM_ERROR}" ]; then
echo "${PHP_FPM_ERROR}"
false
fi
echo "Tests were successful!"
echo
fi
exec "$@"