From 7af8e33a9fce3385c4812ca3b0616153c4a18866 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 20 Aug 2024 01:31:22 +0200 Subject: [PATCH] Panel config (#66) * add config_panel.toml file * add install and upgrade * syntax upgrade * syntax error * correct values cleaning config.local.user * synntax sed * try repalce vs sed * try debug YN_NULL * quote ahhha * quote ahhha akka * quote ahhha akka * add in config panel avalaibity to disable emails * add in config panel avalaibity to disable emails bug boolean * add in config panel avalaibity to disable emails bug boolean * add in config panel avalaibity to disable emails bug boolean * add in config panel avalaibity to disable emails bug boolean * add in config panel avalaibity to disable emails bug boolean * forget the fonction disable email for now in config panel * forget the fonction disable email for now in config panel * forget the fonction disable email for now in config panel * syntax * debug values * remove mail_return_path in config panel * remove mail_return_path in config panel * debug values * debug values * debug values * debug values config panel * debug values config panel removing all mail values, only smtp * come back to first test where upgrade works, but not install * try debug cinfig panel install * try add post-install * try add post-install * try add post-install * keep first panel_config working * add type select for choices * Auto-update READMEs --------- Co-authored-by: yunohost-bot --- README.md | 2 +- README_es.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- README_id.md | 2 +- README_ru.md | 2 +- README_zh_Hans.md | 2 +- conf/config.local.php | 16 ++--- conf/config.local.user.php | 102 ------------------------------ config_panel.toml | 62 ++++++++++++++++++ doc/ynh_local_curl-install-paheko | 1 + manifest.toml | 9 ++- scripts/install | 39 ++++++++++++ scripts/upgrade | 31 ++++++++- 15 files changed, 151 insertions(+), 125 deletions(-) create mode 100644 config_panel.toml create mode 100644 doc/ynh_local_curl-install-paheko diff --git a/README.md b/README.md index d168a81..92c2163 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ It shall NOT be edited by hand. Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Shipped version:** 1.3.11~ynh2 +**Shipped version:** 1.3.11~ynh3 **Demo:** diff --git a/README_es.md b/README_es.md index 6436f3f..ba60e61 100644 --- a/README_es.md +++ b/README_es.md @@ -19,7 +19,7 @@ No se debe editar a mano. Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Versión actual:** 1.3.11~ynh2 +**Versión actual:** 1.3.11~ynh3 **Demo:** diff --git a/README_eu.md b/README_eu.md index 8c3ab57..ed328f2 100644 --- a/README_eu.md +++ b/README_eu.md @@ -19,7 +19,7 @@ EZ editatu eskuz. Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Paketatutako bertsioa:** 1.3.11~ynh2 +**Paketatutako bertsioa:** 1.3.11~ynh3 **Demoa:** diff --git a/README_fr.md b/README_fr.md index a7b172b..7e997d9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Il NE doit PAS être modifié à la main. Paheko (mot de la langue Māori qui signifie « coopérer », illustrant le but du logiciel : améliorer ensemble le quotidien de la gestion d'une association) est un logiciel de gestion associative. Il est l'outil de prédilection pour gérer une association, un club sportif, une ONG, etc. Il est conçu pour répondre aux besoins d'une structure de petite à moyenne taille : gestion des adhérents, comptabilité, site web, prise de notes en réunion, archivage et partage des documents de fonctionnement de l'association, discussion entre adhérents. -**Version incluse :** 1.3.11~ynh2 +**Version incluse :** 1.3.11~ynh3 **Démo :** diff --git a/README_gl.md b/README_gl.md index f6b7a6d..db71438 100644 --- a/README_gl.md +++ b/README_gl.md @@ -19,7 +19,7 @@ NON debe editarse manualmente. Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Versión proporcionada:** 1.3.11~ynh2 +**Versión proporcionada:** 1.3.11~ynh3 **Demo:** diff --git a/README_id.md b/README_id.md index 8caa35e..a179dee 100644 --- a/README_id.md +++ b/README_id.md @@ -19,7 +19,7 @@ Ini TIDAK boleh diedit dengan tangan. Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Versi terkirim:** 1.3.11~ynh2 +**Versi terkirim:** 1.3.11~ynh3 **Demo:** diff --git a/README_ru.md b/README_ru.md index 5201e1e..fb0f713 100644 --- a/README_ru.md +++ b/README_ru.md @@ -19,7 +19,7 @@ Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**Поставляемая версия:** 1.3.11~ynh2 +**Поставляемая версия:** 1.3.11~ynh3 **Демо-версия:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 4f9f53d..522e8b1 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -19,7 +19,7 @@ Paheko (a word from the Māori language meaning "to cooperate", illustrating the purpose of the software: to improve together the daily management of an association) is software for associative management. It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members. -**分发版本:** 1.3.11~ynh2 +**分发版本:** 1.3.11~ynh3 **演示:** diff --git a/conf/config.local.php b/conf/config.local.php index 44f9db0..fb91b3c 100644 --- a/conf/config.local.php +++ b/conf/config.local.php @@ -500,7 +500,6 @@ const USE_CRON = true; //const DISABLE_EMAIL = false; - /** * Hôte du serveur SMTP, mettre à null (défaut) pour utiliser la fonction * mail() de PHP @@ -508,7 +507,7 @@ const USE_CRON = true; * Défaut : null */ -//const SMTP_HOST = '__DOMAIN__'; +const SMTP_HOST = '__SMTP_HOST__'; /** * Port du serveur SMTP @@ -519,7 +518,7 @@ const USE_CRON = true; * Défaut : 587 */ -//const SMTP_PORT = 25; +const SMTP_PORT = __SMTP_PORT__; /** * Login utilisateur pour le server SMTP @@ -529,7 +528,7 @@ const USE_CRON = true; * Défaut : null */ -//const SMTP_USER = '__APP__'; +const SMTP_USER = '__SMTP_USER__'; /** * Mot de passe pour le serveur SMTP @@ -539,7 +538,7 @@ const USE_CRON = true; * Défaut : null */ -//const SMTP_PASSWORD = '__MAIL_PWD__'; +const SMTP_PASSWORD = '__SMTP_PASSWORD__'; /** * Sécurité du serveur SMTP @@ -552,7 +551,7 @@ const USE_CRON = true; * Défaut : STARTTLS */ -//const SMTP_SECURITY = 'STARTTLS'; +const SMTP_SECURITY = '__SMTP_SECURITY__'; /** * Nom du serveur utilisé dans le HELO SMTP @@ -584,8 +583,7 @@ const USE_CRON = true; * Défaut : null */ -//const MAIL_RETURN_PATH = '__APP__@__DOMAIN__'; - +const MAIL_RETURN_PATH = '__MAIL_RETURN_PATH__'; /** * Adresse e-mail expéditrice des messages (Sender) @@ -602,7 +600,7 @@ const USE_CRON = true; * Défaut : null */ -//const MAIL_SENDER = '__APP__@__DOMAIN__'; +const MAIL_SENDER = '__MAIL_SENDER__'; /** * Mot de passe pour l'accès à l'API permettant de gérer les mails d'erreur diff --git a/conf/config.local.user.php b/conf/config.local.user.php index 890c7aa..877d546 100644 --- a/conf/config.local.user.php +++ b/conf/config.local.user.php @@ -11,106 +11,4 @@ // Nécessaire pour situer les constantes dans le bon namespace namespace Paheko; -/** - * Hôte du serveur SMTP, mettre à false (défaut) pour utiliser la fonction - * mail() de PHP - * - * Défaut : null - */ - -const SMTP_HOST = '__DOMAIN__'; - -/** - * Port du serveur SMTP - * - * 25 = port standard pour connexion non chiffrée (465 pour Gmail) - * 587 = port standard pour connexion SSL - * - * Défaut : 587 - */ - -const SMTP_PORT = 25; - -/** - * Login utilisateur pour le server SMTP - * - * mettre à null pour utiliser un serveur local ou anonyme - * - * Défaut : null - */ - -const SMTP_USER = '__APP__'; - -/** - * Mot de passe pour le serveur SMTP - * - * mettre à null pour utiliser un serveur local ou anonyme - * - * Défaut : null - */ - -const SMTP_PASSWORD = '__MAIL_PWD__'; - -/** - * Sécurité du serveur SMTP - * - * NONE = pas de chiffrement - * SSL = connexion SSL native - * TLS = connexion TLS native (le plus sécurisé) - * STARTTLS = utilisation de STARTTLS (moyennement sécurisé) - * - * Défaut : STARTTLS - */ - -const SMTP_SECURITY = 'STARTTLS'; - -/** - * Nom du serveur utilisé dans le HELO SMTP - * - * Si NULL, alors le nom renseigné comme SERVER_NAME (premier nom du virtual host Apache) - * sera utilisé. - * - * Defaut : NULL - * - * @var null|string - */ - -const SMTP_HELO_HOSTNAME = '__DOMAIN__'; - -/** - * Adresse e-mail destinée à recevoir les erreurs de mail - * (adresses invalides etc.) — Return-Path / MAIL FROM - * - * Si laissé NULL, alors l'adresse e-mail de l'association sera utilisée. - * En cas d'hébergement de plusieurs associations, il est conseillé - * d'utiliser une adresse par association. - * - * Voir la documentation de configuration sur des exemples de scripts - * permettant de traiter les mails reçus à cette adresse. - * - * Si renseigné, cette adresse sera utilisée également comme "MAIL FROM" - * lors de la session avec le serveur SMTP. - * - * Défaut : null - */ - -const MAIL_RETURN_PATH = '__APP__@__DOMAIN__'; - - -/** - * Adresse e-mail expéditrice des messages (Sender) - * - * Si vous envoyez des mails pour plusieurs associations, il est souhaitable - * de forcer l'adresse d'expéditeur des messages pour passer les règles SPF et DKIM. - * - * Dans ce cas l'adresse de l'association sera indiquée en "Reply-To", et - * l'adresse contenue dans MAIL_SENDER sera dans le From. - * - * Si laissé NULL, c'est l'adresse de l'association indiquée dans la configuration - * qui sera utilisée. - * - * Défaut : null - */ - -const MAIL_SENDER = '__APP__@__DOMAIN__'; diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..eb31a08 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,62 @@ +version = "1.0" + +################################################################################ +#### ABOUT PANELS +################################################################################ + +[main] + +name.fr = "Configuration SMTP" + + ############################################################################ + #### ABOUT SECTIONS + ############################################################################ + + [main.smtp] + + name = "" + + ## (optional) This help properties is a short help displayed on the same line + + optional = false + + [main.smtp.smtp_host] + ask.fr = "Serveur SMTP" + type = "string" + bind = "SMTP_HOST:__INSTALL_DIR__/config.local.php" + + [main.smtp.smtp_port] + ask.fr = "Port" + min = 25 + type = "number" + bind = "SMTP_PORT:__INSTALL_DIR__/config.local.php" + + [main.smtp.smtp_user] + ask.fr = "Nom d'utilisateur" + type = "string" + bind = "SMTP_USER:__INSTALL_DIR__/config.local.php" + + [main.smtp.smtp_password] + ask.fr = "Mot de passe" + type = "password" + bind = "SMTP_PASSWORD:__INSTALL_DIR__/config.local.php" + + [main.smtp.smtp_security] + ask.fr = "Sécurité de la connexion" + type = "select" + choices.NONE = "NONE, pas de chiffrement" + choices.SSL = "SSL, connexion SSL native" + choices.TLS = "TLS, connexion TLS native (le plus sécurisé)" + choices.STARTTLS = "STARTTLS, utilisation de STARTTLS (moyennement sécurisé)" + bind = "SMTP_SECURITY:__INSTALL_DIR__/config.local.php" + + [main.smtp.mail_sender] + ask.fr = "Adresse e-mail expéditrice des messages" + type = "string" + bind = "MAIL_SENDER:__INSTALL_DIR__/config.local.php" + + [main.smtp.mail_return_path] + ask.fr = "Adresse e-mail expéditrice des messages" + type = "string" + bind = "MAIL_RETURN_PATH:__INSTALL_DIR__/config.local.php" + diff --git a/doc/ynh_local_curl-install-paheko b/doc/ynh_local_curl-install-paheko new file mode 100644 index 0000000..b6b70e2 --- /dev/null +++ b/doc/ynh_local_curl-install-paheko @@ -0,0 +1 @@ +ynh_local_curl https://paheko.rodinux.fr/admin/install.php --args="country=FR&name=toto&user_name=bob&user_email=bob@example.org&password=bopbidibopbopbop&password_confirmed=bopbidibopbopbop" \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index 2f46f4b..5404b50 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Paheko" description.en = "Association management software" description.fr = "Logiciel de gestion d'association" -version = "1.3.11~ynh2" +version = "1.3.11~ynh3" maintainers = ["rodinux"] @@ -35,10 +35,9 @@ ram.runtime = "50M" default = "visitors" [resources] - [resources.sources.main] - url = "https://fossil.kd2.org/paheko/uv/paheko-1.3.11.tar.gz" - sha256 = "88624f5efdc7dc7ce779c29827d25e8a9a8ffa21793c1a8320c3705d5ac1fc31" - + [resources.sources.main] + url = "https://fossil.kd2.org/paheko/uv/paheko-1.3.11.tar.gz" + sha256 = "88624f5efdc7dc7ce779c29827d25e8a9a8ffa21793c1a8320c3705d5ac1fc31" [resources.system_user] allow_email = true diff --git a/scripts/install b/scripts/install index 6820f82..4848bee 100644 --- a/scripts/install +++ b/scripts/install @@ -12,6 +12,21 @@ source /usr/share/yunohost/helpers secret_key=$(ynh_string_random --length=50) ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key +smtp_host=$domain +smtp_port=25 +smtp_user=$app +smtp_password=$mail_pwd +smtp_security=STARTTLS +mail_return_path=$app@$domain +mail_sender=$app@$domain +ynh_app_setting_set --app=$app --key=smtp_host --value=$smtp_host +ynh_app_setting_set --app=$app --key=smtp_port --value=$smtp_port +ynh_app_setting_set --app=$app --key=smtp_user --value=$smtp_user +ynh_app_setting_set --app=$app --key=smtp_password --value=$smtp_password +ynh_app_setting_set --app=$app --key=smtp_security --value=$smtp_security +ynh_app_setting_set --app=$app --key=mail_return_path --value=$mail_return_path +ynh_app_setting_set --app=$app --key=mail_sender --value=$mail_sender + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -51,6 +66,30 @@ ynh_add_config --template="config.local.php" --destination="$install_dir/config. chmod 440 "$install_dir/config.local.php" chown $app:$app "$install_dir/config.local.php" +#================================================= +# SETUP APPLICATION WITH CURL +#================================================= + +### Use these lines only if the app installation needs to be finalized through +### web forms. We generally don't want to ask the final user, +### so we're going to use curl to automatically fill the fields and submit the +### forms. + +# Post-Installation with curl +# ynh_script_progression --message="Finalizing installation..." --weight=1 + +# domain=$domain +# admin_url="/admin/install.php" + +# country=$country +# name_association=$name_association +# user_name=$user_name +# user_email=$user_email +# password=$password +# password_confirmed=$password_confirmed + +# ynh_local_curl $admin_url "country=$country" "name=$name_association" "user_name=$user_name" "user_email=$user_email" "password=$password" "password_confirmed=$password_confirmed" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7535325..c40a6c3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,36 @@ if [ -z "${secret_key:-}" ]; then ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key fi +if [ -z "${smtp_host:-}" ]; then + user_conf="$data_dir/data/config.local.user.php" + if [ -f $user_conf ]; then + smtp_host=$(ynh_read_var_in_file --file=$user_conf --key=SMTP_HOST) + smtp_port=$(ynh_read_var_in_file --file=$user_conf --key=SMTP_PORT) + smtp_user=$(ynh_read_var_in_file --file=$user_conf --key=SMTP_USER) + smtp_password=$(ynh_read_var_in_file --file=$user_conf --key=SMTP_PASSWORD) + smtp_security=$(ynh_read_var_in_file --file=$user_conf --key=SMTP_SECURITY) + mail_return_path=$(ynh_read_var_in_file --file=$user_conf --key=MAIL_RETURN_PATH) + mail_sender=$(ynh_read_var_in_file --file=$user_conf --key=MAIL_SENDER) + ynh_replace_string --match_string="const SMTP_" --replace_string="//const SMTP_" --target_file=$user_conf + ynh_replace_string --match_string="const MAIL_" --replace_string="//const MAIL_" --target_file=$user_conf + else + smtp_host=$domain + smtp_port=25 + smtp_user=$app + smtp_password=$mail_pwd + smtp_security=STARTTLS + mail_return_path=$app@$domain + mail_sender=$app@$domain + fi + ynh_app_setting_set --app=$app --key=smtp_host --value=$smtp_host + ynh_app_setting_set --app=$app --key=smtp_port --value=$smtp_port + ynh_app_setting_set --app=$app --key=smtp_user --value=$smtp_user + ynh_app_setting_set --app=$app --key=smtp_password --value=$smtp_password + ynh_app_setting_set --app=$app --key=smtp_security --value=$smtp_security + ynh_app_setting_set --app=$app --key=mail_return_path --value=$mail_return_path + ynh_app_setting_set --app=$app --key=mail_sender --value=$mail_sender +fi + #================================================= # KEEP CONFIGS IF NEEDED #================================================= @@ -143,7 +173,6 @@ else chown $app:www-data "$data_dir/data/local_addresses" fi - if [ -f "$install_dir/data/association.sqlite" ]; then ynh_script_progression --message="Moving db files..." --weight=5 mv $install_dir/data/association.* $data_dir/data/