From 813533be70caddf29035726ae8a1dd71f5c603f4 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 25 Jan 2022 14:32:24 +0100 Subject: [PATCH 1/7] Add config panel --- config_panel.toml | 25 +++++++++++++ scripts/conf | 95 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 4 +- scripts/remove | 16 ++++---- scripts/restore | 3 ++ scripts/upgrade | 30 ++++++++++++++- 6 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 config_panel.toml create mode 100644 scripts/conf diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..f1be4dc --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,25 @@ +version = "1.0" + +[main] +name = "Plainpad configuration" + + [main.php_fpm_config] + name = "PHP-FPM configuration" + + [main.php_fpm_config.fpm_footprint] + ask = "Memory footprint of the service?" + choices = ["low", "medium", "high", "specific"] + default = "low" + help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.
Use specific to set a value with the following option." + + [main.php_fpm_config.free_footprint] + ask = "Memory footprint of the service?" + type = "number" + default = "0" + help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values." + + [main.php_fpm_config.fpm_usage] + ask = "Expected usage of the service?" + choices = ["low", "medium", "high"] + default = "low" + help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." diff --git a/scripts/conf b/scripts/conf new file mode 100644 index 0000000..3440bd2 --- /dev/null +++ b/scripts/conf @@ -0,0 +1,95 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) + +#================================================= +# SPECIFIC GETTERS FOR TOML SHORT KEY +#================================================= + +get__fpm_footprint() { + # Free footprint value for php-fpm + # Check if current_fpm_footprint is an integer + if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null + then + echo "specific" + else + echo "$current_fpm_footprint" + fi +} + +get__free_footprint() { + # Free footprint value for php-fpm + # Check if current_fpm_footprint is an integer + if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null + then + # If current_fpm_footprint is an integer, that's a numeric value for the footprint + echo "$current_fpm_footprint" + else + echo "0" + fi +} + +#================================================= +# SPECIFIC SETTERS FOR TOML SHORT KEYS +#================================================= + +set__fpm_footprint() { + if [ "$fpm_footprint" != "specific" ] + then + ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint" + fi +} + +set__free_footprint() { + if [ "$fpm_footprint" = "specific" ] + then + ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint" + fi +} + +#================================================= +# GENERIC FINALIZATION +#================================================= + +ynh_app_config_validate() { + _ynh_app_config_validate + + if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then + # If fpm_footprint is set to 'specific', use $free_footprint value. + if [ "$fpm_footprint" = "specific" ] + then + fpm_footprint=$free_footprint + fi + + if [ "$fpm_footprint" == "0" ] + then + ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." + + exit 0 + fi + fi +} + +ynh_app_config_apply() { + _ynh_app_config_apply + + ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint +} + +ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index b73c88b..1e30b91 100755 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC key=$(ynh_string_random --length=32) +phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -103,8 +104,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config --usage=low --footprint=low #================================================= # ADD A CONFIGURATION diff --git a/scripts/remove b/scripts/remove index 2300b9a..f75dd97 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,14 +29,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -61,6 +53,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 6df366c..0709231 100755 --- a/scripts/restore +++ b/scripts/restore @@ -35,6 +35,9 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) + #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 12b0ca6..7bd0986 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,10 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$YNH_PHP_VERSION + +fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION @@ -41,6 +45,30 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# If fpm_footprint doesn't exist, create it +if [ -z "$fpm_footprint" ]; then + fpm_footprint=low + ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint +fi + +# If fpm_usage doesn't exist, create it +if [ -z "$fpm_usage" ]; then + fpm_usage=low + ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +fi + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -86,7 +114,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint #================================================= # GENERIC FINALIZATION From c6ba0b55a79f782687f32c83bd9683191cb116cd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 25 Jan 2022 14:35:59 +0100 Subject: [PATCH 2/7] Update conf --- scripts/conf | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/scripts/conf b/scripts/conf index 3440bd2..284d78e 100644 --- a/scripts/conf +++ b/scripts/conf @@ -67,29 +67,4 @@ set__free_footprint() { # GENERIC FINALIZATION #================================================= -ynh_app_config_validate() { - _ynh_app_config_validate - - if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then - # If fpm_footprint is set to 'specific', use $free_footprint value. - if [ "$fpm_footprint" = "specific" ] - then - fpm_footprint=$free_footprint - fi - - if [ "$fpm_footprint" == "0" ] - then - ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." - - exit 0 - fi - fi -} - -ynh_app_config_apply() { - _ynh_app_config_apply - - ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -} - ynh_app_config_run $1 From 9892bb3c68003e4f24a2cd18cdabbf3a226a0749 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 25 Jan 2022 14:37:21 +0100 Subject: [PATCH 3/7] Update manifest.json --- manifest.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.json b/manifest.json index 919e288..99c31da 100644 --- a/manifest.json +++ b/manifest.json @@ -44,6 +44,10 @@ { "name": "is_public", "type": "boolean", + "help": { + "en": "If enabled, Plainpad will be accessible by people who do not have an account. This can be changed later via the webadmin.", + "fr": "Si cette case est cochée, Plainpad sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + }, "default": true } ] From 24d85324a6369cbd358793b53f80ca4d0f6350a6 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 25 Jan 2022 14:38:37 +0100 Subject: [PATCH 4/7] Create DESCRIPTION_fr.md --- doc/DESCRIPTION_fr.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/DESCRIPTION_fr.md diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..820d2ac --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1,2 @@ +Plainpad est une application de prise de notes open source auto-hébergée qui est très facile à configurer sur votre serveur. Vos données ne quitteront jamais votre serveur et vous pourrez y accéder depuis n'importe quel appareil connecté à Internet. +Avec Plainpad, vous pouvez autoriser plusieurs utilisateurs à accéder à l'application sans pouvoir voir les notes des autres. Les notes sont cryptées et stockées en toute sécurité dans la base de données. \ No newline at end of file From 783163a4f206c80a44288a6203f1a7b50ef6e32c Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Tue, 25 Jan 2022 13:38:49 +0000 Subject: [PATCH 5/7] Auto-update README --- README_fr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_fr.md b/README_fr.md index bd5d59f..9d5d90b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,8 +11,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Plainpad is a self hosted, open source note taking application that is very easy to setup on your server. Your data will never leave your server and you will be able to access them from any device connected to the internet. -With Plainpad you can allow multiple users to access the application without being able to see each other's notes. The notes are being encrypted and stored safely in the database. +Plainpad est une application de prise de notes open source auto-hébergée qui est très facile à configurer sur votre serveur. Vos données ne quitteront jamais votre serveur et vous pourrez y accéder depuis n'importe quel appareil connecté à Internet. +Avec Plainpad, vous pouvez autoriser plusieurs utilisateurs à accéder à l'application sans pouvoir voir les notes des autres. Les notes sont cryptées et stockées en toute sécurité dans la base de données. **Version incluse :** 1.0.0~ynh1 From 9ceb82a037544514c119a0a643d7bcd86a6e6b62 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 5 Apr 2022 11:52:09 +0200 Subject: [PATCH 6/7] Update conf --- scripts/conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/conf b/scripts/conf index 284d78e..d4a2d47 100644 --- a/scripts/conf +++ b/scripts/conf @@ -57,7 +57,7 @@ set__fpm_footprint() { } set__free_footprint() { - if [ "$fpm_footprint" = "specific" ] + if [ "$fpm_footprint" == "specific" ] then ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint" fi From ccfca27e95edc78c0e93b7ec4642d8a7e122f971 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 5 Apr 2022 12:00:35 +0200 Subject: [PATCH 7/7] Update upgrade --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 7bd0986..6ef09b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,6 +69,11 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +# Create a permission if needed +if ! ynh_permission_exists --permission="api"; then + ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" +fi + #================================================= # CREATE DEDICATED USER #=================================================