2021-11-30 11:20:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Only start container if database is accessible
|
2022-10-11 20:29:52 +02:00
|
|
|
while ! sudo -u www-data nc -z "$POSTGRES_HOST" 5432; do
|
2021-11-30 11:20:42 +01:00
|
|
|
echo "Waiting for database to start..."
|
|
|
|
|
sleep 5
|
|
|
|
|
done
|
|
|
|
|
|
2023-07-24 01:03:36 +02:00
|
|
|
# Wait for database to actually start
|
2022-08-15 13:38:24 +02:00
|
|
|
if [ -f "/var/www/html/config/config.php" ]; then
|
|
|
|
|
sleep 2
|
2022-10-11 20:29:52 +02:00
|
|
|
while ! sudo -u www-data psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB" -c "select now()"; do
|
2022-08-15 13:38:24 +02:00
|
|
|
echo "Waiting for the database to start..."
|
|
|
|
|
sleep 5
|
|
|
|
|
done
|
2022-02-12 02:29:20 +01:00
|
|
|
fi
|
|
|
|
|
|
2022-08-31 22:50:19 +02:00
|
|
|
# Trust additional Cacerts, if the user provided $TRUSTED_CACERTS_DIR
|
|
|
|
|
if [ -n "$TRUSTED_CACERTS_DIR" ]; then
|
2022-11-03 15:08:07 +01:00
|
|
|
echo "User required to trust additional CA certificates, running 'update-ca-certificates.'"
|
2022-08-31 22:50:19 +02:00
|
|
|
update-ca-certificates
|
|
|
|
|
fi
|
|
|
|
|
|
2023-01-03 02:01:03 +01:00
|
|
|
# Check if /dev/dri device is present and apply correct permissions
|
|
|
|
|
set -x
|
|
|
|
|
if ! [ -f "/dev-dri-group-was-added" ] && [ -n "$(find /dev -maxdepth 1 -mindepth 1 -name dri)" ] && [ -n "$(find /dev/dri -maxdepth 1 -mindepth 1 -name renderD128)" ]; then
|
|
|
|
|
# From https://github.com/pulsejet/memories/wiki/QSV-Transcoding#docker-installations
|
|
|
|
|
GID="$(stat -c "%g" /dev/dri/renderD128)"
|
|
|
|
|
groupadd -g "$GID" render2 || true # sometimes this is needed
|
|
|
|
|
GROUP="$(getent group "$GID" | cut -d: -f1)"
|
|
|
|
|
usermod -aG "$GROUP" www-data
|
|
|
|
|
touch "/dev-dri-group-was-added"
|
|
|
|
|
fi
|
|
|
|
|
set +x
|
|
|
|
|
|
2022-10-11 20:29:52 +02:00
|
|
|
# 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
|
2022-10-27 12:35:42 +02:00
|
|
|
sudo -u www-data rm -f "$NEXTCLOUD_DATA_DIR/this-is-a-test-file"
|
2022-10-11 20:29:52 +02:00
|
|
|
|
2022-11-08 21:38:31 +01:00
|
|
|
# Install additional dependencies
|
|
|
|
|
if [ -n "$ADDITIONAL_APKS" ]; then
|
|
|
|
|
if ! [ -f "/additional-apks-are-installed" ]; then
|
|
|
|
|
read -ra ADDITIONAL_APKS_ARRAY <<< "$ADDITIONAL_APKS"
|
|
|
|
|
for app in "${ADDITIONAL_APKS_ARRAY[@]}"; do
|
2022-11-10 17:31:06 +01:00
|
|
|
echo "Installing $app via apk..."
|
2022-11-10 18:04:12 +01:00
|
|
|
if ! apk add --no-cache "$app" >/dev/null; then
|
|
|
|
|
echo "The packet $app was not installed!"
|
|
|
|
|
fi
|
2022-11-08 21:38:31 +01:00
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
touch /additional-apks-are-installed
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Install additional php extensions
|
|
|
|
|
if [ -n "$ADDITIONAL_PHP_EXTENSIONS" ]; then
|
|
|
|
|
if ! [ -f "/additional-php-extensions-are-installed" ]; then
|
|
|
|
|
read -ra ADDITIONAL_PHP_EXTENSIONS_ARRAY <<< "$ADDITIONAL_PHP_EXTENSIONS"
|
|
|
|
|
for app in "${ADDITIONAL_PHP_EXTENSIONS_ARRAY[@]}"; do
|
2022-12-29 13:05:54 +01:00
|
|
|
if [ "$app" = imagick ]; then
|
|
|
|
|
echo "Enabling Imagick..."
|
|
|
|
|
if ! docker-php-ext-enable imagick >/dev/null; then
|
|
|
|
|
echo "Could not install PHP extension imagick!"
|
|
|
|
|
fi
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2022-11-10 19:16:33 +01:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
if [ "$PHP_DEPS_ARE_INSTALLED" != 1 ]; then
|
|
|
|
|
echo "Installing PHP build dependencies..."
|
2022-12-29 12:31:59 +01:00
|
|
|
if ! apk add --no-cache --virtual .build-deps \
|
|
|
|
|
libxml2-dev \
|
|
|
|
|
autoconf \
|
|
|
|
|
$PHPIZE_DEPS >/dev/null; then
|
2022-11-10 19:16:33 +01:00
|
|
|
echo "Could not install build-deps!"
|
|
|
|
|
fi
|
|
|
|
|
PHP_DEPS_ARE_INSTALLED=1
|
|
|
|
|
fi
|
2022-12-29 13:05:54 +01:00
|
|
|
if [ "$app" = inotify ]; then
|
2022-11-10 17:31:06 +01:00
|
|
|
echo "Installing $app via PECL..."
|
|
|
|
|
pecl install "$app" >/dev/null
|
2022-11-10 18:04:12 +01:00
|
|
|
if ! docker-php-ext-enable "$app" >/dev/null; then
|
|
|
|
|
echo "Could not install PHP extension $app!"
|
|
|
|
|
fi
|
|
|
|
|
elif [ "$app" = soap ]; then
|
|
|
|
|
echo "Installing $app from core..."
|
|
|
|
|
if ! docker-php-ext-install -j "$(nproc)" "$app" >/dev/null; then
|
|
|
|
|
echo "Could not install PHP extension $app!"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "Installing PHP extension $app ..."
|
2022-11-10 19:16:33 +01:00
|
|
|
if ! docker-php-ext-install -j "$(nproc)" "$app" >/dev/null; then
|
|
|
|
|
echo "Could not install $app from core. Trying to install from PECL..."
|
|
|
|
|
pecl install "$app" >/dev/null
|
2022-11-10 18:04:12 +01:00
|
|
|
if ! docker-php-ext-enable "$app" >/dev/null; then
|
2022-11-10 19:16:33 +01:00
|
|
|
echo "Could also not install $app from PECL. The PHP extensions was not installed!"
|
2022-11-10 18:04:12 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
2022-11-08 21:38:31 +01:00
|
|
|
fi
|
|
|
|
|
done
|
2022-11-10 20:46:18 +01:00
|
|
|
if [ "$PHP_DEPS_ARE_INSTALLED" = 1 ]; then
|
|
|
|
|
rm -rf /tmp/pear
|
|
|
|
|
runDeps="$( \
|
|
|
|
|
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
|
|
|
|
|
| tr ',' '\n' \
|
|
|
|
|
| sort -u \
|
|
|
|
|
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
|
|
|
|
)";
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
apk add --virtual .nextcloud-phpext-rundeps $runDeps >/dev/null
|
|
|
|
|
apk del .build-deps >/dev/null
|
|
|
|
|
fi
|
2022-11-08 21:38:31 +01:00
|
|
|
fi
|
|
|
|
|
touch /additional-php-extensions-are-installed
|
|
|
|
|
fi
|
|
|
|
|
|
2021-11-30 11:20:42 +01:00
|
|
|
# Run original entrypoint
|
2022-10-27 16:11:09 +02:00
|
|
|
if ! sudo -E -u www-data bash /entrypoint.sh; then
|
2021-11-30 11:20:42 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exec "$@"
|