From 6511c4c6e0bb5ff2584feb03600d40511a3c43f4 Mon Sep 17 00:00:00 2001 From: xis Date: Tue, 24 Oct 2023 20:54:42 +0200 Subject: [PATCH 1/8] fix groupfolders path in intergration tests --- src/integration/resources/db/data.sql | 2 +- .../__groupfolders/{ => 1}/Nextcloud community.jpg | Bin .../nextclouddlna/util/ServerInfoProvider.kt | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) rename src/integration/resources/nextcloud/app/data/__groupfolders/{ => 1}/Nextcloud community.jpg (100%) diff --git a/src/integration/resources/db/data.sql b/src/integration/resources/db/data.sql index 269d352..3937d21 100644 --- a/src/integration/resources/db/data.sql +++ b/src/integration/resources/db/data.sql @@ -23,7 +23,7 @@ INSERT INTO `oc_filecache` VALUES (584,2,'__groupfolders','29ff0edf73a32cb03e437d88fd049245',3,'__groupfolders',2,1,3012412,1696702221,1696702221,0,0,'',31,''), (586,2,'__groupfolders/1','e46cc72327dfc3ccaf32f0a167e6c6d1',584,'1',2,1,3012412,1696695701,1696695701,0,0,'',31,''), -(587,2,'__groupfolders/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',586,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0, +(587,2,'__groupfolders/1/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',586,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0, '',27,''), (4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''), diff --git a/src/integration/resources/nextcloud/app/data/__groupfolders/Nextcloud community.jpg b/src/integration/resources/nextcloud/app/data/__groupfolders/1/Nextcloud community.jpg similarity index 100% rename from src/integration/resources/nextcloud/app/data/__groupfolders/Nextcloud community.jpg rename to src/integration/resources/nextcloud/app/data/__groupfolders/1/Nextcloud community.jpg diff --git a/src/main/kotlin/net/schowek/nextclouddlna/util/ServerInfoProvider.kt b/src/main/kotlin/net/schowek/nextclouddlna/util/ServerInfoProvider.kt index 1473442..3b9614e 100644 --- a/src/main/kotlin/net/schowek/nextclouddlna/util/ServerInfoProvider.kt +++ b/src/main/kotlin/net/schowek/nextclouddlna/util/ServerInfoProvider.kt @@ -1,6 +1,5 @@ package net.schowek.nextclouddlna.util -import jakarta.annotation.PostConstruct import mu.KLogging import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Profile From 80e6f9e81801a2e81285fe298b3e5f20f52970e2 Mon Sep 17 00:00:00 2001 From: xis Date: Thu, 26 Oct 2023 18:46:12 +0200 Subject: [PATCH 2/8] banner and version added --- build.gradle | 5 +++++ src/main/resources/application.yml | 22 ++++++++++++---------- src/main/resources/banner.txt | 7 +++++++ 3 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/banner.txt diff --git a/build.gradle b/build.gradle index bbec057..230ed64 100644 --- a/build.gradle +++ b/build.gradle @@ -91,3 +91,8 @@ tasks.register('integrationTest', Test) { check.dependsOn integrationTest +processResources { + filesMatching('**/application.yml') { + expand(project.properties) + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f116b70..e2be49b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,19 +1,21 @@ server: - port: ${NEXTCLOUD_DLNA_SERVER_PORT:8080} - interface: ${NEXTCLOUD_DLNA_INTERFACE:} - friendlyName: ${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA} + port: \${NEXTCLOUD_DLNA_SERVER_PORT:8080} + interface: \${NEXTCLOUD_DLNA_INTERFACE:} + friendlyName: \${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA} nextcloud: - filesDir: ${NEXTCLOUD_DATA_DIR} + filesDir: \${NEXTCLOUD_DATA_DIR} db: - type: ${NEXTCLOUD_DB_TYPE:mariadb} - host: ${NEXTCLOUD_DB_HOST:localhost} - port: ${NEXTCLOUD_DB_PORT:3306} - name: ${NEXTCLOUD_DB_NAME:nextcloud} - user: ${NEXTCLOUD_DB_USER:nextcloud} - pass: ${NEXTCLOUD_DB_PASS:nextcloud} + type: \${NEXTCLOUD_DB_TYPE:mariadb} + host: \${NEXTCLOUD_DB_HOST:localhost} + port: \${NEXTCLOUD_DB_PORT:3306} + name: \${NEXTCLOUD_DB_NAME:nextcloud} + user: \${NEXTCLOUD_DB_USER:nextcloud} + pass: \${NEXTCLOUD_DB_PASS:nextcloud} spring: + application: + version: ${version} jpa: hibernate: ddl-auto: none diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000..7faea76 --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,7 @@ + _ _ _ _ _ + _ __ _____ _| |_ ___| | ___ _ _ __| | __| | |_ __ __ _ + | '_ \ / _ \ \/ / __/ __| |/ _ \| | | |/ _` |_____ / _` | | '_ \ / _` | + | | | | __/> <| || (__| | (_) | |_| | (_| |_____| (_| | | | | | (_| | + |_| |_|\___/_/\_\\__\___|_|\___/ \__,_|\__,_| \__,_|_|_| |_|\__,_| + +ver: ${spring.application.version} (powered by Spring Boot ${spring-boot.version}) \ No newline at end of file From b42dea27a2934c5c90499b4cd46ca16c91769fda Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 30 Oct 2023 16:52:42 +0100 Subject: [PATCH 3/8] create wrapper script in order to wait for Nextcloud to start Signed-off-by: Simon L --- Dockerfile | 12 ++++++++++++ start.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index 0377e6c..3b8b6f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,5 +3,17 @@ WORKDIR /app COPY ./build/libs/* ./nextcloud-dlna.jar +RUN set -ex; \ + export DEBIAN_FRONTEND=noninteractive; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + tzdata \ + netcat-openbsd \ + ; \ + rm -rf /var/lib/apt/lists/*; + +COPY --chmod=775 start.sh /start.sh + EXPOSE 8080 +ENTRYPOINT /start.sh CMD ["java","-jar","nextcloud-dlna.jar"] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..6d880fe --- /dev/null +++ b/start.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Wait for Nextcloud to come online +if [ -n "$NC_DOMAIN" ] && [ "$NC_PORT" ]; then + while ! nc -z "$NC_DOMAIN" "$NC_PORT"; do + echo "Waiting for Nextcloud to start..." + sleep 5 + done +fi + +# Execute CMD +exec /__cacert_entrypoint.sh "$@" From fa5443d0dc805ef84dd4ba3708b6f4107586669c Mon Sep 17 00:00:00 2001 From: xis Date: Mon, 30 Oct 2023 19:58:53 +0100 Subject: [PATCH 4/8] Fixed test isolation --- .../upnp/UpnpServiceConfigurationInt.groovy | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/integration/groovy/support/beans/dlna/upnp/UpnpServiceConfigurationInt.groovy b/src/integration/groovy/support/beans/dlna/upnp/UpnpServiceConfigurationInt.groovy index 91b269e..e4a1478 100644 --- a/src/integration/groovy/support/beans/dlna/upnp/UpnpServiceConfigurationInt.groovy +++ b/src/integration/groovy/support/beans/dlna/upnp/UpnpServiceConfigurationInt.groovy @@ -2,12 +2,12 @@ package support.beans.dlna.upnp import org.jupnp.DefaultUpnpServiceConfiguration import org.jupnp.model.message.OutgoingDatagramMessage +import org.jupnp.transport.Router import org.jupnp.transport.impl.DatagramIOConfigurationImpl import org.jupnp.transport.impl.DatagramIOImpl -import org.jupnp.transport.spi.DatagramIO -import org.jupnp.transport.spi.NetworkAddressFactory -import org.jupnp.transport.spi.StreamClient -import org.jupnp.transport.spi.StreamServer +import org.jupnp.transport.impl.MulticastReceiverConfigurationImpl +import org.jupnp.transport.impl.MulticastReceiverImpl +import org.jupnp.transport.spi.* import org.springframework.context.annotation.Profile import org.springframework.stereotype.Component @@ -31,10 +31,33 @@ class UpnpServiceConfigurationInt extends DefaultUpnpServiceConfiguration { return new MockDatagramIO(this, new DatagramIOConfigurationImpl()) } + @Override + public MulticastReceiver createMulticastReceiver(NetworkAddressFactory networkAddressFactory) { + return new MockMulticastReceiver( + new MulticastReceiverConfigurationImpl( + networkAddressFactory.getMulticastGroup(), + networkAddressFactory.getMulticastPort() + ) + ); + } + private void onOutgoingDatagramMessage(OutgoingDatagramMessage message) { outgoingDatagramMessages.add(message) } + class MockMulticastReceiver extends MulticastReceiverImpl { + MockMulticastReceiver(MulticastReceiverConfigurationImpl configuration) { + super(configuration) + } + + @Override + void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException { + } + + @Override + public void run() {} + } + class MockDatagramIO extends DatagramIOImpl { private final UpnpServiceConfigurationInt upnpServiceConfiguration From 43412c7b065172bd243be90b9b13bcbea080924d Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 30 Oct 2023 17:35:16 +0100 Subject: [PATCH 5/8] address review Signed-off-by: Simon L --- Dockerfile | 2 +- start.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b8b6f6..e144e0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,5 +15,5 @@ RUN set -ex; \ COPY --chmod=775 start.sh /start.sh EXPOSE 8080 -ENTRYPOINT /start.sh +ENTRYPOINT ["/start.sh"] CMD ["java","-jar","nextcloud-dlna.jar"] diff --git a/start.sh b/start.sh index 6d880fe..7671296 100644 --- a/start.sh +++ b/start.sh @@ -1,11 +1,12 @@ #!/bin/bash # Wait for Nextcloud to come online -if [ -n "$NC_DOMAIN" ] && [ "$NC_PORT" ]; then +if [ -n "$NC_DOMAIN" ] && [ -n "$NC_PORT" ]; then while ! nc -z "$NC_DOMAIN" "$NC_PORT"; do - echo "Waiting for Nextcloud to start..." + echo "Waiting for Nextcloud to start on $NC_DOMAIN:$NC_PORT..." sleep 5 done + echo "Nextcloud found on $NC_DOMAIN:$NC_PORT!" fi # Execute CMD From be0580582e7b06f0e9d23699162774f4c4719079 Mon Sep 17 00:00:00 2001 From: xis Date: Tue, 31 Oct 2023 17:05:13 +0100 Subject: [PATCH 6/8] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fce6ce3..70d83a3 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ thanek/nextcloud-dlna or, if used together with the official Nextcloud docker image using the docker-composer. See the [examples](./examples) directory. for more details about running nextcloud-dlna server in the docker container. -You can pass to the container other env variables that are listed below. +While using docker, you can pass to the container the `NC_DOMAIN` and `NC_PORT` environment variables and force the container +to check and wait for the nextcloud HTTP server to appear on the specified domain and port address. +You can also pass to the container other env variables that are listed below. Note that it would not work on Mac OS since docker is a Linux container and the `host` networking mode doesn't actually share the host's network interfaces. From b8a9c451d404a74043633875c1b8db68952b9785 Mon Sep 17 00:00:00 2001 From: xis Date: Tue, 31 Oct 2023 17:43:01 +0100 Subject: [PATCH 7/8] docker folder --- Dockerfile => docker/Dockerfile | 2 +- docker-build-image.sh => docker/build-image.sh | 10 +++++++++- start.sh => docker/start.sh | 0 3 files changed, 10 insertions(+), 2 deletions(-) rename Dockerfile => docker/Dockerfile (89%) rename docker-build-image.sh => docker/build-image.sh (72%) rename start.sh => docker/start.sh (100%) diff --git a/Dockerfile b/docker/Dockerfile similarity index 89% rename from Dockerfile rename to docker/Dockerfile index e144e0b..e5dfefc 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -12,7 +12,7 @@ RUN set -ex; \ ; \ rm -rf /var/lib/apt/lists/*; -COPY --chmod=775 start.sh /start.sh +COPY --chmod=775 ./docker/start.sh /start.sh EXPOSE 8080 ENTRYPOINT ["/start.sh"] diff --git a/docker-build-image.sh b/docker/build-image.sh similarity index 72% rename from docker-build-image.sh rename to docker/build-image.sh index 8a35a0b..1a7025f 100755 --- a/docker-build-image.sh +++ b/docker/build-image.sh @@ -1,6 +1,10 @@ #!/bin/bash -version=`./gradlew currentVersion | grep "Project version" | awk -F"version: " '{ print $2 }'` +dir=$(realpath "$(dirname "$0")") + +cd "$dir/../" || exit + +version=$(./gradlew currentVersion | grep "Project version" | awk -F"version: " '{ print $2 }') echo "This will create docker image for version $version." read -p "Continue [y/n]? " -n 1 -r @@ -21,9 +25,13 @@ docker buildx inspect --bootstrap docker buildx build \ --push \ --platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \ + --file=./docker/Dockerfile \ --tag=thanek/nextcloud-dlna:$version . docker buildx build \ --push \ --platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \ + --file=./docker/Dockerfile \ --tag=thanek/nextcloud-dlna . + +cd - || exit diff --git a/start.sh b/docker/start.sh similarity index 100% rename from start.sh rename to docker/start.sh From 5eccb5b43cdfe58f5414cc225e4c266e38e51777 Mon Sep 17 00:00:00 2001 From: xis Date: Tue, 31 Oct 2023 17:47:12 +0100 Subject: [PATCH 8/8] docs fixes --- README.md | 2 +- examples/docker-compose/docker-compose.yaml | 2 -- examples/docker-standalone/run.sh | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 70d83a3..9e266c5 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Available env variables with their default values that you can overwrite: | NEXTCLOUD_DLNA_INTERFACE | | (optional) interface the server will be listening on
if not given, the default local address will be used | | NEXTCLOUD_DLNA_FRIENDLY_NAME | Nextcloud-DLNA | friendly name of the DLNA service | | NEXTCLOUD_DATA_DIR | | nextcloud installation directory (that ends with /data) | -| NEXTCLOUD_DB_TYPE | mariadb | nextcloud database type (mysql, mariadb, postgresql) | +| NEXTCLOUD_DB_TYPE | mariadb | nextcloud database type (mysql, mariadb, postgres) | | NEXTCLOUD_DB_HOST | localhost | nextcloud database host | | NEXTCLOUD_DB_PORT | 3306 | nextcloud database port | | NEXTCLOUD_DB_NAME | nextcloud | nextcloud database name | diff --git a/examples/docker-compose/docker-compose.yaml b/examples/docker-compose/docker-compose.yaml index 206f621..f8abebe 100644 --- a/examples/docker-compose/docker-compose.yaml +++ b/examples/docker-compose/docker-compose.yaml @@ -72,8 +72,6 @@ services: volumes: - app:/nextcloud network_mode: "host" - ports: - - "9999:9999" environment: - NEXTCLOUD_DLNA_SERVER_PORT=9999 - NEXTCLOUD_DLNA_FRIENDLY_NAME=Nextcloud diff --git a/examples/docker-standalone/run.sh b/examples/docker-standalone/run.sh index 7086777..b2697aa 100644 --- a/examples/docker-standalone/run.sh +++ b/examples/docker-standalone/run.sh @@ -4,7 +4,6 @@ docker run -d \ --name="nextcloud-dlna" \ --restart=unless-stopped \ --net=host \ - -p 9999:9999 \ -e NEXTCLOUD_DLNA_SERVER_PORT=9999 \ -e NEXTCLOUD_DLNA_FRIENDLY_NAME="Nextcloud" \ -e NEXTCLOUD_DB_HOST='localhost' \