From 17534e2819fa17a781247956f6ca7bee5780daa5 Mon Sep 17 00:00:00 2001
From: Tagadda <36127788+Tagadda@users.noreply.github.com>
Date: Mon, 31 Jan 2022 15:24:14 +0000
Subject: [PATCH] configpanel phpversion
---
config_panel.toml | 17 ++++++++++++++++-
scripts/config | 26 ++++++++++++++------------
2 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/config_panel.toml b/config_panel.toml
index eeeb340..b3955c3 100644
--- a/config_panel.toml
+++ b/config_panel.toml
@@ -21,21 +21,36 @@ name = "My webapp configuration"
[main.php_fpm_config]
name = "PHP-FPM configuration"
+ [main.php_fpm_config.phpversion]
+ ask = "PHP version"
+ choices = ["none", "7.3", "7.4", "8.0"]
+ default = "none"
+
[main.php_fpm_config.fpm_footprint]
ask = "Memory footprint of the service?"
choices = ["low", "medium", "high", "specific"]
default = "low"
+ visible = "! match(phpversion, 'none')"
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"
- visible = "match(fpm_footprint, 'specific')"
+ visible = "match(fpm_footprint, 'specific') && ! match(phpversion, 'none')"
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"
+ visible = "! match(phpversion, 'none')"
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."
+
+# TODO: Add protected_path as tags, which are created as permission "label (path)", so admin can protect a specific path
+# [main.permissions]
+# [main.permissions.proteced_path]
+# ask = "Protected path"
+# help = "A permission will be created so you can restrict the access to a subpath of the web app."
+# type = "tags"
+
\ No newline at end of file
diff --git a/scripts/config b/scripts/config
index 656d5fe..34a6a47 100644
--- a/scripts/config
+++ b/scripts/config
@@ -17,16 +17,6 @@ ynh_abort_if_errors
final_path=$(ynh_app_setting_get $app final_path)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
-
-is_password_exist=0
-current_password=$(ynh_app_setting_get --app=$app --key=password)
-if [ -n "$current_password" ]
-then
- is_password_exist=1
-fi
-
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
@@ -109,13 +99,25 @@ ynh_app_config_validate() {
ynh_app_config_apply() {
_ynh_app_config_apply
- ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
+ # If there's any change to the php config, remove the old one and add a new one if applicable
+ if [ "${changed[phpversion]}" == "true" ] || "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then
+ ynh_remove_fpm_config
+
+ if [[ ! "$phpversion" == "none" ]]; then
+ ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
+ fi
+ fi
+
+ if [[ ! $phpversion == "none" ]]
+ then
+ ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
+ fi
if [ $with_sftp -eq 1 ]
then
ynh_system_user_add_group --username=$app --groups="sftp.app"
- if [ ! $password -eq "" ]
+ if [[ ! $password == "" ]]
then
chpasswd <<< "${app}:${password}"
fi