From 1341345908b9a6b99e7c5c229973984c8f1a1772 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/DISCLAIMER.md | 4 ++++ doc/DISCLAIMER_fr.md | 4 ++++ manifest.json | 9 +++++++++ scripts/change_url | 11 +++++++++++ scripts/install | 25 +++++++++++++++++++++++++ scripts/remove | 8 ++++++++ scripts/restore | 14 ++++++++++++++ scripts/upgrade | 36 ++++++++++++++++++++++++++++++++++++ 10 files changed, 132 insertions(+) create mode 100644 conf/systemd.service diff --git a/conf/nginx.conf b/conf/nginx.conf index 7970b97..7c7acfc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -134,6 +134,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/DISCLAIMER.md b/doc/DISCLAIMER.md index ff9f640..6535915 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -11,6 +11,10 @@ To install and configure it: *NB: OnlyOffice is only available for x86 architecture - **ARM** architecture is **not** supported (Raspberry Pi, OLinuXino...)* +#### 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 + ## YunoHost specific features In addition to Nextcloud core features, the following are made available with diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index aacdc22..faeaf01 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -11,6 +11,10 @@ Pour l'installer et la configurer : *NB : OnlyOffice n'est disponible que sous architecture x86 - L'architecture **ARM** n'est **pas** supporté (Raspberry Pi, OLinuXino...)* +#### 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 + ## Caractéristiques spécifiques YunoHost En plus des fonctionnalités principales de Nextcloud, les fonctionnalités suivantes sont incluses dans ce package : diff --git a/manifest.json b/manifest.json index ccc8955..2d69a0a 100644 --- a/manifest.json +++ b/manifest.json @@ -56,6 +56,15 @@ "fr": "Accéder au dossier personnel des utilisateurs depuis Nextcloud ?" }, "default": false + }, + { + "name": "use_notify_push", + "type": "boolean", + "ask": { + "en": "Configure the High Performance Backend?", + "fr": "Configurer le Backend Hautes Performances ?" + }, + "default": false } ] } diff --git a/scripts/change_url b/scripts/change_url index 5c6deb8..2614a88 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -127,6 +127,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 + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index bb5e844..b0c66d6 100755 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN user_home=$YNH_APP_ARG_USER_HOME +use_notify_push=$YNH_APP_ARG_USE_NOTIFY_PUSH app=$YNH_APP_INSTANCE_NAME @@ -47,6 +48,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=user_home --value=$user_home +ynh_app_setting_set --app=$app --key=use_notify_push --value=$use_notify_push #================================================= # STANDARD MODIFICATIONS @@ -121,6 +123,13 @@ then sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "../conf/nginx.conf" fi +if [ $use_notify_push -eq 1 ] +then + string_use_notify_push="" +else + string_use_notify_push="#" +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -297,6 +306,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 [ $use_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 b84d5bf..4df124d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +use_notify_push=$(ynh_app_setting_get --app=$app --key=use_notify_push) #================================================= # STANDARD REMOVE @@ -78,6 +79,13 @@ ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." + +ynh_remove_systemd_config --service="${app}-notify-push" + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 44f8384..b3f2451 100755 --- a/scripts/restore +++ b/scripts/restore @@ -128,6 +128,20 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p "$datadir" +#================================================= +# 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 39b124d..e424348 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) user_home=$(ynh_app_setting_get --app=$app --key=user_home) +use_notify_push=$(ynh_app_setting_get --app=$app --key=use_notify_push) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) @@ -70,6 +71,12 @@ if [ -z "$phpversion" ]; then phpversion="$YNH_PHP_VERSION" fi +# If final_path doesn't exist, create it +if [ -z "$use_notify_push" ]; then + use_notify_push=0 + ynh_app_setting_set --app=$app --key=use_notify_push --value=$use_notify_push +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -174,6 +181,13 @@ then sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "../conf/nginx.conf" fi +if [ $use_notify_push -eq 1 ] +then + string_use_notify_push="" +else + string_use_notify_push="#" +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -410,6 +424,28 @@ chmod 644 "$cron_path" exec_occ background:cron +#================================================= +# CONFIGURE NOTIFY_PUSH APP +#================================================= + +if [ $use_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 + #================================================= # GENERIC FINALIZATION #=================================================