0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-06-16 16:14:47 +02:00

Add env variables to change UID/GID of www-data

Signed-off-by: Jan Dittrich <mail@jand.one>
This commit is contained in:
Jan Dittrich 2020-12-10 21:38:36 +01:00
parent f87624c6eb
commit bf1d80595b
14 changed files with 164 additions and 0 deletions

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -6,6 +6,7 @@ RUN set -ex; \
\ \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
shadow \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ rm /var/spool/cron/crontabs/root; \

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -6,6 +6,7 @@ RUN set -ex; \
\ \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
shadow \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ rm /var/spool/cron/crontabs/root; \

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -6,6 +6,7 @@ RUN set -ex; \
\ \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
shadow \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ rm /var/spool/cron/crontabs/root; \

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip

View file

@ -5,6 +5,7 @@ RUN set -ex; \
\ \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
shadow \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ rm /var/spool/cron/crontabs/root; \

View file

@ -43,6 +43,22 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi
if expr "$1" : "apache" 1>/dev/null; then if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip a2disconf remoteip