From ffad7ee21b0ff339e1deba47fbf5d7342bc63e12 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 29 Mar 2020 13:41:07 +0200 Subject: [PATCH 01/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bbca77..d5ba494 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hextris app for YunoHost -[![Integration level](https://dash.yunohost.org/integration/hextris.svg)](https://dash.yunohost.org/appci/app/hextris) +[![Integration level](https://dash.yunohost.org/integration/hextris.svg)](https://dash.yunohost.org/appci/app/hextris) ![](https://ci-apps.yunohost.org/ci/badges/hextris.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/hextris.maintain.svg) [![Install Hextris with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=hextris) > *This package allow you to install Hextris quickly and simply on a YunoHost server. From adcca2c3efb2592171d78197c9629aeb773413b4 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 00:11:51 +0200 Subject: [PATCH 02/25] New permission system in install script --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 4c373f2..f9c8d95 100755 --- a/scripts/install +++ b/scripts/install @@ -82,8 +82,7 @@ ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=skipped_uris --value="/" + ynh_permission_update --permission "main" --add visitors fi #================================================= From a08b2dcbde468d235f2b189d14587d1fbb29746e Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 00:15:25 +0200 Subject: [PATCH 03/25] Remove old permissions system in upgrade --- scripts/upgrade | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 08d2411..c1c86d2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,13 +103,6 @@ chown -R root: $final_path #================================================= ynh_script_progression --message="Upgrading SSOwat configuration..." -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=skipped_uris --value="/" -fi - #================================================= # RELOAD NGINX #================================================= From 9be9d70a68965d4403117c0a69c1372e7900fda5 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 00:16:30 +0200 Subject: [PATCH 04/25] Remove is_public in upgrade --- scripts/upgrade | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c1c86d2..51886ff 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,7 +17,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) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -31,15 +30,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# 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 final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app From cda3f9cba9b1624f60a3eae73d90c4accbbc0de3 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 00:17:45 +0200 Subject: [PATCH 05/25] Change requirements --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 5fc6261..58ae05f 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "opi@zeropi.net" }, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.7.0" }, "multi_instance": true, "services": [ From 21abcad4fa1ea0dcd545bf78fe411aab0f465f37 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 11:27:11 +0200 Subject: [PATCH 06/25] Remove skipped_uris if it exists when upgrading --- scripts/upgrade | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 51886ff..df8ad30 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,6 +30,14 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +# REMOVE SKIPPED_URIS +skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) + +# Unused with the permission system +if [ ! -z "$skipped_uris" ]; then + ynh_app_setting_delete --app=$app --key=skipped_uris +fi + # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app From 7f25eda031ef8ff95c472fe019c2bca271c39194 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 13:00:23 +0200 Subject: [PATCH 07/25] Cleaning legacy permission in upgrade --- scripts/upgrade | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index df8ad30..e1307f5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,12 +30,30 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# REMOVE SKIPPED_URIS +# 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) -# Unused with the permission system +# Remove is_public if exists +if [ ! -z "$is_public" ]; 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 + 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 # If final_path doesn't exist, create it From 845149815c9cbf004948ed51d9f5730ffef50c22 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 14:00:17 +0200 Subject: [PATCH 08/25] Desperately trying to debug upgrade... --- scripts/upgrade | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e1307f5..cab2f09 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -23,12 +23,24 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # CHECK VERSION #================================================= +### 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) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi # Cleaning legacy permissions is_public=$(ynh_app_setting_get --app=$app --key=is_public) @@ -56,16 +68,10 @@ if [ ! -z "$protected_uris" ]; then ynh_app_setting_delete --app=$app --key=protected_uris fi -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=5 # Backup the current version of the app ynh_backup_before_upgrade @@ -100,7 +106,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -114,15 +120,10 @@ ynh_add_nginx_config # Set permissions to app files chown -R root: $final_path -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -130,4 +131,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --time --last From ae29f28b73015018ecb3cf632d45635b6f06e9ed Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 14:17:05 +0200 Subject: [PATCH 09/25] Remove all these useless '--time' arguments --- scripts/upgrade | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index cab2f09..53b9ae6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -34,7 +34,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If final_path doesn't exist, create it if [ -z "$final_path" ]; then @@ -71,7 +71,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=5 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5 # Backup the current version of the app ynh_backup_before_upgrade @@ -106,7 +106,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=2 +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -123,7 +123,7 @@ chown -R root: $final_path #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -131,4 +131,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last From 0d654c2e001a8c91f912f31e8652187fd35dada0 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 14:49:05 +0200 Subject: [PATCH 10/25] Quick and dirty workaround --- scripts/upgrade | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 53b9ae6..0f720b9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,11 +48,6 @@ 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 -fi - # Remove skipped_uris if exists if [ ! -z "$skipped_uris" ]; then ynh_app_setting_delete --app=$app --key=skipped_uris @@ -68,6 +63,16 @@ if [ ! -z "$protected_uris" ]; then ynh_app_setting_delete --app=$app --key=protected_uris fi +# Remove is_public if exists +if [ ! -z $is_public ]; then + if [ "$is_public" = "1" ]; then + ynh_permission_update --permission "main" --add "visitors" + show_warning="1" + fi + ynh_app_setting_delete --app=$app --key=is_public +fi + + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -131,4 +136,10 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= +if [ ! -z $show_warning ]; then + if [ "$show_warning" = "1" ]; then + ynh_print_warn --message="Due to the fact that Yunohost resets permissions when upgrading a package from the old permissions system to the new one, we had to define your instance of Hextris as public. If you want to make it private, you can do it via webmin." + fi +fi + ynh_script_progression --message="Upgrade of $app completed" --last From 05d13f99bce260655c2b188b7763e96c792b7a7d Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 14:57:50 +0200 Subject: [PATCH 11/25] Debug --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 0f720b9..96c1c3c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,6 +68,8 @@ if [ ! -z $is_public ]; then if [ "$is_public" = "1" ]; then ynh_permission_update --permission "main" --add "visitors" show_warning="1" + else + show_warning="0" fi ynh_app_setting_delete --app=$app --key=is_public fi From 2463f25c8cd0b7a0cb74717dc7f64745a066406e Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 16:17:33 +0200 Subject: [PATCH 12/25] =?UTF-8?q?Some=20corrections=20(Thanks=20Maniack=20?= =?UTF-8?q?=F0=9F=98=89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/upgrade | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 96c1c3c..e0d8084 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,23 +49,18 @@ unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris) protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris) # Remove skipped_uris if exists -if [ ! -z "$skipped_uris" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris -fi +# /!\ This commands also remove the "main" permission from "visitor" groups, that's why I made the trick with is_public and the warn at the end. +ynh_app_setting_delete --app=$app --key=skipped_uris # Remove unprotected_uris if exists -if [ ! -z "$unprotected_uris" ]; then - ynh_app_setting_delete --app=$app --key=unprotected_uris -fi +ynh_app_setting_delete --app=$app --key=unprotected_uris # Remove protected_uris if exists -if [ ! -z "$protected_uris" ]; then - ynh_app_setting_delete --app=$app --key=protected_uris -fi +ynh_app_setting_delete --app=$app --key=protected_uris -# Remove is_public if exists -if [ ! -z $is_public ]; then - if [ "$is_public" = "1" ]; then +# Remove is_public if exists and trick about what I said 8 lines before. +if [ -n "$is_public" ]; then + if [ $is_public -eq 1 ]; then ynh_permission_update --permission "main" --add "visitors" show_warning="1" else @@ -138,8 +133,8 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -if [ ! -z $show_warning ]; then - if [ "$show_warning" = "1" ]; then +if [ -n "$show_warning" ]; then + if [ $show_warning -eq 1 ]; then ynh_print_warn --message="Due to the fact that Yunohost resets permissions when upgrading a package from the old permissions system to the new one, we had to define your instance of Hextris as public. If you want to make it private, you can do it via webmin." fi fi From 8b5b77ce424a2d0d6f92e5b54eac2c97c1415559 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 16:38:32 +0200 Subject: [PATCH 13/25] Changed warn message Changed warn message to something more ~~complicated complex~~ comprehensive. --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index e0d8084..a440e8e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -135,7 +135,7 @@ ynh_systemd_action --service_name=nginx --action=reload if [ -n "$show_warning" ]; then if [ $show_warning -eq 1 ]; then - ynh_print_warn --message="Due to the fact that Yunohost resets permissions when upgrading a package from the old permissions system to the new one, we had to define your instance of Hextris as public. If you want to make it private, you can do it via webmin." + ynh_print_warn --message="In order to make this package compatible with Yunohost's new permission management system, we had to revert back any change to package's permissions made since the 3.7.0 release. If you edited permissions of this package between Yunohost 3.7.0 upgrade and this upgrade these changes have been discarded and will need to be made again. If you do not have made any modifications to permissions of this package since Yunohost 3.7.0 release, forget about that. We are sorry for that, this will only happen once." fi fi From de22d8ed0e7cd6d3d16ba18bcb5d5e6b3db387be Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 17:53:50 +0200 Subject: [PATCH 14/25] Changed permission migration process --- scripts/upgrade | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a440e8e..0323229 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,14 +42,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path 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) + +### +### MIGRATE FROM LEGACY PERMISSION SYSTEM +### # Remove skipped_uris if exists -# /!\ This commands also remove the "main" permission from "visitor" groups, that's why I made the trick with is_public and the warn at the end. +# /!\ This commands also remove the "main" permission from "visitor" groups. ynh_app_setting_delete --app=$app --key=skipped_uris # Remove unprotected_uris if exists @@ -62,14 +61,12 @@ ynh_app_setting_delete --app=$app --key=protected_uris if [ -n "$is_public" ]; then if [ $is_public -eq 1 ]; then ynh_permission_update --permission "main" --add "visitors" - show_warning="1" - else - show_warning="0" - fi + fi ynh_app_setting_delete --app=$app --key=is_public fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -133,10 +130,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -if [ -n "$show_warning" ]; then - if [ $show_warning -eq 1 ]; then - ynh_print_warn --message="In order to make this package compatible with Yunohost's new permission management system, we had to revert back any change to package's permissions made since the 3.7.0 release. If you edited permissions of this package between Yunohost 3.7.0 upgrade and this upgrade these changes have been discarded and will need to be made again. If you do not have made any modifications to permissions of this package since Yunohost 3.7.0 release, forget about that. We are sorry for that, this will only happen once." - fi -fi - ynh_script_progression --message="Upgrade of $app completed" --last From 6ca812d7e8e8c4f15923d15b7d8794641e208dcc Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 19:13:21 +0200 Subject: [PATCH 15/25] Update upgrade --- scripts/upgrade | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0323229..1e12be0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,12 +23,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # CHECK VERSION #================================================= -### 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) #================================================= @@ -47,18 +41,8 @@ fi ### MIGRATE FROM LEGACY PERMISSION SYSTEM ### -# Remove skipped_uris if exists -# /!\ This commands also remove the "main" permission from "visitor" groups. -ynh_app_setting_delete --app=$app --key=skipped_uris - -# Remove unprotected_uris if exists -ynh_app_setting_delete --app=$app --key=unprotected_uris - -# Remove protected_uris if exists -ynh_app_setting_delete --app=$app --key=protected_uris - -# Remove is_public if exists and trick about what I said 8 lines before. if [ -n "$is_public" ]; then + ynh_app_setting_delete --app=$app --key=skipped_uris if [ $is_public -eq 1 ]; then ynh_permission_update --permission "main" --add "visitors" fi @@ -66,7 +50,6 @@ if [ -n "$is_public" ]; then fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From fc006236360882ca3e05fa4d97311bc78bc9e5c9 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 19:36:04 +0200 Subject: [PATCH 16/25] Update upgrade --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 1e12be0..5342cb2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,6 +41,8 @@ fi ### MIGRATE FROM LEGACY PERMISSION SYSTEM ### +is_public=$(ynh_app_setting_get --app=$app --key=is_public) + if [ -n "$is_public" ]; then ynh_app_setting_delete --app=$app --key=skipped_uris if [ $is_public -eq 1 ]; then From 54c84ab0ac4e4d9479cb31d249cee4d4f352a6c4 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 30 Mar 2020 19:56:35 +0200 Subject: [PATCH 17/25] Change a random thing to launch a CI build --- scripts/upgrade | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5342cb2..2dcb016 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,10 +36,7 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi - -### -### MIGRATE FROM LEGACY PERMISSION SYSTEM -### +# Migrate from legacy permission system is_public=$(ynh_app_setting_get --app=$app --key=is_public) From 8e98e49d330132bde1a16fbb990de9e46bf1d3d0 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Tue, 31 Mar 2020 15:39:07 +0200 Subject: [PATCH 18/25] Migration using experimental helper (#14) * Create _common.sh * Use experimental helper in upgrade --- scripts/_common.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 13 ++++++++---- 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 scripts/_common.sh diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..a652bbf --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= + +# Check if a permission exists +# +# While waiting for this new helper https://github.com/YunoHost/yunohost/pull/905 +# We have to use another one because the new helper use a new YunoHost command, not available for now. +# +# usage: ynh_permission_has_user --permission=permission --user=user +# | arg: -p, --permission - the permission to check +# | arg: -u, --user - the user seek in the permission +# +# example: ynh_permission_has_user --permission=main --user=visitors +# +# Requires YunoHost version 3.7.1 or higher. +ynh_permission_has_user() { + local legacy_args=pu + # Declare an array to define the options of this helper. + declare -Ar args_array=( [p]=permission= [u]=user= ) + local permission + local user + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if ! ynh_permission_exists --permission=$permission + then + return 1 + fi + + # List all permissions + # Filter only the required permission with a multiline sed (Here a cut from the permission to the next one), remove the url and his value + perm="$(yunohost user permission list --full --output-as plain | sed --quiet "/^#$app.$permission/,/^#[[:alnum:]]/p" | sed "/^##url/,+1d")" + # Remove all lines starting by # (got from the plain output before) + allowed_users="$(echo "$perm" | grep --invert-match '^#')" + # Grep the list of users an return the result if the user is indeed into the list + echo "$allowed_users" | grep --quiet --word "$user" +} diff --git a/scripts/upgrade b/scripts/upgrade index 2dcb016..23b240d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -37,14 +38,18 @@ if [ -z "$final_path" ]; then fi # Migrate from legacy permission system - is_public=$(ynh_app_setting_get --app=$app --key=is_public) if [ -n "$is_public" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris - if [ $is_public -eq 1 ]; then + # Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 + # Remove skipped_uris. If the app was public, add visitors again to the main permission + if ynh_permission_has_user --permission=main --user=visitors + then + ynh_app_setting_delete --app=$app --key=skipped_uris ynh_permission_update --permission "main" --add "visitors" - fi + else + ynh_app_setting_delete --app=$app --key=skipped_uris + fi ynh_app_setting_delete --app=$app --key=is_public fi From 3425703c2a50e60f0403d739e2d8f2f50d0dda9d Mon Sep 17 00:00:00 2001 From: Aeris One Date: Tue, 31 Mar 2020 16:37:36 +0200 Subject: [PATCH 19/25] Update manifest.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Package_linter told me to add an help key, so I add an help key 😉 --- manifest.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifest.json b/manifest.json index 5fc6261..c039a8d 100644 --- a/manifest.json +++ b/manifest.json @@ -48,6 +48,9 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help": { + "en": "If enabled, Hextris will be accessible by people who doesn't have an account. This can be changed later via the webmin." + "fr": "Si cette case est cochée, Hextris sera accessible aux personnes n'ayant pas de compte. Vous pourrez changer ceci plus tard via le webmin." "default": true } ] From 91cda4a93f7d6076e3096fe735e7a5c3f1b960d6 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 31 Mar 2020 17:16:58 +0200 Subject: [PATCH 20/25] Missing commas --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c039a8d..e9cbc51 100644 --- a/manifest.json +++ b/manifest.json @@ -49,8 +49,9 @@ "fr": "Est-ce une application publique ?" }, "help": { - "en": "If enabled, Hextris will be accessible by people who doesn't have an account. This can be changed later via the webmin." + "en": "If enabled, Hextris will be accessible by people who doesn't have an account. This can be changed later via the webmin.", "fr": "Si cette case est cochée, Hextris sera accessible aux personnes n'ayant pas de compte. Vous pourrez changer ceci plus tard via le webmin." + }, "default": true } ] From 4d1e4bfc65999eff2c5c7426da609c85dedd6489 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 31 Mar 2020 17:37:02 +0200 Subject: [PATCH 21/25] You meant webadmin ? --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index e9cbc51..5e6c586 100644 --- a/manifest.json +++ b/manifest.json @@ -49,8 +49,8 @@ "fr": "Est-ce une application publique ?" }, "help": { - "en": "If enabled, Hextris will be accessible by people who doesn't have an account. This can be changed later via the webmin.", - "fr": "Si cette case est cochée, Hextris sera accessible aux personnes n'ayant pas de compte. Vous pourrez changer ceci plus tard via le webmin." + "en": "If enabled, Hextris will be accessible by people who doesn't have an account. This can be changed later via the webadmin.", + "fr": "Si cette case est cochée, Hextris sera accessible aux personnes n'ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." }, "default": true } From 540e637f7c82142037a14dbf29bf3433a6187716 Mon Sep 17 00:00:00 2001 From: Aeris One Date: Sun, 29 Mar 2020 23:23:19 +0200 Subject: [PATCH 22/25] Update manifest.json --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 5fc6261..6b77907 100644 --- a/manifest.json +++ b/manifest.json @@ -10,8 +10,8 @@ "url": "http://hextris.github.io/", "license": "GPL-3.0", "maintainer": { - "name": "opi", - "email": "opi@zeropi.net" + "name": "AerisOne", + "email": "aeris@e.email" }, "requirements": { "yunohost": ">= 3.5.0" From 44b6d85e98b92a7b47281b19b6592f6e6dff04cf Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 6 Apr 2020 15:26:16 +0200 Subject: [PATCH 23/25] Bump version from 1.1~ynh2 to 1.1~ynh3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index f93d252..3141e59 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A fast paced puzzle game.", "fr": "Un jeu de puzzle très rapide" }, - "version": "1.1~ynh2", + "version": "1.1~ynh3", "url": "http://hextris.github.io/", "license": "GPL-3.0", "maintainer": { From f671a8a5361024ec0087b099b78ec118c017e82c Mon Sep 17 00:00:00 2001 From: Aeris One Date: Mon, 6 Apr 2020 15:32:58 +0200 Subject: [PATCH 24/25] Update pull_request_template.md --- pull_request_template.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index a9a8ac5..3de1420 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -2,7 +2,7 @@ - *Description of why you made this PR* ## Solution -- *And how you fix that* +- *And how you fix that problem* ## PR Status - [ ] Code finished. @@ -13,12 +13,10 @@ ## Validation --- -*Minor decision* -- **Upgrade previous version** : - [ ] **Code review** : -- [ ] **Approval (LGTM)** : -- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +*Code review and approval have to be from a member of @YunoHost-Apps/apps-group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/hextris_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/hextris_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* -When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. +When the PR is marked as ready to merge, we have to wait for 3 days before really merging it. From 9272fb87bd60e01833849f2c06ac573fe8e1ddef Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 6 Apr 2020 15:36:30 +0200 Subject: [PATCH 25/25] Update pull_request_template.md --- pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 3de1420..c6480b1 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,6 +17,6 @@ - [ ] **Approval (LGTM)** : *Code review and approval have to be from a member of @YunoHost-Apps/apps-group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/hextris_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/hextris_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* -When the PR is marked as ready to merge, we have to wait for 3 days before really merging it. +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.