Skip to content

Commit 9d6a340

Browse files
committed
php-ext
1 parent f2c43a8 commit 9d6a340

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

rootfs/usr/local/bin/php-ext

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
php_version=$(php -v 2>/dev/null | grep "^PHP " | head -n 1 | awk '{print $2}')
77
php_base=${php_version:0:3}
8+
os=$(grep -o '^ID=.*' /etc/os-release | cut -d = -f2)
89

9-
case "$(container_info distro)" in
10+
case "${os}" in
1011
"alpine" )
1112
case "${php_version:0:3}" in
1213
8*)
@@ -30,7 +31,7 @@ disable_module() {
3031
"all" )
3132
echo "**Disabling All Modules"
3233
for module in "${modules_available}"/*.ini ; do
33-
case "$(container_info distro)" in
34+
case "${os}" in
3435
"alpine" )
3536
rm -f "${php_prefix}"/conf.d/$(cat ${module} | grep ";priority" | cut -d = -f 2)-$(basename ${module})
3637
;;
@@ -45,7 +46,7 @@ disable_module() {
4546
for module in $php_env_modules_enabled ; do
4647
if [ -f "${modules_available}/${module}.ini" ]; then
4748
echo "Disabling ${module}"
48-
case "$(container_info distro)" in
49+
case "${os}" in
4950
"alpine" )
5051
rm -f ${php_prefix}/conf.d/$(cat ${modules_available}/${module}.ini | grep ";priority" | cut -d = -f 2)-${module}.ini
5152
;;
@@ -79,7 +80,7 @@ disable_module() {
7980

8081
if [[ "$MATCH" -lt 1 ]] ; then
8182
echo "Disabling $(basename $module .ini)"
82-
case "$(container_info distro)" in
83+
case "${os}" in
8384
"alpine" )
8485
rm -f "${php_prefix}"conf.d/$(cat ${module} | grep ";priority" | cut -d = -f 2)-$(basename ${module})
8586
;;
@@ -91,7 +92,7 @@ disable_module() {
9192
done
9293
;;
9394
reset )
94-
case "$(container_info distro)" in
95+
case "${os}" in
9596
"alpine" )
9697
rm -rf ${php_prefix}conf.d/*
9798
;;
@@ -103,7 +104,7 @@ disable_module() {
103104
* )
104105
if [ -f "${modules_available}/${1}.ini" ]; then
105106
echo "Disabling ${1}"
106-
case "$(container_info distro)" in
107+
case "${os}" in
107108
"alpine" )
108109
rm -f ${php_prefix}conf.d/$(cat ${modules_available}/${1}.ini | grep ";priority" | cut -d = -f 2)-$1.ini
109110
;;
@@ -129,7 +130,7 @@ enable_module () {
129130
echo "** Enabling All Modules"
130131
for module in "${modules_available}"/*.ini; do
131132
echo "Enabling ${module}"
132-
case "$(container_info distro)" in
133+
case "${os}" in
133134
"alpine" )
134135
ln -sf "${module}" "${php_prefix}"/conf.d/$(cat "${module}" | grep ";priority" | cut -d = -f 2)-$(basename "${module}")
135136
;;
@@ -144,7 +145,7 @@ enable_module () {
144145
for module in ${php_env_modules_enabled} ; do
145146
if [ -f "${modules_available}"/"${module}".ini ]; then
146147
echo "Enabling '$(basename "${module}" .ini)' module"
147-
case "$(container_info distro)" in
148+
case "${os}" in
148149
"alpine" )
149150
ln -sf "${modules_available}/${module}.ini" ${php_prefix}/conf.d/$(cat ${modules_available}/${module}.ini | grep ";priority" | cut -d = -f 2)-${module}.ini
150151
if [ "${php_major_version}" != "8" ] ; then
@@ -176,7 +177,7 @@ enable_module () {
176177
for module in "${modules_available}"/*.ini; do
177178
if ! grep -w -i -q "$(basename ${module} .ini)" "${php_env_modules_enabled}"; then
178179
echo "Enabling $(basename ${module} .ini)"
179-
case "$(container_info distro)" in
180+
case "${os}" in
180181
"alpine" )
181182
ln -sf "${module}" ${php_prefix}conf.d/$(cat ${module} | grep ";priority" | cut -d = -f 2)-$(basename ${module})
182183
;;
@@ -200,7 +201,7 @@ enable_module () {
200201

201202
if [[ "$MATCH" -lt 1 ]] ; then
202203
echo "Enabling $(basename ${module} .ini)"
203-
case "$(container_info distro)" in
204+
case "${os}" in
204205
"alpine" )
205206
ln -sf "${module}" ${php_prefix}conf.d/$(cat ${module} | grep ";priority" | cut -d = -f 2)-$(basename ${module})
206207
;;
@@ -214,7 +215,7 @@ enable_module () {
214215
* )
215216
if [ -f "${modules_available}/$1.ini" ]; then
216217
echo "Enabling $1"
217-
case "$(container_info distro)" in
218+
case "${os}" in
218219
"alpine" )
219220
ln -sf "${modules_available}/$1.ini" ${php_prefix}conf.d/$(cat ${modules_available}/${1}.ini | grep ";priority" | cut -d = -f 2)-$1.ini
220221
;;
@@ -328,7 +329,7 @@ EOF
328329
}
329330

330331
prepare() {
331-
case "$(container_info distro)" in
332+
case "${os}" in
332333
"alpine" )
333334
mkdir -p ${modules_available}
334335
for module in ${php_prefix}/conf.d/*.ini; do
@@ -353,6 +354,15 @@ get_php_env_modules_enabled() {
353354
set -o posix; set | sort | grep "^PHP_MODULE_ENABLE_.*=" | grep -i TRUE | cut -d _ -f 4- | cut -d = -f 1 | tr A-Z a-z
354355
}
355356

357+
silent() {
358+
## Quiet down output
359+
if [ "${DEBUG_MODE}" = "true" ] || [ "${SHOW_OUTPUT,,}" = "true" ] || [ "${CONTAINER_LOG_LEVEL,,}" = "debug" ] ; then
360+
"$@"
361+
else
362+
"$@" > /dev/null 2>&1
363+
fi
364+
}
365+
356366
if [ "${PHP_MODULE_ENABLE_OPENSSL,,}" = "true" ] && [ ! -f "${modules_available}"/openssl.ini ]; then
357367
export PHP_MODULE_ENABLE_OPENSSL=FALSE
358368
fi
@@ -388,3 +398,4 @@ else
388398
echo "PHP Module Tool"
389399
echo "Commands: enable | disable | list | info | help"
390400
fi
401+

0 commit comments

Comments
 (0)