notify-push: refactor to use Nextcloud's config.php directly

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L. 2026-01-15 17:37:54 +01:00
parent 1ed7196de6
commit 884ac9b87f
2 changed files with 3 additions and 61 deletions

View file

@ -3,12 +3,6 @@
if [ -z "$NEXTCLOUD_HOST" ]; then
echo "NEXTCLOUD_HOST needs to be provided. Exiting!"
exit 1
elif [ -z "$POSTGRES_HOST" ]; then
echo "POSTGRES_HOST needs to be provided. Exiting!"
exit 1
elif [ -z "$REDIS_HOST" ]; then
echo "REDIS_HOST needs to be provided. Exiting!"
exit 1
fi
# Only start container if nextcloud is accessible
@ -44,52 +38,9 @@ fi
echo "notify-push was started"
# Set a default value for POSTGRES_PORT
if [ -z "$POSTGRES_PORT" ]; then
POSTGRES_PORT=5432
fi
# Set a default for redis db index
if [ -z "$REDIS_DB_INDEX" ]; then
REDIS_DB_INDEX=0
fi
# Set a default value for REDIS_PORT
if [ -z "$REDIS_PORT" ]; then
REDIS_PORT=6379
fi
# Set a default for db type
if [ -z "$DATABASE_TYPE" ]; then
DATABASE_TYPE=postgres
elif [ "$DATABASE_TYPE" != postgres ] && [ "$DATABASE_TYPE" != mysql ]; then
echo "DB type must be either postgres or mysql"
exit 1
fi
# Use the correct Postgres username
if [ "$POSTGRES_USER" = nextcloud ]; then
POSTGRES_USER="oc_$POSTGRES_USER"
export POSTGRES_USER
fi
# URL-encode passwords
POSTGRES_PASSWORD="$(jq -rn --arg v "$POSTGRES_PASSWORD" '$v|@uri')"
REDIS_HOST_PASSWORD="$(jq -rn --arg v "$REDIS_HOST_PASSWORD" '$v|@uri')"
# Postgres root cert
if [ -f "/nextcloud/data/certificates/POSTGRES" ]; then
CERT_OPTIONS="?sslmode=verify-ca&sslrootcert=/nextcloud/data/certificates/ca-bundle.crt"
# Mysql root cert
elif [ -f "/nextcloud/data/certificates/MYSQL" ]; then
CERT_OPTIONS="?sslmode=verify-ca&ssl-ca=/nextcloud/data/certificates/ca-bundle.crt"
fi
# Set sensitive values as env
export DATABASE_URL="$DATABASE_TYPE://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB$CERT_OPTIONS"
export REDIS_URL="redis://$REDIS_USER:$REDIS_HOST_PASSWORD@$REDIS_HOST:$REDIS_PORT/$REDIS_DB_INDEX"
# Run it
/nextcloud/custom_apps/notify_push/bin/"$CPU_ARCH"/notify_push \
--database-prefix="oc_" \
--nextcloud-url "https://$NC_DOMAIN" \
--port 7867
--port 7867 \
/nextcloud/config/config.php
exec "$@"

View file

@ -303,17 +303,8 @@
}
],
"environment": [
"NC_DOMAIN=%NC_DOMAIN%",
"NEXTCLOUD_HOST=nextcloud-aio-nextcloud",
"TZ=%TIMEZONE%",
"REDIS_HOST=nextcloud-aio-redis",
"REDIS_PORT=6379",
"REDIS_HOST_PASSWORD=%REDIS_PASSWORD%",
"POSTGRES_HOST=nextcloud-aio-database",
"POSTGRES_PORT=5432",
"POSTGRES_PASSWORD=%DATABASE_PASSWORD%",
"POSTGRES_DB=nextcloud_database",
"POSTGRES_USER=nextcloud"
"TZ=%TIMEZONE%"
],
"restart": "unless-stopped",
"read_only": true,