From a6c70d706ec758698c7d022b69d522b3c29d3495 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:08:27 -0400 Subject: [PATCH] auto install plugin, add various checks --- README.md | 10 +++--- .../svc-mod-nextcloud-notify-push | 1 + .../svc-mod-nextcloud-notify-push-set-url/run | 8 +++++ .../type | 1 + .../svc-mod-nextcloud-notify-push-set-url/up | 1 + .../notification-fd | 1 + .../s6-rc.d/svc-mod-nextcloud-notify-push/run | 31 ++++++++++++++----- .../svc-mod-nextcloud-notify-push-set-url | 0 8 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/dependencies.d/svc-mod-nextcloud-notify-push create mode 100755 root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/run create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/type create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/up create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/notification-fd create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-nextcloud-notify-push-set-url diff --git a/README.md b/README.md index 28859e2..84daea5 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,13 @@ This mod adds a service to start the [notify-push](https://github.com/nextcloud/ ## Setup -1. Download and install the "client-push" (``notify-push``) app from the Nextcloud store. +1. Add ``DOCKER_MODS=linuxserver/mods:nextcloud-notify-push`` to your env. -2. Add ``DOCKER_MODS=linuxserver/mods:nextcloud-notify-push`` to your env. +2. Make sure that Redis is already configured with Nextcloud. -3. notify_push should be running and ``**** Starting notify-push ****`` appear in the log. Also check for errors. +3. [Configure your reverse proxy for notify push.](https://github.com/nextcloud/notify_push#reverse-proxy) -4. [Configure your reverse proxy for notify push.](https://github.com/nextcloud/notify_push#reverse-proxy) - -5. run ``occ notify_push:setup https://cloud.example.org/push`` to test and enable notify-push, replace "*cloud.example.org*" with your domain. +4. notify_push should be running and ``**** Starting notify-push ****`` appear in the log. Also check for errors. ### SWAG configuration diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/dependencies.d/svc-mod-nextcloud-notify-push b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/dependencies.d/svc-mod-nextcloud-notify-push new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/dependencies.d/svc-mod-nextcloud-notify-push @@ -0,0 +1 @@ + diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/run b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/run new file mode 100755 index 0000000..728aaf7 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/run @@ -0,0 +1,8 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +NOTIFY_PUSH_URL=$(echo "$(occ config:system:get overwrite.cli.url)/push") +echo "**** Setting notify_push server URL to ${NOTIFY_PUSH_URL} ****" +if ! occ notify_push:setup "${NOTIFY_PUSH_URL}"; then + echo "**** There was an error setting the notify_push server URL. Please double check your reverse proxy settings as well as the overwrite.cli.url entry in Nextcloud's config.php ****" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/type b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/up b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/up new file mode 100644 index 0000000..2d9fb7b --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push-set-url/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/notification-fd b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/notification-fd new file mode 100644 index 0000000..6751f92 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/notification-fd @@ -0,0 +1 @@ +7867 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/run b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/run index a960e33..052eadb 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-nextcloud-notify-push/run @@ -2,20 +2,37 @@ export NEXTCLOUD_URL="https://localhost" export ALLOW_SELF_SIGNED=true -NEXTCLOUD_BASE="/config/www/nextcloud" -NOTIFY_PUSH_BIN="$NEXTCLOUD_BASE/apps/notify_push/bin/$(arch)/notify_push" +export NEXTCLOUD_BASE="/config/www/nextcloud" +export NOTIFY_PUSH_BIN="$NEXTCLOUD_BASE/apps/notify_push/bin/$(arch)/notify_push" + +installed_version=$(php -r "require '/config/www/nextcloud/config/config.php'; echo \$CONFIG['version'];" 2>/dev/null) +if [ "${installed_version}" = "" ]; then + echo "**** Nextcloud not installed yet. Please go through the wizard and restart the container. Then notify_push will be enabled. ****" + sleep infinity +fi +# Check redis +if ! occ config:system:get redis >/dev/null; then + echo "**** Redis does not seem to be configued. Notify_push will not start ****" + sleep infinity +fi + +echo "**** Making sure the Nextcloud Client Push plugin is installed and enabled ****" +occ app:install notify_push +occ app:enable notify_push # Check if notify-push is installed if [ ! -d "$NEXTCLOUD_BASE/apps/notify_push/" ]; then - echo "**** Notify-push folder not found. Install the notify-push/client-push app and restart the container. ****" - sleep infinity + echo "**** Notify-push folder not found. Install the notify-push/client-push app and restart the container. ****" + sleep infinity fi # Check cpu arch if [ ! -f "$NOTIFY_PUSH_BIN" ]; then - echo "**** Did not find a matching notify-push binary for your cpu arch: $(arch) ****" - sleep infinity + echo "**** Did not find a matching notify-push binary for your cpu arch: $(arch) ****" + sleep infinity fi # run notify-push binary echo "**** Starting notify-push ****" -s6-setuidgid abc "$NOTIFY_PUSH_BIN" "$NEXTCLOUD_BASE/config/config.php" \ No newline at end of file +exec \ + s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 7867" \ + s6-setuidgid abc "$NOTIFY_PUSH_BIN" "$NEXTCLOUD_BASE/config/config.php" diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-nextcloud-notify-push-set-url b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mod-nextcloud-notify-push-set-url new file mode 100644 index 0000000..e69de29