From 1e61302fbc16f6e8a9f562fdf8955a860862ad51 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 18 Mar 2021 23:50:24 +0100 Subject: [PATCH 1/7] Fix linter warnings --- manifest.json | 29 ++++------------------------- scripts/install | 7 +++---- scripts/upgrade | 38 ++++++++------------------------------ 3 files changed, 15 insertions(+), 59 deletions(-) diff --git a/manifest.json b/manifest.json index 819a1ef..cb7f203 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Un forum de nouvelle génération, simplement.", "de": "Forum der nächsten Generation leicht gemacht." }, - "version": "0.1.0.14~ynh2", + "version": "0.1.0.14~ynh3", "url": "http://flarum.org/", "license": "MIT", "maintainer": { @@ -15,7 +15,7 @@ "email": "tituspijean@outlook.com" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1" }, "multi_instance": true, "services": [ @@ -26,7 +26,7 @@ "arguments": { "install" : [ { - "name": "domain", + "name": "swap", "type": "display_text", "ask": { "en": "The installation will add a 1 GB swap file if your system has less than 1 GB free RAM.", @@ -36,32 +36,16 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Flarum", - "fr": "Choisissez un nom de domaine pour Flarum", - "de": "Wählen einen Domain-Namen für Flarum" - }, - "example": "example.com" - }, + "example": "example.com" { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Flarum", - "fr": "Choisissez un chemin pour Flarum", - "de": "Wählen einen Pfad für Flarum" - }, "example": "/flarum", "default": "/flarum" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose the admin user", - "fr": "Choisissez l’administrateur", - "de": "Wählen einen Administrator" - }, "example": "johndoe" }, { @@ -78,11 +62,6 @@ { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?", - "de": "Ist es eine öffentliche Applikation ?" - }, "help": { "en": "If public, it will be open to all visitors like any forum. If private, only the YunoHost server users can access it.", "fr": "Si public, le forum sera accessible à tous, comme pour tout forum. Si privé, seuls les utilisateurs du serveur YunoHost pourront y accéder." diff --git a/scripts/install b/scripts/install index fcb7dc7..ff73c95 100644 --- a/scripts/install +++ b/scripts/install @@ -58,7 +58,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=project_version --value=$project_version ynh_app_setting_set --app=$app --key=core_version --value=$core_version @@ -136,13 +135,13 @@ ynh_script_progression --message="Installing composer dependencies..." --weight= ynh_exec_warn_less ynh_install_composer --user=$app --phpversion="$phpversion" --workdir="$final_path" # Set Flarum version -ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-lowest --no-update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-lowest --no-update" # Require SSOwat extension -ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" # Update and download dependencies -ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="update" #================================================= # FLARUM POST-INSTALL diff --git a/scripts/upgrade b/scripts/upgrade index a4eceed..53b0ec8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -44,15 +43,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -66,14 +56,15 @@ if [ -z "$final_path" ]; then fi # Cleaning legacy permissions -is_public=$(ynh_app_setting_get --app=$app --key=is_public) skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris) protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris) -# Remove is_public if exists -if [ ! -z "$is_public" ]; then - ynh_app_setting_delete --app=$app --key=is_public +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public fi # Remove skipped_uris if exists @@ -203,13 +194,13 @@ then chown -R $app:www-data $final_path # Install Composer and Flarum - ynh_install_composer --user=$app --phpversion=$phpversion --workdir=$final_path + ynh_exec_warn_less ynh_install_composer --user=$app --phpversion=$phpversion --workdir=$final_path # Perform migrations and clear cache pushd $final_path ynh_script_progression --message="Upgrading Flarum and its extensions..." --weight=1 - ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" - ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies" + ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" + ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies" exec_as $app php$phpversion flarum migrate exec_as $app php$phpversion flarum cache:clear popd @@ -276,19 +267,6 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:www-data $final_path -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. - ynh_permission_update --permission "main" --add "visitors" -fi - #================================================= # RELOAD NGINX #================================================= From 56ec85a82957836045c8bcaf78a56290c932037c Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 00:00:09 +0100 Subject: [PATCH 2/7] Use ynh_add_config --- conf/configuration.yml | 6 +++--- scripts/install | 15 ++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/conf/configuration.yml b/conf/configuration.yml index 6a2432f..44f1c2a 100644 --- a/conf/configuration.yml +++ b/conf/configuration.yml @@ -1,4 +1,4 @@ -baseUrl : "https://__DOMAIN__/__PATH__" +baseUrl : "https://__DOMAIN____PATH__" databaseConfiguration : host : "localhost" database : "__USER__" @@ -8,6 +8,6 @@ adminUser : username : "__ADMIN__" password : "__ADMIN_PWD__" password_confirmation : "__ADMIN_PWD__" - email : "__ADMIN_EML__" + email : "__ADMIN_MAIL__" settings : - forum_title : "__FORUM_TITLE__" + forum_title : "__TITLE__" diff --git a/scripts/install b/scripts/install index ff73c95..a22963d 100644 --- a/scripts/install +++ b/scripts/install @@ -148,19 +148,8 @@ ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --work #================================================= ynh_script_progression --message="Configuring Flarum..." --weight=2 -# Copy the configuration.yml to working directory -finalflarumconf="$final_path/configuration.yml" -cp ../conf/configuration.yml $finalflarumconf - -# Populate configuration.yml -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$finalflarumconf" -ynh_replace_string --match_string="/__PATH__" --replace_string="$path_url" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__ADMIN_PWD__" --replace_string="$admin_pwd" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__ADMIN_EML__" --replace_string="$admin_mail" --target_file="$finalflarumconf" -ynh_replace_string --match_string="__FORUM_TITLE__" --replace_string="$title" --target_file="$finalflarumconf" +# Copy and populate configuration.yml to working directory +ynh_add_config --template="../conf/configuration.yml" --destination="$final_path/configuration.yml" # Execute post-installation pushd $final_path From 21860847ec3c9f52a509c094692b5e58345a2f65 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 07:48:12 +0100 Subject: [PATCH 3/7] Fix broken manifest.json --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index cb7f203..e586b5f 100644 --- a/manifest.json +++ b/manifest.json @@ -37,6 +37,7 @@ "name": "domain", "type": "domain", "example": "example.com" + }, { "name": "path", "type": "path", From 3e35924e65b409efe2886bd0eaf5e64b003bbd80 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 08:16:27 +0100 Subject: [PATCH 4/7] Escape quotes for ynh_exec_warn_less --- scripts/install | 6 +++--- scripts/upgrade | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index a22963d..b597a39 100644 --- a/scripts/install +++ b/scripts/install @@ -135,13 +135,13 @@ ynh_script_progression --message="Installing composer dependencies..." --weight= ynh_exec_warn_less ynh_install_composer --user=$app --phpversion="$phpversion" --workdir="$final_path" # Set Flarum version -ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-lowest --no-update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require flarum/core:$core_version --prefer-lowest --no-update\" # Require SSOwat extension -ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update\" # Update and download dependencies -ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="update" +ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"update\" #================================================= # FLARUM POST-INSTALL diff --git a/scripts/upgrade b/scripts/upgrade index 53b0ec8..2c87852 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -199,8 +199,8 @@ then # Perform migrations and clear cache pushd $final_path ynh_script_progression --message="Upgrading Flarum and its extensions..." --weight=1 - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update" - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies" + ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update\" + ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies\" exec_as $app php$phpversion flarum migrate exec_as $app php$phpversion flarum cache:clear popd From 91342f4ac236130228a4cdd7f021a357ebe049ce Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 08:43:37 +0100 Subject: [PATCH 5/7] Fix configuration file removal --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b597a39..34714ff 100644 --- a/scripts/install +++ b/scripts/install @@ -155,7 +155,7 @@ ynh_add_config --template="../conf/configuration.yml" --destination="$final_path pushd $final_path exec_as $app php$phpversion -d $final_path -d memory_limit=-1 flarum install -f configuration.yml # Delete configuration.yml as it contains sensitive data - ynh_secure_remove $finalflarumconf + ynh_secure_remove --file="$final_path/configuration.yml" popd # Email setup From f352bc53c9d2921a8d578db82ad2447978b8bac0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 12:45:33 +0100 Subject: [PATCH 6/7] Bump requirement to YunoHost 4.1.2 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index e586b5f..f7c0a08 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "email": "tituspijean@outlook.com" }, "requirements": { - "yunohost": ">= 4.1" + "yunohost": ">= 4.1.2" }, "multi_instance": true, "services": [ From 13e6fb2d211663cf136d113a2529fb3c148ee108 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 19 Mar 2021 12:49:06 +0100 Subject: [PATCH 7/7] Remove old permissions... removal --- scripts/upgrade | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2c87852..f9262c2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,11 +55,6 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -# Cleaning legacy permissions -skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) -unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris) -protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris) - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -67,21 +62,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -# Remove skipped_uris if exists -if [ ! -z "$skipped_uris" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris -fi - -# Remove unprotected_uris if exists -if [ ! -z "$unprotected_uris" ]; then - ynh_app_setting_delete --app=$app --key=unprotected_uris -fi - -# Remove protected_uris if exists -if [ ! -z "$protected_uris" ]; then - ynh_app_setting_delete --app=$app --key=protected_uris -fi - # Remove the v before version number if [[ $old_project_version == "v*" ]]; then $old_project_version = ${old_project_version:1}; fi