mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-09-21 07:16:09 +08:00
make database connections persistant
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
b076d5ea1a
commit
dace781b4e
7
Containers/nextcloud/config/postgresql.php
Normal file
7
Containers/nextcloud/config/postgresql.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$CONFIG = array (
|
||||||
|
'dbuser' => 'oc_' . getenv('POSTGRES_USER'),
|
||||||
|
'dbpassword' => getenv('POSTGRES_PASSWORD'),
|
||||||
|
'db_name' => getenv('POSTGRES_DB'),
|
||||||
|
'dbpersistent' => true,
|
||||||
|
);
|
|
@ -6,23 +6,13 @@ while ! sudo -u www-data nc -z "$POSTGRES_HOST" 5432; do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
# Use the correct Postgres username
|
# Wait for database to actually start
|
||||||
POSTGRES_USER="oc_$POSTGRES_USER"
|
|
||||||
export POSTGRES_USER
|
|
||||||
|
|
||||||
# Fix false database connection on old instances
|
|
||||||
if [ -f "/var/www/html/config/config.php" ]; then
|
if [ -f "/var/www/html/config/config.php" ]; then
|
||||||
sleep 2
|
sleep 2
|
||||||
while ! sudo -u www-data 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..."
|
echo "Waiting for the database to start..."
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
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
|
fi
|
||||||
|
|
||||||
# Trust additional Cacerts, if the user provided $TRUSTED_CACERTS_DIR
|
# Trust additional Cacerts, if the user provided $TRUSTED_CACERTS_DIR
|
||||||
|
|
|
@ -148,13 +148,6 @@ fi
|
||||||
|
|
||||||
# Modify postgresql.conf
|
# Modify postgresql.conf
|
||||||
if [ -f "/var/lib/postgresql/data/postgresql.conf" ]; then
|
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
|
# Modify conf
|
||||||
if grep -q "#log_checkpoints" /var/lib/postgresql/data/postgresql.conf; then
|
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
|
sed -i 's|#log_checkpoints.*|log_checkpoints = off|' /var/lib/postgresql/data/postgresql.conf
|
||||||
|
|
Loading…
Reference in a new issue