Works if you run it manually in the container
This commit is contained in:
@@ -27,7 +27,7 @@ services:
|
||||
environment:
|
||||
- PHP_VERSIONS=${PHP_VERSIONS} # Inherits from .env
|
||||
volumes:
|
||||
- ./mnt/place-config/etc/php/8.2:/mnt/place-config/etc/php/8.2 # Config ready to be copied into the container.
|
||||
- ./mnt/place-config/etc/php:/mnt/place-config/etc/php # Config ready to be copied into the container.
|
||||
- ./multi-php-fpm-srv/run/php:/run/php
|
||||
- ./mariadb-srv/run/mysql:/run/mysqld # php-mysql should be able connecting to the MariaDB socket.
|
||||
|
||||
|
@@ -5,34 +5,52 @@ set -euo pipefail
|
||||
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}"
|
||||
# Use both environment variables if they exist
|
||||
VERSIONS_TO_PROCESS="$(echo "${PHP_VERSIONS:-} ${BUILDTIME_PHP_VER_INST:-}" | xargs -n1 | sort -u | xargs)"
|
||||
|
||||
echo "Processing PHP versions: ${VERSIONS_TO_PROCESS}"
|
||||
if [ -z "$VERSIONS_TO_PROCESS" ]; then
|
||||
echo "ℹ️ No PHP versions specified in environment variables"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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
|
||||
echo -e "\n📦 Checking PHP ${version}..."
|
||||
|
||||
# Verify source directory exists
|
||||
if [ ! -d "$src_dir" ]; then
|
||||
echo " ⚠️ Source directory not found: $src_dir"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Count .conf files
|
||||
conf_files=("$src_dir"/*.conf)
|
||||
if [ ${#conf_files[@]} -eq 0 ]; then
|
||||
echo " ✅ No .conf files to copy (directory empty)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Process each .conf file
|
||||
find "$src_dir" -maxdepth 1 -name '*.conf' -print0 | while IFS= read -r -d '' conf_file; do
|
||||
copied=0
|
||||
for conf_file in "${conf_files[@]}"; do
|
||||
if [ ! -f "$conf_file" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
filename=$(basename "$conf_file")
|
||||
echo "Copying: ${filename} (PHP ${version})"
|
||||
echo " ➤ Copying: $filename"
|
||||
|
||||
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
|
||||
}
|
||||
cp -f "$conf_file" "$dest_dir/" && \
|
||||
chmod 644 "${dest_dir}/${filename}" && \
|
||||
chown root:root "${dest_dir}/${filename}" && \
|
||||
copied=$((copied + 1))
|
||||
done
|
||||
|
||||
echo " ✔ Copied $copied files for PHP $version"
|
||||
done
|
||||
|
||||
echo "Configuration copy completed successfully"
|
||||
echo -e "\n✅ Configuration copy completed"
|
||||
|
Reference in New Issue
Block a user