From 274ad45c54edf9ae204fdd23295df3c607408c84 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 20:12:22 +0200 Subject: [PATCH] add notify_push option --- conf/nginx.conf | 9 +++++++++ conf/systemd.service | 12 ++++++++++++ doc/ADMIN.md | 4 ++++ doc/ADMIN_fr.md | 4 ++++ manifest.toml | 6 ++++++ scripts/change_url | 11 +++++++++++ scripts/install | 21 +++++++++++++++++++++ scripts/remove | 3 +++ scripts/restore | 14 ++++++++++++++ scripts/upgrade | 22 ++++++++++++++++++++++ 10 files changed, 106 insertions(+) create mode 100644 conf/systemd.service diff --git a/conf/nginx.conf b/conf/nginx.conf index 0300bad..1f3c053 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -165,6 +165,15 @@ location ^~ __PATH__/ { try_files $uri / __PATH__/index.php$request_uri; } + __STRING_USE_NOTIFY_PUSH__location ^~ __PATH__/push/ { + __STRING_USE_NOTIFY_PUSH__ proxy_pass http://unix:/var/run/__APP__/notify-push.sock:/; + __STRING_USE_NOTIFY_PUSH__ proxy_http_version 1.1; + __STRING_USE_NOTIFY_PUSH__ proxy_set_header Upgrade $http_upgrade; + __STRING_USE_NOTIFY_PUSH__ proxy_set_header Connection "Upgrade"; + __STRING_USE_NOTIFY_PUSH__ proxy_set_header Host $host; + __STRING_USE_NOTIFY_PUSH__ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + __STRING_USE_NOTIFY_PUSH__} + # show YunoHost panel access include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..9f26878 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,12 @@ +[Unit] +Description = Push daemon for Nextcloud clients + +[Service] +Environment=SOCKET_PATH=/var/run/__APP__/notify-push.sock +Environment=NEXTCLOUD_URL=https://__DOMAIN____PATH__ +ExecStart=__FINAL_PATH__/apps/notify_push/bin/x86_64/notify_push __FINAL_PATH__/config/config.php +User=__APP__ +Group=__APP__ + +[Install] +WantedBy = multi-user.target \ No newline at end of file diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 8d401d2..2bc6a3e 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -12,6 +12,10 @@ Alternatively, you may open a 'Nextcloud shell' with `sudo yunohost app shell __ ONLYOFFICE is an online rich text document editor which can be integrated in Nextcloud +#### High Performance Backend + +This is an application on Nextcloud that should speed up the instance, more information here: https://github.com/nextcloud/notify_push#about + #### With YunoHost App (ARM64 support, better performance) For better performance and ARM64 support (Raspberry Pi, OLinuXino...), install the [OnlyOffice YunoHost app](https://apps.yunohost.org/app/onlyoffice) and connect it to Nextcloud, see the tutorial in the [doc of onlyoffice_ynh package](https://github.com/YunoHost-Apps/onlyoffice_ynh/blob/master/README_fr.md#configuration-de-onlyoffice-server) diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 06b76b1..90cfec3 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -12,6 +12,10 @@ Ou bien, vous pouvez ouvrir un "shell Nextcloud" avec `sudo yunohost app shell _ ONLYOFFICE est un éditeur de texte enrichi en ligne qui peut s'intégrer dans Nextcloud +#### Backend Hautes Performances + +Il s'agit d'une application sur nextcloud qui devrait accélérer l'instance, plus d'informations ici: https://github.com/nextcloud/notify_push#about + #### Avec l'application YunoHost (support ARM64, meilleures performances) Pour de meilleures performances et le support de ARM64 (Raspberry Pi, OLinuXino...), installez l'[app YunoHost OnlyOffice](https://apps.yunohost.org/app/onlyoffice), puis connectez-la à Nextcloud : voir le tutoriel dans la [doc du paquet onlyoffice_ynh](https://github.com/YunoHost-Apps/onlyoffice_ynh/blob/master/README_fr.md#configuration-de-onlyoffice-server) diff --git a/manifest.toml b/manifest.toml index ef01371..244b38b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -61,6 +61,12 @@ ram.runtime = "512M" choices = ["yes", "no"] default = "yes" + [install.enable_notify_push] + ask.en = "Configure the High Performance Backend?", + ask.fr = "Configurer le Backend Hautes Performances ?" + type = "boolean" + default = false + [resources] [resources.sources] diff --git a/scripts/change_url b/scripts/change_url index aac12f0..71a661b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -49,6 +49,17 @@ then fi fi +#================================================= +# CONFIGURE NOTIFY_PUSH APP +#================================================= + +if [ $use_notify_push -eq 1 ] +then + ynh_add_systemd_config --service="${app}-notify-push" + + ynh_systemd_action --service_name="${app}-notify-push" --action=restart +fi + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/install b/scripts/install index 88c1c0d..41afca7 100755 --- a/scripts/install +++ b/scripts/install @@ -49,6 +49,11 @@ then sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "../conf/nginx.conf" fi +if [ $enable_notify_push -eq 1 ] +then + ynh_add_nginx_config "${app}-notify-push" +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -227,6 +232,22 @@ create_external_storage "/home/yunohost.multimedia/share" "Shared multimedia" # Allow nextcloud to write into these directories ynh_multimedia_addaccess $app +#================================================= +# CONFIGURE NOTIFY_PUSH APP +#================================================= + +if [ $enable_notify_push -eq 1 ] +then + exec_occ app:install notify_push + + mkdir -p /var/run/$app/ + chown $app: /var/run/$app/ + + ynh_add_systemd_config --service="${app}-notify-push" + + ynh_systemd_action --service_name="${app}-notify-push" --action=restart +fi + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/remove b/scripts/remove index c39ac68..1bf74ab 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,9 @@ ynh_remove_logrotate # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config +# Remove notify push +ynh_remove_systemd_config --service="${app}-notify-push" + # Remove a cron file # TODO: Ensure that cron job is not running (How !?) ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 1b0f63c..4a4e276 100755 --- a/scripts/restore +++ b/scripts/restore @@ -74,6 +74,20 @@ ynh_script_progression --message="Restoring data directory..." --weight=2 # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$data_dir" --not_mandatory +#================================================= +# CONFIGURE NOTIFY_PUSH APP +#================================================= + +if [ $use_notify_push -eq 1 ] +then + mkdir -p /var/run/$app/ + chown $app: /var/run/$app/ + + ynh_add_systemd_config --service="${app}-notify-push" + + ynh_systemd_action --service_name="${app}-notify-push" --action=restart +fi + #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c2ddc1d..6440851 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -366,6 +366,28 @@ chmod 644 "$cron_path" exec_occ background:cron +#================================================= +# CONFIGURE NOTIFY_PUSH APP +#================================================= + +if [ $enable_notify_push -eq 1 ] +then + # If notify_push is disabled, reenable it + if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then + exec_occ app:enable notify_push + # If notify_push is not installed, install it + elif exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then + exec_occ app:install notify_push + fi + + mkdir -p /var/run/$app/ + chown $app: /var/run/$app/ + + ynh_add_systemd_config --service="${app}-notify-push" + + ynh_systemd_action --service_name="${app}-notify-push" --action=restart +fi + #================================================= # LOGROTATE #=================================================