diff --git a/Containers/nextcloud/config/postgresql.php b/Containers/nextcloud/config/postgresql.php new file mode 100644 index 00000000..f086b297 --- /dev/null +++ b/Containers/nextcloud/config/postgresql.php @@ -0,0 +1,7 @@ + 'oc_' . getenv('POSTGRES_USER'), + 'dbpassword' => getenv('POSTGRES_PASSWORD'), + 'db_name' => getenv('POSTGRES_DB'), + 'dbpersistent' => true, +); diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index b990d6c5..95c0af90 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -6,23 +6,13 @@ while ! sudo -u www-data nc -z "$POSTGRES_HOST" 5432; do sleep 5 done -# Use the correct Postgres username -POSTGRES_USER="oc_$POSTGRES_USER" -export POSTGRES_USER - -# Fix false database connection on old instances +# Wait for database to actually start if [ -f "/var/www/html/config/config.php" ]; then sleep 2 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 - if [ "$POSTGRES_USER" = "oc_nextcloud" ] && [ "$POSTGRES_DB" = "nextcloud_database" ] && echo "$POSTGRES_PASSWORD" | grep -q '^[a-z0-9]\+$'; then - # This was introduced with https://github.com/nextcloud/all-in-one/pull/218 - sed -i "s|'dbuser'.*=>.*$|'dbuser' => '$POSTGRES_USER',|" /var/www/html/config/config.php - sed -i "s|'dbpassword'.*=>.*$|'dbpassword' => '$POSTGRES_PASSWORD',|" /var/www/html/config/config.php - sed -i "s|'db_name'.*=>.*$|'db_name' => '$POSTGRES_DB',|" /var/www/html/config/config.php - fi fi # Trust additional Cacerts, if the user provided $TRUSTED_CACERTS_DIR diff --git a/Containers/postgresql/start.sh b/Containers/postgresql/start.sh index 75a86abd..642039d4 100644 --- a/Containers/postgresql/start.sh +++ b/Containers/postgresql/start.sh @@ -148,13 +148,6 @@ fi # Modify postgresql.conf if [ -f "/var/lib/postgresql/data/postgresql.conf" ]; then - echo "Setting max connections..." - MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo) - MAX_CONNECTIONS=$((MEMORY/50+3)) - if [ -n "$MAX_CONNECTIONS" ]; then - sed -i "s|^max_connections =.*|max_connections = $MAX_CONNECTIONS|" "/var/lib/postgresql/data/postgresql.conf" - fi - # Modify conf if grep -q "#log_checkpoints" /var/lib/postgresql/data/postgresql.conf; then sed -i 's|#log_checkpoints.*|log_checkpoints = off|' /var/lib/postgresql/data/postgresql.conf