docker-GLPI/web-builder/service/php
2024-03-28 18:20:48 +01:00

44 lines
1.1 KiB
Bash

#!/bin/sh
NORMAL=''
RED=''
GREEN=''
msglog() {
case "${1}" in
green)
TEXT_COLOR="${GREEN}"
;;
red)
TEXT_COLOR="${RED}"
;;
normal)
TEXT_COLOR="${NORMAL}"
;;
esac
DATE=$(date '+%Y %b %d %H:%M:%S')
echo ${DATE} ${TEXT_COLOR}${2}${NORMAL}
}
updatephpini() {
variable=$1
value=$2
file="/etc/php82/php.ini"
if [ ! -z "${value}" ] ; then
msglog green "Updating $variable to $value in $file"
if grep "^${variable}" "${file}" > /dev/null 2<&1 ; then
sed -i "s@^\(${variable}\s*=\).*@\1 ${value}@g" "${file}"
else
echo ${variable} = ${value} >> ${file}
fi
fi
}
updatephpini memory_limit ${PHP_MEMORY_LIMIT}
updatephpini upload_max_filesize ${PHP_UPLOAD_MAX_FILESIZE}
updatephpini post_max_size ${PHP_POST_MAX_SIZE}
updatephpini date.timezone ${PHP_DATE_TIMEZONE}
updatephpini max_input_vars ${PHP_MAX_INPUT_VARS}
updatephpini session.cookie_httponly 1
updatephpini session.gc_maxlifetime ${PHP_SESSION_GC_MAXLIFETIME}