From 5d8320abbee51b99e609659b399f7cf30befd4f4 Mon Sep 17 00:00:00 2001 From: ljf Date: Tue, 29 Aug 2023 05:57:53 +0200 Subject: [PATCH 01/20] Empty thing to create PR --- doc/POST_INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 4ef235f..7f453e5 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,3 +1,4 @@ After filling informations in the configuration panel, in order to be added to stats.chatons.org, you could send by mail this link to contact@chatons.org. + URL of the organization.properties: `https://__DOMAIN__/.well_known/chatonsinfos/organization.properties` From a197bcf87b98a52f6ca4ed6c9b2e50e71d1cdd7a Mon Sep 17 00:00:00 2001 From: ljf Date: Sat, 2 Sep 2023 21:16:02 +0200 Subject: [PATCH 02/20] [fix] Remove debug tree call --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3fad7b8..db727c4 100755 --- a/scripts/install +++ b/scripts/install @@ -58,7 +58,6 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -tree $install_dir/sources cp "$install_dir/sources/MODELES/organization.properties" "$install_dir/public/" orga_path="$install_dir/public/organization.properties" From 631a20743808a236c9ac5417a6a189a55e01d192 Mon Sep 17 00:00:00 2001 From: ljf Date: Sat, 2 Sep 2023 21:38:31 +0200 Subject: [PATCH 03/20] [fix] Linter --- doc/ADMIN.md | 9 ++++++++- doc/ADMIN_fr.md | 9 ++++++++- doc/PRE_INSTALL.md | 1 + doc/PRE_INSTALL_fr.md | 2 ++ tests.toml | 4 ++++ 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 doc/PRE_INSTALL.md create mode 100644 doc/PRE_INSTALL_fr.md create mode 100644 tests.toml diff --git a/doc/ADMIN.md b/doc/ADMIN.md index c9b5225..c7f013c 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1,3 +1,10 @@ -This is a dummy admin doc for this app +## Start process + +1. Install this app +2. Fill the config panel (services specific tab are preconfigured) +3. Send your organization properties url by email to contact@chatons.org +4. Some days or weeks later, you should see your services in https://stats.chatons.org + +URL of the organization.properties: `https://__DOMAIN__/.well_known/chatonsinfos/organization.properties` The app install dir is `__INSTALL_DIR__` diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index a138028..d28d926 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -1,3 +1,10 @@ -Ceci est une fausse doc d'admin pour cette app +## Démarrer le processus + +1. Installer cette application +2. Remplir le panneau de configuration (les onglets spécifiques aux services sont préconfigurés) +3. Envoyez l'url des propriétés de votre organisation par email à contact@chatons.org +4. Quelques jours ou semaines plus tard, vous devriez voir vos services sur https://stats.chatons.org + +URL de l'organization.properties : `https://__DOMAIN__/.well_known/chatonsinfos/organization.properties` Le dossier d'install de l'app est `__INSTALL_DIR__` diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..2e8788c --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1 @@ +This app is specifically designed for YunoHost instances used to create CHATONS (Hosters Alternative, Transparent, Open, Neutral and Solidarity). You probably should not install it, if you are not candidate or member of this CHATONS collective. diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..28d94d2 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,2 @@ +Cette app est spécialement conçue pour les instance YunoHost utilisées dans le but de créer un "chaton" (hébergeur alternatif transparent ouvert neutre et solidaire). Vous ne devriez probablement pas installer cette application, si vous n'êtes ni candidat⋅es ni membre du collectif CHATONS. + diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..dba2938 --- /dev/null +++ b/tests.toml @@ -0,0 +1,4 @@ +test_format = 1.0 + +[default] + From 574d5e458bcc547a328a38ec444ae0953dbb9878 Mon Sep 17 00:00:00 2001 From: ljf Date: Sat, 2 Sep 2023 22:48:56 +0200 Subject: [PATCH 04/20] [fix] Config panel display --- conf/config_panel.toml.j2 | 37 ++++++++++++++----------------------- scripts/_common.sh | 2 +- scripts/config | 2 +- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/conf/config_panel.toml.j2 b/conf/config_panel.toml.j2 index 0943292..f643f32 100644 --- a/conf/config_panel.toml.j2 +++ b/conf/config_panel.toml.j2 @@ -1,6 +1,8 @@ version = "1.0" [main] +name.en = "Organization" +name.fr = "Organisation" bind = ":{{ install_dir }}/public/organization.properties" services = [] @@ -30,7 +32,7 @@ services = [] [main.organization.status-level] ask.fr = "Statut" - type = "string" + type = "select" choices.ACTIVE = "Actif" choices.IDLE = "En pause" choices.AWAY = "Inactif" @@ -45,18 +47,18 @@ services = [] [main.organization.startdate] ask.fr = "Date de création" type = "date" - bind = "organization.:" + bind = "organization.startdate:" [main.organization.enddate] ask.fr = "Date de fermeture" type = "date" visible = "status-level == 'AWAY'" - bind = "organization.:" + bind = "organization.enddate:" [main.organization._type] ask.fr = "Type d'organisation" - type = "string" + type = "select" choices.ASSOCIATION = "Association" choices.INFORMAL = "Informel" choices.COOPERATIVE = "Coopérative" @@ -75,7 +77,7 @@ services = [] [main.organization.logo] - ask.fr = "Name of the project" + ask.fr = "Logo" type = "url" bind = "organization.logo:" @@ -108,7 +110,7 @@ services = [] [main.organization.status-level-chatons] ask.fr = "Statut" - type = "string" + type = "select" choices.ACTIVE = "Actif" choices.IDLE = "En pause" choices.AWAY = "Inactif" @@ -233,7 +235,7 @@ services = [] [main.socialnetworks.pixelfed] ask.fr = "Pixelfed" type = "url" - bind = "organization.socialnetworks.pixelfed:" + bind = "organization.socialnetworks.pixelfeld:" [main.socialnetworks.twitter] ask.fr = "Twitter" @@ -305,7 +307,7 @@ services = [] [host] name = "Hébergement" -bind = "multi_file({% for app in apps.split(',') %}{{ install_dir }}/public/{{ app }}.properties {% endfor %})" +bind = "multi_file({% for app in apps.split(',') %}{{ install_dir }}/public/{{ app }}.properties,{% endfor %})" [host.provider] name = "Fournisseur" @@ -329,7 +331,7 @@ bind = "multi_file({% for app in apps.split(',') %}{{ install_dir }}/public/{{ a [host.provider.host_provider_type] ask.fr = "Type d'hébergement" - type = "string" + type = "select" choices.HOME = "hébergement à domicile" choices.HOSTEDBAY = "serveur personnel hébergé dans une baie d'un fournisseur" choices.HOSTEDSERVER = "serveur d'un fournisseur" @@ -354,7 +356,7 @@ bind = "multi_file({% for app in apps.split(',') %}{{ install_dir }}/public/{{ a [host.server.host_server_type] ask.fr = "Type de serveur" - type = "string" + type = "select" choices.NANO = "nano-ordinateur (Raspberry Pi, Olimex…)" choices.PHYSICAL = "machine physique" choices.VIRTUAL = "machine virtuelle" @@ -377,76 +379,65 @@ bind = ":{{ install_dir }}/public/{{ app }}.properties" ask.fr = "Date d'ouverture" type = "date" bind = "service.startdate:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_enddate] ask.fr = "Date de fermeture" type = "date" optional = true bind = "service.enddate:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_description] ask.fr = "Description" type = "string" bind = "service.description:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_logo] ask.fr = "Logo" type = "url" bind = "service.logo:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_legal-url] ask.fr = "Mentions légales" type = "url" bind = "service.legal.url:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_guide-technical] ask.fr = "Documentation technique" type = "url" bind = "service.guide.technical:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_guide-user] ask.fr = "Documentation utilisateurices" type = "url" bind = "service.guide.user:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_contact-url] ask.fr = "Page de support" type = "url" bind = "service.contact.url:" optional = true - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_contact-email] ask.fr = "Courriel de support" type = "email" bind = "service.contact.email:" optional = true - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_registration] ask.fr = "Inscription" - type = "string" + type = "select" choices.None = "Le service s'utilise sans inscription" choices.Free = "Inscription nécessaire mais ouverte à tout le monde et gratuite" choices.Member = "Inscription restreinte aux membres (la notion de membre pouvant être très relative, par exemple, une famille, un cercle d’amis, adhérents d'association…)" choices.Client = "Inscription liée à une relation commerciale (facture…)" bind = "service.registration:" - visible = "{{ app }}.service.{{ app }}_published" [{{ app }}.service.{{ app }}_registration-load] ask.fr = "Capacité" - type = "string" + type = "select" choices.OPEN = "Le service accueille de nouveaux comptes" choices.FULL = "Le service n'accueille plus de nouveau compte pour l'instant" bind = "service.registration.load:" - visible = "{{ app }}.service.{{ app }}_published" {% endfor %} diff --git a/scripts/_common.sh b/scripts/_common.sh index c98be42..b8d4535 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -45,7 +45,7 @@ create_service_properties() { ynh_write_var_in_file --file="$service_path" --key="service.website" --value="https://$(get_info 'domain_path')" ynh_write_var_in_file --file="$service_path" --key="service.logo" --value="https://$(get_info 'settings.domain')/yunohost/admin/appslogo/$(get_info 'logo')" - ynh_write_var_in_file --file="$service_path" --key="service.startdate" --value="$(date '+%Y-%m-%dT%H:%M:%S')" + ynh_write_var_in_file --file="$service_path" --key="service.startdate" --value="$(date '+%d/%m/%Y')" ynh_write_var_in_file --file="$service_path" --key="service.status.level" --value="OK" local ldap="$(get_info 'manifest.integration.ldap')" local sso="$(get_info 'manifest.integration.sso')" diff --git a/scripts/config b/scripts/config index bcc7875..067ad37 100644 --- a/scripts/config +++ b/scripts/config @@ -45,7 +45,7 @@ set__multi_file() { ynh_print_info --message="Configuration key '$short_setting' edited in app settings" if [ "$bind_files" != "" ] then - for bind_file in $bind_files + for bind_file in ${bind_files//,/ } do ynh_read_var_in_file --file="${bind_file}" --key="${short_settings}" ynh_print_info --message="Configuration key '$short_setting' edited in '${bind_file}'" From ff2ad870afcfb9af100a66ac939bc0d8ffd96bc5 Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 3 Sep 2023 23:49:38 +0200 Subject: [PATCH 05/20] [fix] CI --- conf/nginx.conf | 3 ++- scripts/install | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 1fdbde0..5c351ae 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,6 +6,7 @@ location __PATH__/ { # Path to source alias __INSTALL_DIR__/public/; - + index index.html; + try_files $uri $uri/ index.html; gzip off; } diff --git a/scripts/install b/scripts/install index db727c4..a038530 100755 --- a/scripts/install +++ b/scripts/install @@ -35,6 +35,8 @@ ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/sources" mkdir $install_dir/public +# Empty html page to fix the CI +echo "ChatonsInfos" > $install_dir/public/index.html # $install_dir will automatically be initialized with some decent # permission by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step From b21aa2a768fab64aa33da172f901b43e22f214ca Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 4 Sep 2023 00:40:26 +0200 Subject: [PATCH 06/20] [fix] Config panel --- conf/config_panel.toml.j2 | 52 +++++++++++++++++++-------------------- scripts/_common.sh | 2 +- scripts/config | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/conf/config_panel.toml.j2 b/conf/config_panel.toml.j2 index f643f32..79725c3 100644 --- a/conf/config_panel.toml.j2 +++ b/conf/config_panel.toml.j2 @@ -30,7 +30,7 @@ services = [] type = "string" bind = "organization.description:" - [main.organization.status-level] + [main.organization.status_level] ask.fr = "Statut" type = "select" choices.ACTIVE = "Actif" @@ -38,11 +38,11 @@ services = [] choices.AWAY = "Inactif" bind = "organization.status.level:" - [main.organization.status-description] + [main.organization.status_description] ask.fr = "Description du statut" type = "string" bind = "organization.status.description:" - visible = "status-level == 'IDLE'" + visible = "status_level == 'IDLE'" [main.organization.startdate] ask.fr = "Date de création" @@ -52,7 +52,7 @@ services = [] [main.organization.enddate] ask.fr = "Date de fermeture" type = "date" - visible = "status-level == 'AWAY'" + visible = "status_level == 'AWAY'" bind = "organization.enddate:" @@ -81,34 +81,34 @@ services = [] type = "url" bind = "organization.logo:" - [main.organization.contact-url] + [main.organization.contact_url] ask.fr = "URL de contact" type = "url" bind = "organization.contact.url:" - [main.organization.contact-mail] + [main.organization.contact_mail] ask.fr = "Mail de contact" type = "email" bind = "organization.contact.email:" - [main.organization.legal-url] + [main.organization.legal_url] ask.fr = "Mentions légales" type = "url" bind = "organization.legal.url:" - [main.organization.guide-technical] + [main.organization.guide_technical] ask.fr = "Documentation technique" type = "url" bind = "organization.guide.technical:" default = "https://yunohost.org/admindoc" - [main.organization.guide-user] + [main.organization.guide_user] ask.fr = "Documentation utilisateurice" type = "url" bind = "organization.guide.user:" default = "https://yunohost.org/user_guide" - [main.organization.status-level-chatons] + [main.organization.status_level_chatons] ask.fr = "Statut" type = "select" choices.ACTIVE = "Actif" @@ -117,39 +117,39 @@ services = [] bind = "organization.memberof.chatons.status.level:" optional = false - [main.organization.status-description-chatons] + [main.organization.status_description_chatons] ask.fr = "Description du statut" type = "string" bind = "organization.memberof.chatons.status.description:" - visible = "status-level-chatons == 'IDLE'" + visible = "status_level_chatons == 'IDLE'" - [main.organization.startdate-chatons] + [main.organization.startdate_chatons] ask.fr = "Date d'entrée dans le collectif" type = "date" bind = "organization.memberof.chatons.startdate:" optional = false - [main.organization.enddate-chatons] + [main.organization.enddate_chatons] ask.fr = "Date de sortie du collectif" type = "date" - visible = "status-level-chatons == 'AWAY'" + visible = "status_level_chatons == 'AWAY'" bind = "organization.memberof.chatons.enddate:" [main.owner] name = "Propriétaire de l'organisation" optional = true - [main.owner.owner-name] + [main.owner.owner_name] ask.fr = "Nom" type = "string" bind = "organization.owner.name:" - [main.owner.owner-website] + [main.owner.owner_website] ask.fr = "siteweb" type = "url" bind = "organization.owner.website:" - [main.owner.owner-logo] + [main.owner.owner_logo] ask.fr = "Logo" type = "url" bind = "organization.owner.logo:" @@ -161,13 +161,13 @@ services = [] # help = "" optional = true - [main.location.country-name] + [main.location.country_name] ask.fr = "Pays de l'organisation" type = "string" bind = "organization.country.name:" optional = false - [main.location.country-code] + [main.location.country_code] ask.fr = "Code pays de l'organisation" help = "Table ISO 3166-1 alpha-2 : https://fr.wikipedia.org/wiki/ISO_3166-1#Table_de_codage" type = "string" @@ -396,28 +396,28 @@ bind = ":{{ install_dir }}/public/{{ app }}.properties" type = "url" bind = "service.logo:" - [{{ app }}.service.{{ app }}_legal-url] + [{{ app }}.service.{{ app }}_legal_url] ask.fr = "Mentions légales" type = "url" bind = "service.legal.url:" - [{{ app }}.service.{{ app }}_guide-technical] + [{{ app }}.service.{{ app }}_guide_technical] ask.fr = "Documentation technique" type = "url" bind = "service.guide.technical:" - [{{ app }}.service.{{ app }}_guide-user] + [{{ app }}.service.{{ app }}_guide_user] ask.fr = "Documentation utilisateurices" type = "url" bind = "service.guide.user:" - [{{ app }}.service.{{ app }}_contact-url] + [{{ app }}.service.{{ app }}_contact_url] ask.fr = "Page de support" type = "url" bind = "service.contact.url:" optional = true - [{{ app }}.service.{{ app }}_contact-email] + [{{ app }}.service.{{ app }}_contact_email] ask.fr = "Courriel de support" type = "email" bind = "service.contact.email:" @@ -432,7 +432,7 @@ bind = ":{{ install_dir }}/public/{{ app }}.properties" choices.Client = "Inscription liée à une relation commerciale (facture…)" bind = "service.registration:" - [{{ app }}.service.{{ app }}_registration-load] + [{{ app }}.service.{{ app }}_registration_load] ask.fr = "Capacité" type = "select" choices.OPEN = "Le service accueille de nouveaux comptes" diff --git a/scripts/_common.sh b/scripts/_common.sh index b8d4535..69649b3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -88,7 +88,7 @@ create_service_properties() { update_subs() { local app_published local app=chatonsinfos - export apps=$(yunohost app list | grep "id\:" | sed "s/ *id: //g") + export apps=$(yunohost app list | grep "id\:" | sed "s/ *id: //g" | grep -v chatonsinfos) local orga_path="$install_dir/public/organization.properties" # Remove all subs diff --git a/scripts/config b/scripts/config index 067ad37..b319a9e 100644 --- a/scripts/config +++ b/scripts/config @@ -74,7 +74,7 @@ ynh_app_config_apply() { # Update date of properties files local date=$(date '+%Y-%m-%dT%H:%M:%S') ynh_write_var_in_file --file="$install_dir/public/organization.properties" --key="file.datetime" --value="$date" - local apps=$(yunohost app list | grep "id\:" | sed "s/ *id: //g") + local apps=$(yunohost app list | grep "id\:" | sed "s/ *id: //g" | grep -v chatonsinfos) for _app_id in $apps do ynh_write_var_in_file --file="$install_dir/public/$_app_id.properties" --key="file.datetime" --value="$date" From 20084af358acf8a82f5c2ff9b0f1359d8fdec314 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 4 Sep 2023 01:02:43 +0200 Subject: [PATCH 07/20] [fix] Config panel --- conf/config_panel.toml.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/config_panel.toml.j2 b/conf/config_panel.toml.j2 index 79725c3..884f1c0 100644 --- a/conf/config_panel.toml.j2 +++ b/conf/config_panel.toml.j2 @@ -363,6 +363,7 @@ bind = "multi_file({% for app in apps.split(',') %}{{ install_dir }}/public/{{ a choices.SHARED = "hébergement mutualisé" choices.CLOUD = "infrastructure multi-serveurs" +{% if apps != "" %} {% for app in apps.split(',') %} [{{ app }}] bind = ":{{ install_dir }}/public/{{ app }}.properties" @@ -440,6 +441,7 @@ bind = ":{{ install_dir }}/public/{{ app }}.properties" bind = "service.registration.load:" {% endfor %} +{% endif %} [advanced] name.fr = "Avancé" From 7fea9b9a609f3de76cdec066f260b25a07e75270 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 4 Sep 2023 16:06:35 +0200 Subject: [PATCH 08/20] [enh] Restore and access update --- hooks/post_app_addaccess | 29 +++++++++++++++++++++++++++++ hooks/post_app_removeaccess | 22 ++++++++++++++++++++++ hooks/post_app_restore | 8 ++++++++ 3 files changed, 59 insertions(+) create mode 100644 hooks/post_app_addaccess create mode 100644 hooks/post_app_removeaccess create mode 100644 hooks/post_app_restore diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..9b5a189 --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,29 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers +app=$1 +install_dir=/var/www/chatonsinfos/ +service_path=${install_dir}public/${app}.properties +local groups_added=$4 +local app_info="$(yunohost app info $app --full --json)" +get_info() { + echo $app_info | jq -r ".$1" +} +if [[ "$groups_added" == *"visitors"* ]] +then + registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") + local ldap="$(get_info 'manifest.integration.ldap')" + local sso="$(get_info 'manifest.integration.sso')" + if [[ "$registration" != "None" && "$registration" != "Free" ]] + then + if [[ "$ldap" == "not_relevant" && "$sso" == "not_relevant" ]] + then + registration="None" + elif [[ "$ldap" == "false" ]] + then + registration="Free" + fi + ynh_write_var_in_file --file="$service_path" --key="service.registration" --value="$registration" + fi +fi diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..ec62a29 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,22 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers +app=$1 +install_dir=/var/www/chatonsinfos/ +service_path=${install_dir}public/${app}.properties +local groups_removed=$4 +local app_info="$(yunohost app info $app --full --json)" +get_info() { + echo $app_info | jq -r ".$1" +} +if [[ "$groups_removed" == *"visitors"* ]] +then + registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") + local ldap="$(get_info 'manifest.integration.ldap')" + local sso="$(get_info 'manifest.integration.sso')" + if [[ "$registration" != "Member" && "$registration" != "Client" ]] + then + ynh_write_var_in_file --file="$service_path" --key="service.registration" --value="Member" + fi +fi diff --git a/hooks/post_app_restore b/hooks/post_app_restore new file mode 100644 index 0000000..085c37c --- /dev/null +++ b/hooks/post_app_restore @@ -0,0 +1,8 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers + +install_dir=/var/www/chatonsinfos/ +generate_config_panel +update_subs From abd6f4aee4ebd45f2fe458b3fabd480105338e9b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:56:46 +0100 Subject: [PATCH 09/20] Update change_url: simplify script, there's no service to stop/start --- scripts/change_url | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f0964a6..6e51e15 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,47 +1,8 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# 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_change_url_nginx_config -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - -#================================================= -# 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 From 8f9db727f6c1bb9a74abc00cb611d371e96ab8c7 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 29 Nov 2023 16:56:49 +0000 Subject: [PATCH 10/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 e1889fc..2c5dac6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ChatonsInfos is a protocol for sharing data about the CHATONS collective, its me * Official app website: * 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 e0055ea..8b2f6d9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -32,7 +32,7 @@ ChatonsInfos est un protocole de partage de données sur le collectif CHATONS, s * Site officiel de l’app : * 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 ada33b1d2c8693508d4492f31687d3fffe62d09a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:58:18 +0100 Subject: [PATCH 11/20] Simplify upgrade script --- scripts/upgrade | 52 ------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 20c9bd2..76979f8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,25 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -# Settings are automatically loaded as bash variables -# in every app script context, therefore typically these will exist: -# - $domain -# - $path -# - $language -# - $install_dir -# - $port -# ... - -# In the context of upgrade, -# - resources are automatically provisioned / updated / deleted (depending on existing resources) -# - a safety backup is automatically created by the core and will be restored if the upgrade fails - -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -49,12 +30,6 @@ upgrade_type=$(ynh_check_app_version_changed) #REMOVEME? # ynh_app_setting_set --app=$app --key=db_name --value=$db_name #fi -# If install_dir doesn't exist, create it -#if [ -z "$install_dir" ]; then -# install_dir=/var/www/$app -# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -#fi - #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) #================================================= @@ -69,9 +44,6 @@ then ynh_setup_source --dest_dir="$install_dir/sources" fi -# $install_dir will automatically be initialized with some decent -# permission by default ... however, you may need to recursively reapply -# ownership to all files such as after the ynh_setup_source step chown -R $app:www-data "$install_dir" #================================================= @@ -79,11 +51,8 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 -# This should be a literal copypasta of what happened in the install's "System configuration" section - ynh_add_nginx_config - #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= @@ -93,29 +62,8 @@ ynh_script_progression --message="Generating configuration panel..." --weight=1 generate_config_panel -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 - -### Same as during install -### -### The file will automatically be backed-up if it's found to be manually modified (because -### ynh_add_config keeps track of the file's checksum) - -# ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" - -# FIXME: this should be handled by the core in the future -# You may need to use chmod 600 instead of 400, -# for example if the app is expected to be able to modify its own config chmod 400 "$install_dir/public/organization.properties" chown $app:www-data "$install_dir/public/organization.properties" - -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file" ynh_store_file_checksum --file="$install_dir/public/organization.properties" #================================================= From b983a9c24afd3ca91e619163c7c79b962fe1528b Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:24:37 +0100 Subject: [PATCH 12/20] [fix] Corrupted TOML read from /etc/yunohost/apps/chatonsinfos/config_panel.toml (reason: What? name already exists?OrderedDict([('name', '')]) --- conf/config_panel.toml.j2 | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/config_panel.toml.j2 b/conf/config_panel.toml.j2 index 884f1c0..ef9e6a0 100644 --- a/conf/config_panel.toml.j2 +++ b/conf/config_panel.toml.j2 @@ -1,7 +1,6 @@ version = "1.0" [main] -name.en = "Organization" name.fr = "Organisation" bind = ":{{ install_dir }}/public/organization.properties" From 972638b6cff4e743652edab7b7b8850afa560fcd Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:30:56 +0100 Subject: [PATCH 13/20] [fix] Do nothing if we change chatonsinfos url --- hooks/post_app_change_url | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index 6d73392..1eedb02 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -1,6 +1,9 @@ #!/bin/bash source /usr/share/yunohost/helpers + +[ "${YNH_APP_INSTANCE_NAME}" == "chatonsinfos" ] && exit 0 + properties_path="/var/www/chatonsinfos/public/${YNH_APP_INSTANCE_NAME}.properties" ynh_write_var_in_file --file="$properties_path" --key="service.website" --value="https://$YNH_APP_NEW_DOMAIN/$YNH_APP_NEW_PATH" ynh_write_var_in_file --file="$properties_path" --key="file.datetime" --value="$(date '+%Y-%m-%dT%H:%M:%S')" From a6491947f1e301527b7b862c468dc381b85188bb Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:32:15 +0100 Subject: [PATCH 14/20] [fix] Do nothing in hook if we remove chatonsinfos --- hooks/post_app_remove | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hooks/post_app_remove b/hooks/post_app_remove index a5f5ba8..dc2c86b 100644 --- a/hooks/post_app_remove +++ b/hooks/post_app_remove @@ -3,6 +3,8 @@ source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh source /usr/share/yunohost/helpers +[ "${YNH_APP_ID}" == "chatonsinfos" ] && exit 0 + install_dir=/var/www/chatonsinfos/ ynh_secure_remove --file="$install_dir/public/${YNH_APP_ID}.properties" From 060697dcd62ec2d87ffd74a6372970991b7b6a95 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:33:18 +0100 Subject: [PATCH 15/20] [fix) Do nothing on perm change with chatonsinfos --- hooks/post_app_removeaccess | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index ec62a29..3360b8c 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -3,6 +3,9 @@ source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh source /usr/share/yunohost/helpers app=$1 + +[ "${app}" == "chatonsinfos" ] && exit 0 + install_dir=/var/www/chatonsinfos/ service_path=${install_dir}public/${app}.properties local groups_removed=$4 From f8c50097389996230dbdc6bf2ffdfe6e4786f98d Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:33:54 +0100 Subject: [PATCH 16/20] [fix] Do nothing on perm change on chatonsinfos --- hooks/post_app_addaccess | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 9b5a189..662067d 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -3,6 +3,9 @@ source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh source /usr/share/yunohost/helpers app=$1 + +[ "${app}" == "chatonsinfos" ] && exit 0 + install_dir=/var/www/chatonsinfos/ service_path=${install_dir}public/${app}.properties local groups_added=$4 From b2b834e8cbab06b83d24091315cfaab65a753855 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 21:43:39 +0100 Subject: [PATCH 17/20] [fix] YNH_APP_ID -> YNH_APP_INSTANCE_NAME --- hooks/post_app_remove | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/post_app_remove b/hooks/post_app_remove index dc2c86b..8dbeb5d 100644 --- a/hooks/post_app_remove +++ b/hooks/post_app_remove @@ -3,9 +3,9 @@ source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh source /usr/share/yunohost/helpers -[ "${YNH_APP_ID}" == "chatonsinfos" ] && exit 0 +[ "${YNH_APP_INSTANCE_NAME}" == "chatonsinfos" ] && exit 0 install_dir=/var/www/chatonsinfos/ -ynh_secure_remove --file="$install_dir/public/${YNH_APP_ID}.properties" +ynh_secure_remove --file="$install_dir/public/${YNH_APP_INSTANCE_NAME}.properties" -sed -i "/^subs\.${YNH_APP_ID} =/d" "$install_dir/public/organization.properties" +sed -i "/^subs\.${YNH_APP_INSTANCE_NAME} =/d" "$install_dir/public/organization.properties" From 8301c3330d2a44963bb098c5f65378ed6ec9f63e Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 29 Nov 2023 22:01:22 +0100 Subject: [PATCH 18/20] [fix] TOML validation error in CI --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index 2dfe6fe..b595f06 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -10,7 +10,7 @@ services = [] [main.organization] name = "" -[main.organization.name] +[main.organization._name] ask.en = "Nom de l'oganisation" type = "string" bind = "organization.name>/var/www/__APP__/public/organization.properties" From d2fbcad279bfaecf3f79e932f2423657d49cd48a Mon Sep 17 00:00:00 2001 From: ljf Date: Wed, 29 Nov 2023 22:24:43 +0100 Subject: [PATCH 19/20] [fix] keep generated config_panel --- hooks/post_app_upgrade | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 hooks/post_app_upgrade diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade new file mode 100644 index 0000000..085c37c --- /dev/null +++ b/hooks/post_app_upgrade @@ -0,0 +1,8 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers + +install_dir=/var/www/chatonsinfos/ +generate_config_panel +update_subs From 8324c74e20ecd0d3c2b471893c24051473e34023 Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 30 Nov 2023 00:03:23 +0100 Subject: [PATCH 20/20] [fix] local only in function --- hooks/post_app_addaccess | 8 ++++---- hooks/post_app_removeaccess | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 662067d..5695c0e 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -8,16 +8,16 @@ app=$1 install_dir=/var/www/chatonsinfos/ service_path=${install_dir}public/${app}.properties -local groups_added=$4 -local app_info="$(yunohost app info $app --full --json)" +groups_added=$4 +app_info="$(yunohost app info $app --full --json)" get_info() { echo $app_info | jq -r ".$1" } if [[ "$groups_added" == *"visitors"* ]] then registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") - local ldap="$(get_info 'manifest.integration.ldap')" - local sso="$(get_info 'manifest.integration.sso')" + ldap="$(get_info 'manifest.integration.ldap')" + sso="$(get_info 'manifest.integration.sso')" if [[ "$registration" != "None" && "$registration" != "Free" ]] then if [[ "$ldap" == "not_relevant" && "$sso" == "not_relevant" ]] diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index 3360b8c..7933110 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -8,16 +8,16 @@ app=$1 install_dir=/var/www/chatonsinfos/ service_path=${install_dir}public/${app}.properties -local groups_removed=$4 -local app_info="$(yunohost app info $app --full --json)" +groups_removed=$4 +app_info="$(yunohost app info $app --full --json)" get_info() { echo $app_info | jq -r ".$1" } if [[ "$groups_removed" == *"visitors"* ]] then registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") - local ldap="$(get_info 'manifest.integration.ldap')" - local sso="$(get_info 'manifest.integration.sso')" + ldap="$(get_info 'manifest.integration.ldap')" + sso="$(get_info 'manifest.integration.sso')" if [[ "$registration" != "Member" && "$registration" != "Client" ]] then ynh_write_var_in_file --file="$service_path" --key="service.registration" --value="Member"