From 2ef71aa2e8c67b0ef534e15647198f8396a91777 Mon Sep 17 00:00:00 2001 From: eroncero Date: Mon, 18 Aug 2025 20:35:04 +0200 Subject: [PATCH] It should copy all php config files in /mnt/copy-config. It looks for version directory. --- .../project/entrypoint/copy-config.sh | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/multi-php-fpm-srv/project/entrypoint/copy-config.sh b/multi-php-fpm-srv/project/entrypoint/copy-config.sh index ad1f9c4..8847a06 100644 --- a/multi-php-fpm-srv/project/entrypoint/copy-config.sh +++ b/multi-php-fpm-srv/project/entrypoint/copy-config.sh @@ -1,4 +1,30 @@ -#!/bin/sh +#!/bin/bash -# Copy all .conf files from source to destination -cp /mnt/place-config/etc/php/8.2/fpm/pool.d/*.conf /etc/php/8.2/fpm/pool.d/ +# Source and destination base directories +SRC_BASE="/mnt/place-config/etc/php" +DEST_BASE="/etc/php" + +# Find all PHP versions in source directory +for php_version in $(ls -d ${SRC_BASE}/*/ | grep -oP '(?<=/php/)[^/]+'); do + src_dir="${SRC_BASE}/${php_version}/fpm/pool.d" + dest_dir="${DEST_BASE}/${php_version}/fpm/pool.d" + + # Check if source directory exists and has .conf files + if [ -d "$src_dir" ] && [ -n "$(ls ${src_dir}/*.conf 2>/dev/null)" ]; then + echo "Processing PHP ${php_version}..." + + # Create destination directory if it doesn't exist + mkdir -p "$dest_dir" + + # Copy files with proper permissions + cp -v "${src_dir}"/*.conf "$dest_dir"/ + chmod 644 "${dest_dir}"/*.conf + chown root:root "${dest_dir}"/*.conf + + echo "Copied $(ls ${src_dir}/*.conf | wc -l) .conf files for PHP ${php_version}" + else + echo "No .conf files found for PHP ${php_version} in ${src_dir}" + fi +done + +echo "Configuration copy complete."