|
1 | 1 | #!/bin/sh |
2 | 2 | set -e |
3 | 3 |
|
4 | | -if [ -n "$HOST_UID" ] && [ -n "$HOST_GID" ]; then |
5 | | - WWW_DATA_CURRENT_UID=$(id -u www-data) |
6 | | - WWW_DATA_CURRENT_GID=$(id -g www-data) |
7 | | - |
8 | | - if [ "$WWW_DATA_CURRENT_UID" != "$HOST_UID" ] || [ "$WWW_DATA_CURRENT_GID" != "$HOST_GID" ]; then |
9 | | - groupmod -o -g "$HOST_GID" www-data |
10 | | - usermod -o -u "$HOST_UID" www-data |
| 4 | +if [ "$(id -u)" = "0" ]; then |
| 5 | + if [ -n "$HOST_UID" ] && [ -n "$HOST_GID" ]; then |
| 6 | + WWW_DATA_CURRENT_UID=$(id -u www-data) |
| 7 | + WWW_DATA_CURRENT_GID=$(id -g www-data) |
| 8 | + |
| 9 | + if [ "$WWW_DATA_CURRENT_UID" != "$HOST_UID" ] || [ "$WWW_DATA_CURRENT_GID" != "$HOST_GID" ]; then |
| 10 | + groupmod -o -g "$HOST_GID" www-data |
| 11 | + usermod -o -u "$HOST_UID" www-data |
| 12 | + fi |
11 | 13 | fi |
12 | | -fi |
13 | 14 |
|
14 | | -if [ -f /etc/nginx/custom.conf ]; then |
15 | | - cp /etc/nginx/custom.conf /etc/nginx/conf.d/default.conf |
16 | | -else |
17 | | - envsubst '$NGINX_ROOT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf |
18 | | -fi |
| 15 | + if [ -f /etc/nginx/custom.conf ]; then |
| 16 | + cp /etc/nginx/custom.conf /etc/nginx/conf.d/default.conf |
| 17 | + else |
| 18 | + envsubst '$NGINX_ROOT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf |
| 19 | + fi |
19 | 20 |
|
20 | | -if [ "${VITE_ENABLED}" = "true" ]; then |
21 | | - envsubst '$PROJECT_ROOT' < /etc/supervisor/conf.d/vite.conf.template >> /etc/supervisor/conf.d/supervisord.conf |
22 | | -fi |
| 21 | + if [ "${VITE_ENABLED}" = "true" ]; then |
| 22 | + envsubst '$PROJECT_ROOT' < /etc/supervisor/conf.d/vite.conf.template >> /etc/supervisor/conf.d/supervisord.conf |
| 23 | + fi |
| 24 | + |
| 25 | + chown -R www-data:www-data /var/log/supervisor |
| 26 | + chown -R www-data:www-data /var/log/nginx |
| 27 | + chown -R www-data:www-data /var/lib/nginx |
| 28 | + chown -R www-data:www-data /var/run |
| 29 | + chown -R www-data:www-data /home/wwwroot |
23 | 30 |
|
24 | | -if [ -n "$HOST_UID" ] && [ -n "$HOST_GID" ]; then |
25 | | - exec gosu www-data "$@" |
26 | | -else |
27 | | - exec "$@" |
| 31 | + exec gosu www-data "$0" "$@" |
28 | 32 | fi |
| 33 | + |
| 34 | +exec "$@" |
0 commit comments