change entrypoint of nextcloud container to root

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-10-11 20:29:52 +02:00
parent ce47fab555
commit d3d8b11e28
6 changed files with 27 additions and 20 deletions

View file

@ -202,6 +202,7 @@ RUN set -ex; \
postgresql-client \
tzdata \
mawk \
sudo \
; \
rm -rf /var/lib/apt/lists/*
@ -249,7 +250,8 @@ VOLUME /mnt/ncdata
# Give root a random password
RUN echo "root:$(openssl rand -base64 12)" | chpasswd
USER www-data
USER root
ENTRYPOINT ["/start.sh"]
CMD ["sudo", "-u", "www-data", "/usr/bin/supervisord", "-c", "/supervisord.conf"]
HEALTHCHECK CMD (nc -z localhost 9000 && nc -z localhost 7867) || exit 1
HEALTHCHECK CMD (sudo -u www-data nc -z localhost 9000 && sudo -u www-data nc -z localhost 7867) || exit 1

View file

@ -32,8 +32,8 @@ fi
touch "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" &>/dev/null
if ! [ -f "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" ]; then
echo "The www-data user doesn't seem to have access rights in the datadir.
Did you maybe change the datadir and did forget to apply the correct permissions?
See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir
Most likely are the files located on a drive that does not follow linux permissions.
Please adjust the permissions like mentioned below.
The found permissions are:
$(stat -c "%u:%g %a" "$NEXTCLOUD_DATA_DIR")
(userID:groupID permissions)

View file

@ -1,5 +1,9 @@
#!/bin/bash
if [[ "$EUID" = 0 ]]; then
sudo -u www-data -s
fi
SUBJECT="$1"
MESSAGE="$2"

View file

@ -1,7 +1,7 @@
#!/bin/bash
# Only start container if database is accessible
while ! nc -z "$POSTGRES_HOST" 5432; do
while ! sudo -u www-data nc -z "$POSTGRES_HOST" 5432; do
echo "Waiting for database to start..."
sleep 5
done
@ -13,7 +13,7 @@ export POSTGRES_USER
# Fix false database connection on old instances
if [ -f "/var/www/html/config/config.php" ]; then
sleep 2
while ! psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB" -c "select now()"; do
while ! sudo -u www-data psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB" -c "select now()"; do
echo "Waiting for the database to start..."
sleep 5
done
@ -28,8 +28,16 @@ if [ -n "$TRUSTED_CACERTS_DIR" ]; then
update-ca-certificates
fi
# Check datadir permissions
sudo -u www-data touch "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" &>/dev/null
if ! [ -f "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" ]; then
chown -R www-data:root "$NEXTCLOUD_DATA_DIR"
chmod 750 -R "$NEXTCLOUD_DATA_DIR"
fi
rm -f "$NEXTCLOUD_DATA_DIR/this-is-a-test-file"
# Run original entrypoint
if ! bash /entrypoint.sh; then
if ! sudo -u www-data bash /entrypoint.sh; then
exit 1
fi