Files
lemp-dockerized/multi-php-fpm-srv/project/entrypoint/copy-config.sh
2025-08-18 20:56:09 +02:00

39 lines
1.2 KiB
Bash

#!/bin/bash
set -euo pipefail
# Configuration
SRC_BASE="/mnt/place-config/etc/php"
DEST_BASE="/etc/php"
# Determine which PHP versions to process
[ -z "${PHP_VERSIONS:-}" ] && [ -z "${BUILDTIME_PHP_VER_INST:-}" ] && exit 0
VERSIONS_TO_PROCESS="${PHP_VERSIONS:-$BUILDTIME_PHP_VER_INST}"
echo "Processing PHP versions: ${VERSIONS_TO_PROCESS}"
for version in $VERSIONS_TO_PROCESS; do
src_dir="${SRC_BASE}/${version}/fpm/pool.d"
dest_dir="${DEST_BASE}/${version}/fpm/pool.d"
# Skip if source doesn't exist
[ ! -d "$src_dir" ] && continue
# Process each .conf file
find "$src_dir" -maxdepth 1 -name '*.conf' -print0 | while IFS= read -r -d '' conf_file; do
filename=$(basename "$conf_file")
echo "Copying: ${filename} (PHP ${version})"
cp -f "$conf_file" "$dest_dir/"
chmod 644 "${dest_dir}/${filename}"
chown root:root "${dest_dir}/${filename}"
# Verify copy
cmp -s "$conf_file" "${dest_dir}/${filename}" || {
echo "ERROR: Copy verification failed for ${filename}"
exit 1
}
done
done
echo "Configuration copy completed successfully"