From 1341345908b9a6b99e7c5c229973984c8f1a1772 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 20:12:22 +0200 Subject: [PATCH 1/9] 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 #================================================= From 35faeb9b201f98e8d8a6f530ed126602f1996ed5 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Tue, 8 Jun 2021 18:12:30 +0000 Subject: [PATCH 2/9] Auto-update README --- README.md | 4 ++++ README_fr.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 4007b2f..56bde04 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,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/README_fr.md b/README_fr.md index aee7890..84f4cc2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,6 +36,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 : From f78f064b33491b455016715aef7b1e453feb5bdb Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 20:24:33 +0200 Subject: [PATCH 3/9] self-test notify_push --- scripts/install | 11 +++++++++++ scripts/restore | 11 +++++++++++ scripts/upgrade | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/scripts/install b/scripts/install index b0c66d6..9a421aa 100755 --- a/scripts/install +++ b/scripts/install @@ -367,6 +367,17 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# CHECK IF NOTIFY_PUSH WORKS +#================================================= + +if [ $use_notify_push -eq 1 ] +then + if ! ynh_exec_as "$app" nextcloud php7.3 $final_path/occ notify_push:self-test; then + ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + fi +fi + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index b3f2451..1b160ba 100755 --- a/scripts/restore +++ b/scripts/restore @@ -194,6 +194,17 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# CHECK IF NOTIFY_PUSH WORKS +#================================================= + +if [ $use_notify_push -eq 1 ] +then + if ! ynh_exec_as "$app" nextcloud php7.3 $final_path/occ notify_push:self-test; then + ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + fi +fi + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e424348..d0c8226 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -498,6 +498,17 @@ ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload +#================================================= +# CHECK IF NOTIFY_PUSH WORKS +#================================================= + +if [ $use_notify_push -eq 1 ] +then + if ! ynh_exec_as "$app" nextcloud php7.3 $final_path/occ notify_push:self-test; then + ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + fi +fi + #================================================= # END OF SCRIPT #================================================= From e8dae98afa7e2031bd374d80524e7ac62ce3b141 Mon Sep 17 00:00:00 2001 From: Kayou Date: Wed, 9 Jun 2021 11:11:17 +0200 Subject: [PATCH 4/9] Update manifest.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 2d69a0a..12ae7ab 100644 --- a/manifest.json +++ b/manifest.json @@ -62,7 +62,7 @@ "type": "boolean", "ask": { "en": "Configure the High Performance Backend?", - "fr": "Configurer le Backend Hautes Performances ?" + "fr": "Configurer le Backend Hautes Performances ?" }, "default": false } From 335afb690284b8f04c648641af7445556b8c4060 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 9 Jun 2021 11:20:37 +0200 Subject: [PATCH 5/9] fix notify_app --- scripts/backup | 10 ++++++++++ scripts/change_url | 9 +++++++++ scripts/remove | 1 + scripts/restore | 6 ++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index 7ed3c7f..62c38c6 100755 --- a/scripts/backup +++ b/scripts/backup @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +use_notify_push=$(ynh_app_setting_get --app=$app --key=use_notify_push) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= @@ -86,6 +87,15 @@ ynh_print_info --message="Backing up data directory..." ynh_backup --src_path="/home/yunohost.app/${app}/data" --is_big +#================================================= +# BACKUP THE NOTIFY_PUSH APP +#================================================= + +if [ $use_notify_push -eq 1 ] +then + ynh_backup --src_path="/etc/systemd/system/${app}-notify-push.service" +fi + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2614a88..ebc58ae 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +use_notify_push=$(ynh_app_setting_get --app=$app --key=use_notify_push) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= @@ -80,6 +81,14 @@ then # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" + + 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 fi diff --git a/scripts/remove b/scripts/remove index 4df124d..527610e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -85,6 +85,7 @@ ynh_remove_fail2ban_config ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config --service="${app}-notify-push" +ynh_secure_remove --file="/var/run/$app/" #================================================= # SPECIFIC REMOVE diff --git a/scripts/restore b/scripts/restore index c62a6e4..508a963 100755 --- a/scripts/restore +++ b/scripts/restore @@ -27,6 +27,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +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) @@ -129,7 +130,7 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p "$datadir" #================================================= -# CONFIGURE NOTIFY_PUSH APP +# RESTORE THE NOTIFY_PUSH APP #================================================= if [ $use_notify_push -eq 1 ] @@ -137,8 +138,9 @@ then mkdir -p /var/run/$app/ chown $app: /var/run/$app/ - ynh_add_systemd_config --service="${app}-notify-push" + ynh_restore_file --origin_path="/etc/systemd/system/${app}-notify-push.service" + systemctl enable $app.service --quiet ynh_systemd_action --service_name="${app}-notify-push" --action=restart fi From 36f75ce177c01ddf343cbb7bd48f5063aabbcb27 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 9 Jun 2021 18:26:39 +0200 Subject: [PATCH 6/9] new permission hpb, some fixes --- check_process | 1 + conf/config.json | 3 ++- conf/systemd.service | 1 + scripts/change_url | 4 ++++ scripts/install | 19 ++++++++++++++----- scripts/remove | 2 +- scripts/restore | 6 ++++-- scripts/upgrade | 19 +++++++++++++++++-- 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/check_process b/check_process index 8d88180..f596848 100644 --- a/check_process +++ b/check_process @@ -4,6 +4,7 @@ path="/path" admin="homer" user_home="1" + use_notify_push="1" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/config.json b/conf/config.json index 70efa3f..d60e191 100644 --- a/conf/config.json +++ b/conf/config.json @@ -12,7 +12,8 @@ "password": "" }, "hashing_default_password": true, - "localstorage.allowsymlinks": true + "localstorage.allowsymlinks": true, + "trusted_proxies": [ "127.0.0.1", "::1" ] }, "apps": { "user_ldap": { diff --git a/conf/systemd.service b/conf/systemd.service index 9f26878..ef9e7b6 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,6 +4,7 @@ Description = Push daemon for Nextcloud clients [Service] Environment=SOCKET_PATH=/var/run/__APP__/notify-push.sock Environment=NEXTCLOUD_URL=https://__DOMAIN____PATH__ +Environment=ALLOW_SELF_SIGNED=true ExecStart=__FINAL_PATH__/apps/notify_push/bin/x86_64/notify_push __FINAL_PATH__/config/config.php User=__APP__ Group=__APP__ diff --git a/scripts/change_url b/scripts/change_url index ebc58ae..17503e2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -142,6 +142,10 @@ fi if [ $use_notify_push -eq 1 ] then + domain="$new_domain" + path_url="$new_path" + exec_occ config:app:set notify_push base_endpoint --value https://$domain$path_url/push + ynh_add_systemd_config --service="${app}-notify-push" ynh_systemd_action --service_name="${app}-notify-push" --action=restart diff --git a/scripts/install b/scripts/install index a236eac..f1f6ca9 100755 --- a/scripts/install +++ b/scripts/install @@ -313,13 +313,12 @@ ynh_multimedia_addaccess $app if [ $use_notify_push -eq 1 ] then exec_occ app:install notify_push + exec_occ config:app:set notify_push base_endpoint --value https://$domain$path_url/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 #================================================= @@ -336,6 +335,10 @@ find $datadir/ -type f -print0 | xargs -0 chmod 0640 find $datadir/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "$final_path/config/config.php" chmod 755 /home/yunohost.app +if [ $use_notify_push -eq 1 ] +then + chmod 740 $final_path/apps/notify_push/bin/x86_64/notify_push +fi #================================================= # SETUP LOGROTATE @@ -358,7 +361,11 @@ ynh_add_fail2ban_config --logpath="/home/yunohost.app/$app/data/nextcloud.log" - #================================================= ynh_script_progression --message="Configuring SSOwat..." -ynh_permission_create --permission="api" --label="api" --url="re:$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true" + +if [ $use_notify_push -eq 1 ] +then + ynh_permission_create --permission="hpb" --label="High Performance Backend" --url="/push" --additional_urls="/index.php/apps/notify_push/" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" +fi #================================================= # RELOAD NGINX @@ -373,8 +380,10 @@ ynh_systemd_action --service_name=nginx --action=reload if [ $use_notify_push -eq 1 ] then - if ! ynh_exec_as "$app" php${phpversion} $final_path/occ notify_push:self-test; then - ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + ynh_systemd_action --service_name="${app}-notify-push" --action=restart + + if ! exec_occ notify_push:self-test; then + ynh_print_warn --message="The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \"systemctl restart $app-notify-push.service\", and run \"sudo -u $app php${phpversion} $final_path/occ notify_push:self-test\" to verify that everything is green." fi fi diff --git a/scripts/remove b/scripts/remove index 527610e..9e2ed19 100755 --- a/scripts/remove +++ b/scripts/remove @@ -85,7 +85,7 @@ ynh_remove_fail2ban_config ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config --service="${app}-notify-push" -ynh_secure_remove --file="/var/run/$app/" +ynh_secure_remove --file="/var/run/$app" #================================================= # SPECIFIC REMOVE diff --git a/scripts/restore b/scripts/restore index 508a963..fb01c63 100755 --- a/scripts/restore +++ b/scripts/restore @@ -202,8 +202,10 @@ ynh_systemd_action --service_name=nginx --action=reload if [ $use_notify_push -eq 1 ] then - if ! ynh_exec_as "$app" php${phpversion} $final_path/occ notify_push:self-test; then - ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + ynh_systemd_action --service_name="${app}-notify-push" --action=restart + + if ! exec_occ notify_push:self-test; then + ynh_print_warn --message="The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \"systemctl restart $app-notify-push.service\", and run \"sudo -u $app php${phpversion} $final_path/occ notify_push:self-test\" to verify that everything is green." fi fi diff --git a/scripts/upgrade b/scripts/upgrade index 45b6dec..20756b8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,6 +115,15 @@ if ynh_legacy_permissions_exists; then ynh_permission_create --permission="api" --label="api" --url="re:$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true" fi +if [ $use_notify_push -eq 1 ] && ! ynh_permission_exists --permission="hpb" +then + ynh_permission_create --permission="hpb" --label="High Performance Backend" --url="/push" --additional_urls="/index.php/apps/notify_push/" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" +elif [ $use_notify_push -eq 0 ] && ynh_permission_exists --permission="hpb" +then + ynh_permission_delete --permission="hpb" +fi + + #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -460,6 +469,10 @@ find $datadir/ -type f -print0 | xargs -0 chmod 0640 find $datadir/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "$final_path/config/config.php" chmod 755 /home/yunohost.app +if [ $use_notify_push -eq 1 ] +then + chmod 740 $final_path/apps/notify_push/bin/x86_64/notify_push +fi #================================================= # WARNING ABOUT THIRD-PARTY APPS @@ -504,8 +517,10 @@ ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload if [ $use_notify_push -eq 1 ] then - if ! ynh_exec_as "$app" php${phpversion} $final_path/occ notify_push:self-test; then - ynh_print_warn --message="High Performance Backend is not working correctly, try to repair it or contact YNH support." + ynh_systemd_action --service_name="${app}-notify-push" --action=restart + + if ! exec_occ notify_push:self-test; then + ynh_print_warn --message="The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \"systemctl restart $app-notify-push.service\", and run \"sudo -u $app php${phpversion} $final_path/occ notify_push:self-test\" to verify that everything is green." fi fi From 6ac2807c051b2ac0c722b9a9f3d36252e5e818b1 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 9 Jun 2021 18:50:21 +0200 Subject: [PATCH 7/9] fix the restore script --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index fb01c63..8f74e90 100755 --- a/scripts/restore +++ b/scripts/restore @@ -140,7 +140,7 @@ then ynh_restore_file --origin_path="/etc/systemd/system/${app}-notify-push.service" - systemctl enable $app.service --quiet + systemctl enable "${app}-notify-push".service --quiet ynh_systemd_action --service_name="${app}-notify-push" --action=restart fi From 57b4266fb1c84ffd563837597f3bb1fe14b58bf3 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 10 Jun 2021 10:39:58 +0200 Subject: [PATCH 8/9] =?UTF-8?q?fix=20restore=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/restore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/restore b/scripts/restore index 8f74e90..0596cf8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -200,6 +200,12 @@ ynh_systemd_action --service_name=nginx --action=reload # CHECK IF NOTIFY_PUSH WORKS #================================================= +# Define a function to execute commands with `occ` +exec_occ() { + (cd "$final_path" && ynh_exec_as "$app" \ + php${phpversion} occ --no-interaction --no-ansi "$@") +} + if [ $use_notify_push -eq 1 ] then ynh_systemd_action --service_name="${app}-notify-push" --action=restart From bc77114654393ed3110efdbbe9ed842f259ff7cd Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 10 Jun 2021 12:17:26 +0200 Subject: [PATCH 9/9] fix upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 20756b8..15db7dc 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -443,7 +443,7 @@ then 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 + 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