From 04c454c2384f623e2610e51e6fb6a062ff23bff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 21 Feb 2020 09:37:00 +0100 Subject: [PATCH] Add a small shell helper to update the default PHP-FPM socket location --- debian/php-common.install | 1 + php-fpm-socket-helper | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 php-fpm-socket-helper diff --git a/debian/php-common.install b/debian/php-common.install index 336a9dc..d353818 100644 --- a/debian/php-common.install +++ b/debian/php-common.install @@ -1,3 +1,4 @@ +php-fpm-socket-helper /usr/lib/php/ php-helper /usr/lib/php/ php-maintscript-helper /usr/lib/php/ phpenmod /usr/sbin/ diff --git a/php-fpm-socket-helper b/php-fpm-socket-helper new file mode 100755 index 0000000..b541c25 --- /dev/null +++ b/php-fpm-socket-helper @@ -0,0 +1,25 @@ +#!/bin/sh + +DEFAULT_SOCKET="${2}" +POOL_FILE="${3}" +PRIORITY="${4}" + +[ -r "${POOL_FILE}" ] || exit 0 + +SOCKET=$(sed -n 's/^listen[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/\1/p' "${POOL_FILE}") + +[ -S "${SOCKET}" ] || exit 0 + +case "$1" in + start|install) + /usr/bin/update-alternatives --quiet --install "${DEFAULT_SOCKET}" php-fpm.sock "${SOCKET}" "${PRIORITY}" 2>/dev/null + ;; + stop|remove) + /usr/bin/update-alternatives --quiet --remove php-fpm.sock "${SOCKET}" 2>/dev/null + ;; + *) + exit 1 + ;; +esac + +exit 0