From 74004f765ec7606aa7a7fe8ac11a43f8fa5d602c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20W=C3=BChr?= Date: Mon, 4 Sep 2023 22:31:24 +0200 Subject: [PATCH 01/20] Switch to manifest src handling (#26) * Switch to manifest src handling - take 1 * Switch to manifest src handling - take 2 * Switch to manifest src handling - take 3 * Update pkg to 2.7.0~ynh2 --- conf/amd64.src | 6 ------ conf/arm64.src | 6 ------ conf/armhf.src | 6 ------ manifest.toml | 19 ++++++++++++++++++- scripts/_common.sh | 2 +- tools/update_src.sh | 20 -------------------- 6 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 conf/amd64.src delete mode 100644 conf/arm64.src delete mode 100644 conf/armhf.src delete mode 100644 tools/update_src.sh diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index 9a815e5..0000000 --- a/conf/amd64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_amd64.tar.gz -SOURCE_SUM=2218bea3204348700034cff652437e317b8ed2466aa58d8b2444b41b68eaf5e2 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ntfy_2.7.0_linux_amd64 diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index ea734ee..0000000 --- a/conf/arm64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_arm64.tar.gz -SOURCE_SUM=1e0e1bc4183e3ffecbe8d8b1b91b5df8965d907968588c19b7a591719bd146fb -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ntfy_2.7.0_linux_arm64 diff --git a/conf/armhf.src b/conf/armhf.src deleted file mode 100644 index 385e297..0000000 --- a/conf/armhf.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_armv7.tar.gz -SOURCE_SUM=84981fe6f4234fb8e6429b0c6cbe7090bab1f773e1994b42237c40c244cdd326 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ntfy_2.7.0_linux_armv7 diff --git a/manifest.toml b/manifest.toml index 83125fb..fd0c271 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "ntfy" description.en = "Open Source Push Notification Server" description.fr = "Serveur open source de notification" -version = "2.7.0~ynh1" +version = "2.7.0~ynh2" maintainers = ["Alexander Wühr"] @@ -43,6 +43,23 @@ ram.runtime = "50M" type = "password" [resources] + [resources.sources] + [resources.sources.main] + autoupdate.strategy = "latest_github_release" + + autoupdate.asset.amd64 = '.*_linux_amd64\.tar\.gz' + autoupdate.asset.arm64 = '.*_linux_arm64\.tar\.gz' + autoupdate.asset.armhf = '.*_linux_armv7\.tar\.gz' + + amd64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_amd64.tar.gz" + amd64.sha256 = "2218bea3204348700034cff652437e317b8ed2466aa58d8b2444b41b68eaf5e2" + + arm64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_arm64.tar.gz" + arm64.sha256 = "1e0e1bc4183e3ffecbe8d8b1b91b5df8965d907968588c19b7a591719bd146fb" + + armhf.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_armv7.tar.gz" + armhf.sha256 ="84981fe6f4234fb8e6429b0c6cbe7090bab1f773e1994b42237c40c244cdd326" + [resources.system_user] [resources.install_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index 3d358ff..d5f34cb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,7 +9,7 @@ #================================================= ntfy_setup_source() { - ynh_setup_source -d "$install_dir" -s "$YNH_ARCH" + ynh_setup_source -d "$install_dir" mkdir -p "$install_dir/data" chown -R $app:$app "$install_dir" chmod -R 750 "$install_dir/data" diff --git a/tools/update_src.sh b/tools/update_src.sh deleted file mode 100644 index f123c9a..0000000 --- a/tools/update_src.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -VERSION=$1 - -CHECKSUMS=`wget https://github.com/binwiederhier/ntfy/releases/download/v$VERSION/checksums.txt -q -O -` - -src() { - cat << SH > conf/$1.src -SOURCE_URL=https://github.com/binwiederhier/ntfy/releases/download/v${VERSION}/ntfy_${VERSION}_linux_${2}.tar.gz -SOURCE_SUM=`echo "$CHECKSUMS" | grep ${VERSION}_linux_${2}.tar.gz | cut -d " " -f 1` -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ntfy_${VERSION}_linux_${2} -SH -} - -src amd64 amd64 -src arm64 arm64 -src armhf armv7 From 92ea2911685d6206f901da4681bf70de09cc72fd Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 4 Sep 2023 20:31:28 +0000 Subject: [PATCH 02/20] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a1fa04..3a3fe73 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. -**Shipped version:** 2.7.0~ynh1 +**Shipped version:** 2.7.0~ynh2 **Demo:** https://ntfy.sh/app ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index 7f24b0a..d405e8b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. -**Version incluse :** 2.7.0~ynh1 +**Version incluse :** 2.7.0~ynh2 **Démo :** https://ntfy.sh/app ## Documentations et ressources From f2a06add844f3d795ef0a409b66fb56c55822b07 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 20 Nov 2023 05:17:08 +0100 Subject: [PATCH 03/20] Upgrade to v2.8.0 --- manifest.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manifest.toml b/manifest.toml index fd0c271..bdd36b2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "ntfy" description.en = "Open Source Push Notification Server" description.fr = "Serveur open source de notification" -version = "2.7.0~ynh2" +version = "2.8.0~ynh1" maintainers = ["Alexander Wühr"] @@ -51,14 +51,14 @@ ram.runtime = "50M" autoupdate.asset.arm64 = '.*_linux_arm64\.tar\.gz' autoupdate.asset.armhf = '.*_linux_armv7\.tar\.gz' - amd64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_amd64.tar.gz" - amd64.sha256 = "2218bea3204348700034cff652437e317b8ed2466aa58d8b2444b41b68eaf5e2" + amd64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_amd64.tar.gz" + amd64.sha256 = "7158312a9f6e49daf94355e63a8fa73e04f3c2d5defc2bba0cbf3e35fdf7bf9a" - arm64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_arm64.tar.gz" - arm64.sha256 = "1e0e1bc4183e3ffecbe8d8b1b91b5df8965d907968588c19b7a591719bd146fb" + arm64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_arm64.tar.gz" + arm64.sha256 = "918d0a81355288ef60e8ef0d0587630f069c5c75909a12d6abbdb2e1628dbc52" - armhf.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.7.0/ntfy_2.7.0_linux_armv7.tar.gz" - armhf.sha256 ="84981fe6f4234fb8e6429b0c6cbe7090bab1f773e1994b42237c40c244cdd326" + armhf.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_armv7.tar.gz" + armhf.sha256 ="bf63f969b64889158bb0daa2f55f2e3356516a0c4ff2f57d0392a0c7df0abefc" [resources.system_user] From 8131bfefb9b23f16dbf00b0c08eedb94ff741fd8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 20 Nov 2023 04:17:12 +0000 Subject: [PATCH 04/20] Auto-update README --- README.md | 4 ++-- README_fr.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3a3fe73..4aa69b8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. -**Shipped version:** 2.7.0~ynh2 +**Shipped version:** 2.8.0~ynh1 **Demo:** https://ntfy.sh/app ## Documentation and resources @@ -28,7 +28,7 @@ ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. * Official user documentation: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index d405e8b..3936632 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. -**Version incluse :** 2.7.0~ynh2 +**Version incluse :** 2.8.0~ynh1 **Démo :** https://ntfy.sh/app ## Documentations et ressources @@ -28,7 +28,7 @@ ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. * Documentation officielle utilisateur : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 4213dfcbe24a739826f4325145d9b15fa814374a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:25:17 +0100 Subject: [PATCH 05/20] Update manifest.toml --- manifest.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifest.toml b/manifest.toml index fd0c271..1a03369 100644 --- a/manifest.toml +++ b/manifest.toml @@ -22,8 +22,11 @@ fund = "https://liberapay.com/ntfy" yunohost = ">= 11.2" architectures = ["amd64", "arm64", "armhf"] multi_instance = true + ldap = false + sso = false + disk = "50M" ram.build = "50M" ram.runtime = "50M" From 5831c62c8a7ff934c72aae6fe17d0dc1a63ed7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:25:59 +0100 Subject: [PATCH 06/20] Create DESCRIPTION_fr.md --- doc/DESCRIPTION_fr.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/DESCRIPTION_fr.md diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..d4ea610 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +ntfy (prononcer : *notify*) est un simple service de notification pub-sub basé sur HTTP. Il vous permet d'envoyer des notifications sur votre téléphone ou votre ordinateur via des scripts depuis n'importe quel ordinateur, sans inscription, sans frais ni configuration. Il est également open source si vous souhaitez exécuter le vôtre. \ No newline at end of file From 93f56c912713067631a9517a179ef2c1586f3236 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 23 Nov 2023 18:26:04 +0000 Subject: [PATCH 07/20] Auto-update README --- README_fr.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README_fr.md b/README_fr.md index 6c6fafc..bae11b9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,8 +16,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. - +ntfy (prononcer : *notify*) est un simple service de notification pub-sub basé sur HTTP. Il vous permet d'envoyer des notifications sur votre téléphone ou votre ordinateur via des scripts depuis n'importe quel ordinateur, sans inscription, sans frais ni configuration. Il est également open source si vous souhaitez exécuter le vôtre. **Version incluse :** 2.7.0~ynh2 From cdf51f8e24bb9c2ddc7a454b5651b88525abbe0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:27:05 +0100 Subject: [PATCH 08/20] cleaning --- doc/admin.md | 1 + doc/admin_fr.md | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 doc/admin_fr.md diff --git a/doc/admin.md b/doc/admin.md index e5b2b12..7128e6b 100644 --- a/doc/admin.md +++ b/doc/admin.md @@ -1,4 +1,5 @@ ### Configuration + By default, only user selected at installation can read from and write to topics. To change this refer to the upstream project's documentation: https://docs.ntfy.sh/config/#access-control The configuration file is located at `__INSTALL_DIR__/server.yml` and can be edited directly. diff --git a/doc/admin_fr.md b/doc/admin_fr.md new file mode 100644 index 0000000..5d64f61 --- /dev/null +++ b/doc/admin_fr.md @@ -0,0 +1,13 @@ +### Configuration + +Par défaut, seul l'utilisateur sélectionné lors de l'installation peut lire et écrire dans les rubriques. Pour modifier cela, reportez-vous à la documentation du projet : https://docs.ntfy.sh/config/#access-control + +Le fichier de configuration se trouve dans `__INSTALL_DIR__/server.yml` et peut être modifié directement. + +Pour configurer les utilisateurs, les jetons, les acls et les niveaux, vous trouverez un petit script wrapper dans `__INSTALL_DIR__/ntfy.sh`. + +``` merde +sudo ~__APP__/ntfy.sh utilisateur ajoutez votre_nouveau_nom d'utilisateur +``` + +par exemple, ajoutera un nouvel utilisateur. \ No newline at end of file From eb07615fa9f42af7420cdac331769c5d15f58cb2 Mon Sep 17 00:00:00 2001 From: eric_G <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 15 Dec 2023 08:20:39 +0100 Subject: [PATCH 09/20] Script style cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Wühr Co-authored-by: Salamandar <6552989+Salamandar@users.noreply.github.com> --- conf/nginx.conf | 6 ++-- conf/ntfy.sh | 5 ++++ scripts/_common.sh | 10 ------- scripts/backup | 35 ++++++++++++++++++++-- scripts/change_url | 45 ++++++++++++++++++++++++---- scripts/install | 66 ++++++++++++++++++++++++++++++++++------- scripts/remove | 21 ++++++++++--- scripts/restore | 50 +++++++++++++++++++++++-------- scripts/upgrade | 74 ++++++++++++++++++++++++++++++++++++++-------- 9 files changed, 252 insertions(+), 60 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7854cab..f9431e9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,7 @@ -location / { - proxy_pass http://localhost:__PORT__/; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Host $host; diff --git a/conf/ntfy.sh b/conf/ntfy.sh index c373d33..260c45b 100755 --- a/conf/ntfy.sh +++ b/conf/ntfy.sh @@ -2,4 +2,9 @@ HOME=__INSTALL_DIR__ +if [ ! -f "$HOME/data/user.db" ]; then + echo "Waiting for server to start" + sleep 2 +fi + NTFY_CONFIG_FILE="$HOME/server.yml" $HOME/ntfy $@ diff --git a/scripts/_common.sh b/scripts/_common.sh index d5f34cb..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,16 +8,6 @@ # PERSONAL HELPERS #================================================= -ntfy_setup_source() { - ynh_setup_source -d "$install_dir" - mkdir -p "$install_dir/data" - chown -R $app:$app "$install_dir" - chmod -R 750 "$install_dir/data" - - ynh_secure_remove "$install_dir/client" - ynh_secure_remove "$install_dir/server" -} - #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 8051775..f887e84 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,10 +1,39 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -ynh_backup -s "$install_dir" -ynh_backup -s "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup -s "/etc/systemd/system/$app.service" +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# END OF SCRIPT +#================================================= ynh_print_info --message="Backup script completed. (YunoHost will then actually copy those files to the archive)" \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index c1f169a..572b377 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,15 +1,48 @@ #!/bin/bash +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers -ynh_script_progression --message="Updating systemd service..." --weight=1 -ynh_add_systemd_config +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -ynh_script_progression --message="Updating webserver configuration..." --weight=1 ynh_change_url_nginx_config -ynh_script_progression --message="Restarting systemd service..." --weight=1 -ynh_systemd_action --action=restart +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +ynh_script_progression --message="Updating systemd service..." --weight=1 -ynh_script_progression --message="URL change completed" --last +ynh_add_systemd_config + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 5e8e1d7..1041919 100755 --- a/scripts/install +++ b/scripts/install @@ -1,32 +1,78 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers +#================================================= +# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= ynh_script_progression --message="Setting up source files..." --weight=6 -ntfy_setup_source +ynh_setup_source --dest_dir="$install_dir" + +mkdir -p "$install_dir/data" + +chmod -R 750 "$install_dir/data" +chown -R $app:$app "$install_dir" + +ynh_secure_remove "$install_dir/client" +ynh_secure_remove "$install_dir/server" + +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +# ADD A CONFIGURATION +#================================================= ynh_script_progression --message="Adding configuration file..." --weight=1 -ynh_add_config -t "server.yml" -d "$install_dir/server.yml" -ynh_script_progression --message="Configuring systemd service..." --weight=1 +ynh_add_config --template="server.yml" --destination="$install_dir/server.yml" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +ynh_add_nginx_config + ynh_add_systemd_config -ynh_script_progression --message="Starting systemd service..." --weight=1 -ynh_systemd_action --action=start +yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_script_progression --message="Adding a command wrapper..." --weight=1 ynh_add_config -t "ntfy.sh" -d "$install_dir/ntfy.sh" chown $app:$app "$install_dir/ntfy.sh" chmod u+x "$install_dir/ntfy.sh" -ynh_script_progression --message="Configuring web server..." --weight=2 -ynh_add_nginx_config +#================================================= +# GENERIC FINALIZATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# ADD ADMIN +#================================================= ynh_script_progression --message="Adding admin user..." --weight=1 + ynh_exec_as $app NTFY_PASSWORD="$password" $install_dir/ntfy.sh user add --role=admin $admin +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Installation completed" --last diff --git a/scripts/remove b/scripts/remove index e122375..6dc0d3b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -3,13 +3,26 @@ source _common.sh source /usr/share/yunohost/helpers -ynh_script_progression --message="Removing service in YunoHost..." --weight=1 -yunohost service remove $app +#================================================= +# REMOVE SYSTEM CONFIGURATIONS +#================================================= +# REMOVE SYSTEMD SERVICE +#================================================= +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null +then + ynh_script_progression --message="Removing $app service integration..." --weight=1 + yunohost service remove $app +fi + +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -ynh_script_progression --message="Removing the systemd service..." --weight=1 ynh_remove_systemd_config -ynh_script_progression --message="Removing the web server configuration..." --weight=2 ynh_remove_nginx_config +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Removal completed" --last diff --git a/scripts/restore b/scripts/restore index bafa93c..1566077 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,25 +1,51 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -ynh_script_progression --message="Restoring the main directory..." --weight=1 -ynh_restore_file -o "$install_dir" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_script_progression --message="Restoring the web server configuration..." --weight=1 -ynh_restore_file -o "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="$install_dir" + +chown -R $app:www-data "$install_dir" + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -ynh_systemd_action --action=enable +systemctl enable $app.service --quiet -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app +yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" -ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --action=start +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +#================================================= +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_script_progression --message="Reloading the web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload -ynh_script_progression --message="Restoration completed" --last \ No newline at end of file +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed" --last diff --git a/scripts/upgrade b/scripts/upgrade index c799e98..aa1b779 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,35 +1,83 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=6 - ntfy_setup_source + + ynh_setup_source --dest_dir="$install_dir" + + mkdir -p "$install_dir/data" + + chmod -R 750 "$install_dir/data" + chown -R $app:$app "$install_dir" + + ynh_secure_remove "$install_dir/client" + ynh_secure_remove "$install_dir/server" fi -ynh_script_progression --message="Updating configuration file..." --weight=1 -ynh_add_config -t "server.yml" -d "$install_dir/server.yml" +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +ynh_add_nginx_config -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_add_systemd_config -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app +yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +#================================================= +# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +ynh_add_config --template="server.yml" --destination="$install_dir/server.yml" + +#================================================= +# ADD A CONFIGURATION +#================================================= ynh_script_progression --message="Updating simple command wrapper..." --weight=1 -ynh_add_config -t "ntfy.sh" -d "$install_dir/ntfy.sh" + +ynh_add_config --template="ntfy.sh" --destination="$install_dir/ntfy.sh" + chown $app:$app "$install_dir/ntfy.sh" chmod u+x "$install_dir/ntfy.sh" -ynh_script_progression --message="Upgrading web server configuration..." --weight=2 -ynh_add_nginx_config +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_script_progression --message="Restarting systemd service..." --weight=1 -ynh_systemd_action --action=restart +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_script_progression --message="Upgrade completed" --last \ No newline at end of file +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last From 8ea5ddbd7c0c51b4599a7d2b2e8f9c0e85d74e9d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 19:32:14 +0100 Subject: [PATCH 10/20] fix rate limiting --- conf/server.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/server.yml b/conf/server.yml index be808c0..cdade67 100644 --- a/conf/server.yml +++ b/conf/server.yml @@ -15,6 +15,9 @@ auth-file: __INSTALL_DIR__/data/user.db auth-default-access: "deny-all" enable-login: true +# Tell ntfy to use "X-Forwarded-For" to identify visitors +behind-proxy: true + attachment-cache-dir: __INSTALL_DIR__/data/attachments upstream-base-url: "https://ntfy.sh" From 87d8feb6c3bd23702104e3d80f4126dd28dcc7ba Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 19:34:55 +0100 Subject: [PATCH 11/20] ntfy needs to be exposed to properly work --- manifest.toml | 58 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/manifest.toml b/manifest.toml index 5de5c19..e6d5128 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,44 +32,46 @@ ram.build = "50M" ram.runtime = "50M" [install] - [install.domain] - type = "domain" +[install.domain] +type = "domain" - [install.init_main_permission] - type = "group" - default = "visitors" +[install.init_main_permission] +type = "group" +default = "visitors" - [install.admin] - type = "user" +[install.admin] +type = "user" - [install.password] - type = "password" +[install.password] +type = "password" [resources] - [resources.sources] - [resources.sources.main] - autoupdate.strategy = "latest_github_release" +[resources.sources] +[resources.sources.main] +autoupdate.strategy = "latest_github_release" - autoupdate.asset.amd64 = '.*_linux_amd64\.tar\.gz' - autoupdate.asset.arm64 = '.*_linux_arm64\.tar\.gz' - autoupdate.asset.armhf = '.*_linux_armv7\.tar\.gz' +autoupdate.asset.amd64 = '.*_linux_amd64\.tar\.gz' +autoupdate.asset.arm64 = '.*_linux_arm64\.tar\.gz' +autoupdate.asset.armhf = '.*_linux_armv7\.tar\.gz' - amd64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_amd64.tar.gz" - amd64.sha256 = "7158312a9f6e49daf94355e63a8fa73e04f3c2d5defc2bba0cbf3e35fdf7bf9a" +amd64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_amd64.tar.gz" +amd64.sha256 = "7158312a9f6e49daf94355e63a8fa73e04f3c2d5defc2bba0cbf3e35fdf7bf9a" - arm64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_arm64.tar.gz" - arm64.sha256 = "918d0a81355288ef60e8ef0d0587630f069c5c75909a12d6abbdb2e1628dbc52" +arm64.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_arm64.tar.gz" +arm64.sha256 = "918d0a81355288ef60e8ef0d0587630f069c5c75909a12d6abbdb2e1628dbc52" - armhf.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_armv7.tar.gz" - armhf.sha256 ="bf63f969b64889158bb0daa2f55f2e3356516a0c4ff2f57d0392a0c7df0abefc" +armhf.url = "https://github.com/binwiederhier/ntfy/releases/download/v2.8.0/ntfy_2.8.0_linux_armv7.tar.gz" +armhf.sha256 = "bf63f969b64889158bb0daa2f55f2e3356516a0c4ff2f57d0392a0c7df0abefc" - [resources.system_user] +[resources.system_user] - [resources.install_dir] +[resources.install_dir] - [resources.permissions] - main.url = "/" - main.auth_header = false +[resources.permissions] +main.url = "/" +main.auth_header = false +main.protected = true +main.allowed = "visitors" - [resources.ports] - main.default = 8080 +[resources.ports] +main.default = 8080 From 0950f8e60398101aecc9086a40bc535b3dac6ae5 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:11:36 +0100 Subject: [PATCH 12/20] exclude install.private --- tests.toml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests.toml b/tests.toml index cded3e3..2f07519 100644 --- a/tests.toml +++ b/tests.toml @@ -1,6 +1,9 @@ test_format = 1.0 +# ntfy needs to be publicly exposed to properly work, see #34 +exclude = "install.private" + [default] - test_upgrade_from.727dfd9.name = "Upgrade from 2.6.2~ynh1" - test_upgrade_from.e89c0fb.name = "Upgrade from 2.5.0~ynh1" - #test_upgrade_from.5b729db.name = "Upgrade from 2.4.0~ynh1" +test_upgrade_from.727dfd9.name = "Upgrade from 2.6.2~ynh1" +test_upgrade_from.e89c0fb.name = "Upgrade from 2.5.0~ynh1" +#test_upgrade_from.5b729db.name = "Upgrade from 2.4.0~ynh1" From 78de2fb90035d4624b971472647c91dceeee7fd0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:13:12 +0100 Subject: [PATCH 13/20] bump ynh version --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index e6d5128..93bbe69 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "ntfy" description.en = "Open Source Push Notification Server" description.fr = "Serveur open source de notification" -version = "2.8.0~ynh1" +version = "2.8.0~ynh2" maintainers = ["Alexander Wühr"] From 7f8b5fbcc41832d3e4aee1e34ffa2a3ddcfd2bb2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 16 Jan 2024 19:13:17 +0000 Subject: [PATCH 14/20] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4aa69b8..c491a97 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ntfy (pronounce: *notify*) is a simple HTTP-based pub-sub notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also open source if you want to run your own. -**Shipped version:** 2.8.0~ynh1 +**Shipped version:** 2.8.0~ynh2 **Demo:** https://ntfy.sh/app ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index 5be4e20..03579b6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ntfy (prononcer : *notify*) est un simple service de notification pub-sub basé sur HTTP. Il vous permet d'envoyer des notifications sur votre téléphone ou votre ordinateur via des scripts depuis n'importe quel ordinateur, sans inscription, sans frais ni configuration. Il est également open source si vous souhaitez exécuter le vôtre. -**Version incluse :** 2.8.0~ynh1 +**Version incluse :** 2.8.0~ynh2 **Démo :** https://ntfy.sh/app ## Documentations et ressources From 55e7e63c751945b955e89d1c371e7aa118f88759 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:18:47 +0100 Subject: [PATCH 15/20] remove install.init_main_permission as it's now irrelevant as exposure to visitors is mandatory --- manifest.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifest.toml b/manifest.toml index 93bbe69..c21e57d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -35,10 +35,6 @@ ram.runtime = "50M" [install.domain] type = "domain" -[install.init_main_permission] -type = "group" -default = "visitors" - [install.admin] type = "user" From ee2e76b6c3daacb2d0bfbc4af1ed4cc5067b2e2a Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:28:41 +0100 Subject: [PATCH 16/20] fix SC2086 --- scripts/change_url | 4 ++-- scripts/install | 10 +++++----- scripts/remove | 4 ++-- scripts/restore | 8 ++++---- scripts/upgrade | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 572b377..6084121 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -39,7 +39,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 1041919..4aaba2e 100755 --- a/scripts/install +++ b/scripts/install @@ -21,7 +21,7 @@ ynh_setup_source --dest_dir="$install_dir" mkdir -p "$install_dir/data" chmod -R 750 "$install_dir/data" -chown -R $app:$app "$install_dir" +chown -R "$app:$app" "$install_dir" ynh_secure_remove "$install_dir/client" ynh_secure_remove "$install_dir/server" @@ -44,7 +44,7 @@ ynh_add_nginx_config ynh_add_systemd_config -yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" #================================================= # ADD A CONFIGURATION @@ -52,7 +52,7 @@ yunohost service add $app --description="Open Source Push Notification Server" - ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config -t "ntfy.sh" -d "$install_dir/ntfy.sh" -chown $app:$app "$install_dir/ntfy.sh" +chown "$app:$app" "$install_dir/ntfy.sh" chmod u+x "$install_dir/ntfy.sh" #================================================= @@ -62,14 +62,14 @@ chmod u+x "$install_dir/ntfy.sh" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # ADD ADMIN #================================================= ynh_script_progression --message="Adding admin user..." --weight=1 -ynh_exec_as $app NTFY_PASSWORD="$password" $install_dir/ntfy.sh user add --role=admin $admin +ynh_exec_as "$app" NTFY_PASSWORD="$password" "$install_dir/ntfy.sh" user add --role=admin "$admin" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 6dc0d3b..3e175cb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,10 +9,10 @@ source /usr/share/yunohost/helpers # REMOVE SYSTEMD SERVICE #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_exec_warn_less yunohost service status "$app" >/dev/null then ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app + yunohost service remove "$app" fi ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 diff --git a/scripts/restore b/scripts/restore index 1566077..695c64d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -17,7 +17,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -29,9 +29,9 @@ ynh_script_progression --message="Restoring system configurations related to $ap ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet -yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" #================================================= # GENERIC FINALIZATION @@ -40,7 +40,7 @@ yunohost service add $app --description="Open Source Push Notification Server" - #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index aa1b779..d8dc85b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,7 +16,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) @@ -33,7 +33,7 @@ then mkdir -p "$install_dir/data" chmod -R 750 "$install_dir/data" - chown -R $app:$app "$install_dir" + chown -R "$app:$app" "$install_dir" ynh_secure_remove "$install_dir/client" ynh_secure_remove "$install_dir/server" @@ -48,7 +48,7 @@ ynh_add_nginx_config ynh_add_systemd_config -yunohost service add $app --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) @@ -66,7 +66,7 @@ ynh_script_progression --message="Updating simple command wrapper..." --weight=1 ynh_add_config --template="ntfy.sh" --destination="$install_dir/ntfy.sh" -chown $app:$app "$install_dir/ntfy.sh" +chown "$app:$app" "$install_dir/ntfy.sh" chmod u+x "$install_dir/ntfy.sh" #================================================= @@ -74,7 +74,7 @@ chmod u+x "$install_dir/ntfy.sh" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT From ad00dc13f19963d8cc970a886af22edeff3b0bd8 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:30:49 +0100 Subject: [PATCH 17/20] restructuring --- tests.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index 2f07519..287383f 100644 --- a/tests.toml +++ b/tests.toml @@ -1,9 +1,14 @@ test_format = 1.0 +[default] + # ntfy needs to be publicly exposed to properly work, see #34 exclude = "install.private" -[default] +# ------------------------------- +# Commits to test upgrade from +# ------------------------------- + test_upgrade_from.727dfd9.name = "Upgrade from 2.6.2~ynh1" test_upgrade_from.e89c0fb.name = "Upgrade from 2.5.0~ynh1" #test_upgrade_from.5b729db.name = "Upgrade from 2.4.0~ynh1" From c6e4a417875391ff7f4cb2cf8ef410434603feff Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:34:44 +0100 Subject: [PATCH 18/20] typo --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f9431e9..c6ec61b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,7 +9,7 @@ location __PATH__/ { proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Authorization $http_authorization; - proxy_pass_header Authorization; + proxy_pass_header Authorization; proxy_connect_timeout 3m; proxy_send_timeout 3m; From bb8f3627f4264f48c33cb3287ebac28a3bbe64b6 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:42:20 +0100 Subject: [PATCH 19/20] move settings to the config file --- conf/server.yml | 3 +++ conf/systemd.service | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/server.yml b/conf/server.yml index cdade67..c47da2f 100644 --- a/conf/server.yml +++ b/conf/server.yml @@ -3,6 +3,9 @@ # Please refer to the documentation at https://ntfy.sh/docs/config/ for details. # All options also support underscores (_) instead of dashes (-) to comply with the YAML spec. +base-url: "https://__DOMAIN__" +listen-http: "127.0.0.1:__PORT__" + cache-file: __INSTALL_DIR__/data/cache.db cache-startup-queries: | pragma journal_mode = WAL; diff --git a/conf/systemd.service b/conf/systemd.service index 793ff90..6695ed8 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -3,9 +3,6 @@ Description=ntfy server After=network.target [Service] -Environment="NTFY_LISTEN_HTTP=localhost:__PORT__" -Environment="NTFY_BASE_URL=https://__DOMAIN__" -Environment="NTFY_BEHIND_PROXY=1" Environment="NTFY_CONFIG_FILE=__INSTALL_DIR__/server.yml" Type=simple From 3151cab57e9a23cd1ed3f2c9e4e365737857f643 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 16 Jan 2024 20:47:43 +0100 Subject: [PATCH 20/20] fail2ban support --- scripts/backup | 6 +++++- scripts/install | 3 +++ scripts/remove | 2 ++ scripts/restore | 8 +++++--- scripts/upgrade | 3 +++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index f887e84..b47e55d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -21,11 +21,15 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# BACKUP SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +# Backup the Fail2Ban config +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index 4aaba2e..c7e949b 100755 --- a/scripts/install +++ b/scripts/install @@ -46,6 +46,9 @@ ynh_add_systemd_config yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="limiting requests, excess:.* by zone.*client: " + #================================================= # ADD A CONFIGURATION #================================================= diff --git a/scripts/remove b/scripts/remove index 3e175cb..dc4bfb6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,6 +21,8 @@ ynh_remove_systemd_config ynh_remove_nginx_config +ynh_remove_fail2ban_config + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 695c64d..50ba918 100755 --- a/scripts/restore +++ b/scripts/restore @@ -22,8 +22,6 @@ chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -33,10 +31,14 @@ systemctl enable "$app.service" --quiet yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log" +ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +# RELOAD NGINX AND THE APP SERVICE #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index d8dc85b..d19fadb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -59,6 +59,9 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="server.yml" --destination="$install_dir/server.yml" +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="limiting requests, excess:.* by zone.*client: " + #================================================= # ADD A CONFIGURATION #=================================================