1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00

configpanel phpversion

This commit is contained in:
Tagadda 2022-01-31 15:24:14 +00:00
parent 071d38bfb1
commit 17534e2819
2 changed files with 30 additions and 13 deletions

View file

@ -21,21 +21,36 @@ name = "My webapp configuration"
[main.php_fpm_config] [main.php_fpm_config]
name = "PHP-FPM configuration" 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] [main.php_fpm_config.fpm_footprint]
ask = "Memory footprint of the service?" ask = "Memory footprint of the service?"
choices = ["low", "medium", "high", "specific"] choices = ["low", "medium", "high", "specific"]
default = "low" default = "low"
visible = "! match(phpversion, 'none')"
help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option." help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option."
[main.php_fpm_config.free_footprint] [main.php_fpm_config.free_footprint]
ask = "Memory footprint of the service?" ask = "Memory footprint of the service?"
type = "number" type = "number"
default = "0" 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." 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] [main.php_fpm_config.fpm_usage]
ask = "Expected usage of the service?" ask = "Expected usage of the service?"
choices = ["low", "medium", "high"] choices = ["low", "medium", "high"]
default = "low" 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.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." 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.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>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"

View file

@ -17,16 +17,6 @@ ynh_abort_if_errors
final_path=$(ynh_app_setting_get $app final_path) 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 # SPECIFIC GETTERS FOR TOML SHORT KEY
#================================================= #=================================================
@ -109,13 +99,25 @@ ynh_app_config_validate() {
ynh_app_config_apply() { ynh_app_config_apply() {
_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 ] if [ $with_sftp -eq 1 ]
then then
ynh_system_user_add_group --username=$app --groups="sftp.app" ynh_system_user_add_group --username=$app --groups="sftp.app"
if [ ! $password -eq "" ] if [[ ! $password == "" ]]
then then
chpasswd <<< "${app}:${password}" chpasswd <<< "${app}:${password}"
fi fi