Update 8.4/entrypoint.sh

This commit is contained in:
2025-12-26 11:36:55 +09:00
parent f399a9c25a
commit 627b404081

View File

@ -1,15 +1,40 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -Eeuo pipefail
# www-data 권한 정리 (카페24와 유사)
chown -R www-data:www-data /var/www/html
if [[ -n "${PUID}" ]]
then
usermod -u ${PUID} www-data
fi
if [[ -n "${PGID}" ]]
then
groupmod -g ${PGID} www-data
fi
if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
uid="$(id -u)"
gid="$(id -g)"
if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
group="${APACHE_RUN_GROUP:-www-data}"
# strip off any '#' symbol ('#1000' is valid syntax for Apache)
pound='#'
user="${user#$pound}"
group="${group#$pound}"
;;
*) # php-fpm
user='www-data'
group='www-data'
;;
esac
else
user="$uid"
group="$gid"
fi
# index.php 없으면 테스트용 생성
if [ ! -f /var/www/html/index.php ]; then
cat <<'EOF' > /var/www/html/index.php
<?php
phpinfo();
EOF
fi
exec "$@"