From b7ba43553b5af90df2d18e83f4ad86b7820553dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Thu, 16 May 2024 17:05:45 +0200 Subject: [PATCH] [__php_fpm*] add support for Debian and Ubuntu --- type/__php_fpm/files/php.ini.sh | 2 +- type/__php_fpm/man.rst | 3 +-- type/__php_fpm/manifest | 45 ++++++++++++++++++++++++--------- type/__php_fpm_pool/man.rst | 2 +- type/__php_fpm_pool/manifest | 24 +++++++++++------- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/type/__php_fpm/files/php.ini.sh b/type/__php_fpm/files/php.ini.sh index 8fbc4ac..ec7e446 100755 --- a/type/__php_fpm/files/php.ini.sh +++ b/type/__php_fpm/files/php.ini.sh @@ -20,7 +20,7 @@ variables_order = "GPCS" zend.assertions = -1 ; Local custom variations -include_path = ".:/usr/share/php${PHPVER:?}" +include_path = ".:${PHP_INCLUDEDIR}" memory_limit = ${MEMORY_LIMIT:?} post_max_size = ${UPLOAD_MAX_FILESIZE:?} upload_max_filesize = ${UPLOAD_MAX_FILESIZE:?} diff --git a/type/__php_fpm/man.rst b/type/__php_fpm/man.rst index 08b479e..4306687 100644 --- a/type/__php_fpm/man.rst +++ b/type/__php_fpm/man.rst @@ -12,8 +12,7 @@ This type installs and configures PHP-FPM for a given version of PHP. It is expected to be used in combination with cdist-type__php_fpm_pool, which configures specific pools. -Note that currently, this type is only implemented for Alpine Linux. - +This type supports Debian, Ubuntu and Alpine Linux. REQUIRED PARAMETERS ------------------- diff --git a/type/__php_fpm/manifest b/type/__php_fpm/manifest index 84c4383..9c32716 100644 --- a/type/__php_fpm/manifest +++ b/type/__php_fpm/manifest @@ -6,18 +6,39 @@ PHPVER=$(cat "${__object:?}/parameter/php-version") export PHPVER case "$os" in -'alpine') - package="php${PHPVER}-fpm" - service="php-fpm${PHPVER}" - opcache_package="php${PHPVER}-opcache" - apcu_package="php${PHPVER}-pecl-apcu" - ;; + 'alpine') + # Alpine packages looks like php81-fpm - we make sure to remove dots from user + # input. + PHPVER=$(echo "$PHPVER" | tr -d '.') -*) - printf "Your operating system is currently not supported by this type\n" >&2 - printf "Please contribute an implementation for it if you can.\n" >&2 - exit 1 + package="php${PHPVER}-fpm" + opcache_package="php${PHPVER}-opcache" + apcu_package="php${PHPVER}-pecl-apcu" + + service="php-fpm${PHPVER}" + php_confdir="/etc/php${PHPVER}" + php_ini="${php_confdir:?}/php.ini" + + PHP_INCLUDEDIR="/usr/share/php${PHPVER:?}" + export PHP_INCLUDEDIR ;; + 'debian'|'ubuntu') + package="php${PHPVER}-fpm" + opcache_package="php${PHPVER}-opcache" + apcu_package="php${PHPVER}-apcu" + + service="php${PHPVER}-fpm" + php_confdir="/etc/php/${PHPVER}" + php_ini="${php_confdir:?}/fpm/php.ini" + + PHP_INCLUDEDIR="/usr/share/php/${PHPVER:?}" + export PHP_INCLUDEDIR + ;; + *) + printf "Your operating system is currently not supported by this type\n" >&2 + printf "Please contribute an implementation for it if you can.\n" >&2 + exit 1 + ;; esac __package "$package" @@ -40,8 +61,8 @@ export UPLOAD_MAX_FILESIZE mkdir -p "${__object:?}/files" "${__type:?}/files/php.ini.sh" >"${__object:?}/files/php.ini" -require="__package/$package" __file "/etc/php${PHPVER}/php.ini" \ +require="__package/$package" __file "${php_ini:?}" \ --mode 644 --source "${__object:?}/files/php.ini" \ --onchange "service $service restart" -require="__file/etc/php${PHPVER}/php.ini" __service "$service" --action start +require="__file/${php_ini:?}" __service "$service" --action start diff --git a/type/__php_fpm_pool/man.rst b/type/__php_fpm_pool/man.rst index cd96175..da6dd3a 100644 --- a/type/__php_fpm_pool/man.rst +++ b/type/__php_fpm_pool/man.rst @@ -13,7 +13,7 @@ This type configures a pool named after the `__object_id` for a specified PHP version. Note that this types expects a same-version cdist-type__php_fpm type to have been run first: the user is responsible for doing so. -Note that currently, this type is only implemented for Alpine Linux. +This type supports Debian, Ubuntu and Alpine Linux. REQUIRED PARAMETERS diff --git a/type/__php_fpm_pool/manifest b/type/__php_fpm_pool/manifest index 49579d7..3c8491a 100644 --- a/type/__php_fpm_pool/manifest +++ b/type/__php_fpm_pool/manifest @@ -7,16 +7,22 @@ PHPVER=$(cat "${__object:?}/parameter/php-version") export PHPVER case "$os" in -'alpine') - service="php-fpm${PHPVER}" - : + 'alpine') + PHPVER=$(echo "$PHP_VERSION" | tr -d '.') + service="php-fpm${PHPVER}" + php_confdir="/etc/php${PHPVER}" + php_pooldir="${php_confdir:?}/php-fpm.d" ;; - -*) - printf "Your operating system is currently not supported by this type\n" >&2 - printf "Please contribute an implementation for it if you can.\n" >&2 - exit 1 + 'debian'|'ubuntu') + service="php${PHPVER}-fpm" + php_confdir="/etc/php/${PHPVER}" + php_pooldir="${php_confdir:?}/fpm/pool.d" ;; + *) + printf "Your operating system is currently not supported by this type\n" >&2 + printf "Please contribute an implementation for it if you can.\n" >&2 + exit 1 + ;; esac POOL_NAME="$name" @@ -29,6 +35,6 @@ export POOL_USER POOL_GROUP POOL_LISTEN_ADDR POOL_LISTEN_OWNER POOL_NAME mkdir -p "${__object:?}/files" "${__type:?}/files/www.conf.sh" >"${__object:?}/files/www.conf" -__file "/etc/php${PHPVER:?}/php-fpm.d/${name}.conf" \ +__file "${php_pooldir:?}/${name}.conf" \ --mode 644 --source "${__object:?}/files/www.conf" \ --onchange "service $service reload"