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"