From a9e9e88f8156a784d80781119c4eb282dedc0e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 1 Jul 2024 11:30:11 +0200 Subject: [PATCH 1/4] Cleanup, fix manifest questions, full_replace --- conf/sql/admin.sql | 3 +-- manifest.toml | 20 +++++++++++++---- scripts/backup | 2 -- scripts/change_url | 2 -- scripts/install | 56 ++++++++++++++++++++-------------------------- scripts/remove | 2 -- scripts/restore | 12 ++++------ scripts/upgrade | 42 +++++++++++++++++++++++++++------- tests.toml | 6 +++-- 9 files changed, 83 insertions(+), 62 deletions(-) diff --git a/conf/sql/admin.sql b/conf/sql/admin.sql index b0b2d93..3f13930 100644 --- a/conf/sql/admin.sql +++ b/conf/sql/admin.sql @@ -1,3 +1,2 @@ -INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__USER_NAME__', '__NAME__', '__USER_EMAIL__', '__ADMIN_PASSWORD_HASHED__'); +INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__ADMIN_USERNAME__', '__ADMIN_NAME__', '__ADMIN_EMAIL__', '__ADMIN_PASSWORD_HASHED__'); INSERT INTO `wt_user_setting` (`user_id`, `setting_name`, `setting_value`) VALUES ('1', 'canadmin', '1'), ('1', 'verified', '1'), ('1', 'verified_by_admin', '1'); - diff --git a/manifest.toml b/manifest.toml index 0e278b1..dca2535 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "webtrees" @@ -34,19 +36,19 @@ ram.runtime = "50M" type = "path" default = "/webtrees" - [install.username] + [install.admin_username] ask.en = "Choose an admin username (Not a LDAP User)" ask.fr = "Choisissez un nom d'utilisateur pour l'administrateur de Webtrees (ne doit pas être un utilisateur YunoHost existant)" type = "string" example = "john" - [install.name] + [install.admin_name] ask.en = "Name of the user (Not a LDAP User)" ask.fr = "Nom de cet utilisateur" type = "string" example = "john doe" - [install.email] + [install.admin_email] ask.en = "Admin email (All the new registration will be sent on this email)" ask.fr = "Adresse email de l'administrateur (Toutes les nouvelles inscriptions seront envoyées à cette adresse)" type = "string" @@ -73,7 +75,17 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "mariadb-server, php8.3-mbstring, php8.3-mysql, php8.3-zip, php8.3-gd, php8.3-xml, php8.3-curl, php8.3-intl, mailutils" + packages = [ + "mariadb-server", + "php8.3-mbstring", + "php8.3-mysql", + "php8.3-zip", + "php8.3-gd", + "php8.3-xml", + "php8.3-curl", + "php8.3-intl", + "mailutils", + ] [resources.database] type = "mysql" diff --git a/scripts/backup b/scripts/backup index 9f67fa7..f5a97a9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 4ba8cf7..cfcb0d6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/install b/scripts/install index a26244d..21cc7a7 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,19 +8,13 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST +# INITIALIZE AND STORE SETTINGS #================================================= admin_password=$(ynh_string_random 24) admin_password_hashed=$(mkpasswd -m md5crypt --stdin <<< "$admin_password") -admin_username=$YNH_APP_ARG_USERNAME -admin_name=$YNH_APP_ARG_NAME -admin_email=$YNH_APP_ARG_EMAIL -ynh_app_setting_set --app=$app --key=admin_username --value=$admin_username -ynh_app_setting_set --app=$app --key=admin_name --value=$admin_name -ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email -ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password +ynh_app_setting_set --app="$app" --key="admin_password" --value="$admin_password" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -32,14 +24,32 @@ ynh_script_progression --message="Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -chmod -R 700 $install_dir/data +chmod -R 700 "$install_dir/data" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# NGINX CONFIGURATION +# APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 + +# Adding the details of the database to the config file +ynh_add_config --template="config.ini.php" --destination="$install_dir/data/config.ini.php" + +# Load initial SQL into the new database +ynh_add_config --template="sql/webtrees.sql" --destination="$install_dir/webtrees.sql" +ynh_add_config --template="sql/admin.sql" --destination="$install_dir/admin.sql" + +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/webtrees.sql" +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/admin.sql" + +ynh_secure_remove --file="$install_dir/webtrees.sql" +ynh_secure_remove --file="$install_dir/admin.sql" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -47,24 +57,6 @@ ynh_add_nginx_config # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# MODIFY A CONFIG FILE -#================================================= - -# Adding the details of the database to the config file -ynh_add_config --template="config.ini.php" --destination="$install_dir/data/config.ini.php" - -# Load initial SQL into the new database -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "../conf/sql/webtrees.sql" - -# Replace variables in sql scripts -ynh_replace_string --match_string="__USER_NAME__" --replace_string="$admin_username" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__NAME__" --replace_string="$admin_name" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__USER_EMAIL__" --replace_string="$admin_email" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__ADMIN_PASSWORD_HASHED__" --replace_string="$admin_password_hashed" --target_file="../conf/sql/admin.sql" - -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "../conf/sql/admin.sql" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 2c04d62..13ece6b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/restore b/scripts/restore index ae3bef1..6026dd1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,19 +10,19 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring $app main directory..." --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=1 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -35,14 +33,12 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a843cc3..a31e58f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,23 +8,51 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# CHECK THE PATH +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# Migrate manifest questions +if [ -z "$admin_username" ]; then + admin_username="$username" + ynh_app_setting_set --app="$app" --key="admin_username" --value="$admin_username" +fi +if [ -n "$username" ]; then + ynh_app_setting_delete --app="$app" --key="username" +fi + +if [ -z "$admin_name" ]; then + admin_name="$name" + ynh_app_setting_set --app="$app" --key="admin_name" --value="$admin_name" +fi +if [ -n "$name" ]; then + ynh_app_setting_delete --app="$app" --key="name" +fi + +if [ -z "$admin_email" ]; then + admin_email="$email" + ynh_app_setting_set --app="$app" --key="admin_email" --value="$admin_email" +fi +if [ -n "$email" ]; then + ynh_app_setting_delete --app="$app" --key="email" +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir=$install_dir --keep="data modules_v4" +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="data modules_v4" -chmod -R 700 $install_dir/data +chmod -R 700 "$install_dir/data" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config diff --git a/tests.toml b/tests.toml index b867703..9562ff8 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default] @@ -5,7 +7,7 @@ test_format = 1.0 # ------------------------------- # Default args to use for install # ------------------------------- - + args.username = "john" args.name = "john" args.email = "admin@example.com" @@ -13,5 +15,5 @@ test_format = 1.0 # ------------------------------- # Commits to test upgrade from # ------------------------------- - + #test_upgrade_from.dfcde24cce4db0527465acbc16dcecf9a3082858.name = "2.1.16" From 7c5b3d1398834c3bf0067413fdb628dbe1ef19d7 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 1 Jul 2024 09:30:30 +0000 Subject: [PATCH 2/4] Auto-update READMEs --- README.md | 2 +- README_es.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- README_zh_Hans.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 181dbf5..c2fdbdc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Webtrees for YunoHost -[![Integration level](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![Working status](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![Working status](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![Install Webtrees with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) diff --git a/README_es.md b/README_es.md index f235a08..d738999 100644 --- a/README_es.md +++ b/README_es.md @@ -5,7 +5,7 @@ No se debe editar a mano. # Webtrees para Yunohost -[![Nivel de integración](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![Instalar Webtrees con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) diff --git a/README_eu.md b/README_eu.md index 493a838..af6aac1 100644 --- a/README_eu.md +++ b/README_eu.md @@ -5,7 +5,7 @@ EZ editatu eskuz. # Webtrees YunoHost-erako -[![Integrazio maila](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![Integrazio maila](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![Instalatu Webtrees YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) diff --git a/README_fr.md b/README_fr.md index 90b3434..d284d18 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ Il NE doit PAS être modifié à la main. # Webtrees pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![Installer Webtrees avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) diff --git a/README_gl.md b/README_gl.md index 5122a28..5026098 100644 --- a/README_gl.md +++ b/README_gl.md @@ -5,7 +5,7 @@ NON debe editarse manualmente. # Webtrees para YunoHost -[![Nivel de integración](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![Instalar Webtrees con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 6c9ead5..712d1ee 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -5,7 +5,7 @@ # YunoHost 上的 Webtrees -[![集成程度](https://dash.yunohost.org/integration/webtrees.svg)](https://dash.yunohost.org/appci/app/webtrees) ![工作状态](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) +[![集成程度](https://dash.yunohost.org/integration/webtrees.svg)](https://ci-apps.yunohost.org/ci/apps/webtrees/) ![工作状态](https://ci-apps.yunohost.org/ci/badges/webtrees.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/webtrees.maintain.svg) [![使用 YunoHost 安装 Webtrees](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=webtrees) From 6f27c348e7bfba9447896a7014859b019956cfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 1 Jul 2024 12:40:41 +0200 Subject: [PATCH 3/4] Fix tests args --- tests.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests.toml b/tests.toml index 9562ff8..42a573b 100644 --- a/tests.toml +++ b/tests.toml @@ -8,9 +8,9 @@ test_format = 1.0 # Default args to use for install # ------------------------------- - args.username = "john" - args.name = "john" - args.email = "admin@example.com" + args.admin_username = "john" + args.admin_name = "john" + args.admin_email = "admin@example.com" # ------------------------------- # Commits to test upgrade from From fe507604aef8df8b4f4a080008931a2f8872db39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 1 Jul 2024 13:52:02 +0200 Subject: [PATCH 4/4] Fix upgrade missing vars --- scripts/upgrade | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a31e58f..6b4b862 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,27 +13,27 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Migrate manifest questions -if [ -z "$admin_username" ]; then +if [ -z "${admin_username:-}" ]; then admin_username="$username" ynh_app_setting_set --app="$app" --key="admin_username" --value="$admin_username" fi -if [ -n "$username" ]; then +if [ -n "${username:-}" ]; then ynh_app_setting_delete --app="$app" --key="username" fi -if [ -z "$admin_name" ]; then +if [ -z "${admin_name:-}" ]; then admin_name="$name" ynh_app_setting_set --app="$app" --key="admin_name" --value="$admin_name" fi -if [ -n "$name" ]; then +if [ -n "${name:-}" ]; then ynh_app_setting_delete --app="$app" --key="name" fi -if [ -z "$admin_email" ]; then +if [ -z "${admin_email:-}" ]; then admin_email="$email" ynh_app_setting_set --app="$app" --key="admin_email" --value="$admin_email" fi -if [ -n "$email" ]; then +if [ -n "${email:-}" ]; then ynh_app_setting_delete --app="$app" --key="email" fi