41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
exec "$@"
|
|
|