mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Upgrade config panel
This commit is contained in:
parent
3f3e936ef6
commit
b5c21f0c3d
3 changed files with 63 additions and 59 deletions
|
@ -6,7 +6,7 @@ name = "Nextcloud configuration"
|
||||||
[main.php_fpm_config]
|
[main.php_fpm_config]
|
||||||
name = "PHP-FPM configuration"
|
name = "PHP-FPM configuration"
|
||||||
|
|
||||||
[main.php_fpm_config.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"
|
||||||
|
@ -18,7 +18,7 @@ name = "Nextcloud configuration"
|
||||||
default = "0"
|
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."
|
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.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"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
|
|
115
scripts/config
115
scripts/config
|
@ -9,84 +9,87 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD VALUES
|
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Load the real value from the app config or elsewhere.
|
get__fpm_footprint() {
|
||||||
# Then get the value from the form.
|
# Free footprint value for php-fpm
|
||||||
# If the form has a value for a variable, take the value from the form,
|
# Check if current_fpm_footprint is an integer
|
||||||
# Otherwise, keep the value from the app config.
|
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||||
|
then
|
||||||
|
echo "specific"
|
||||||
|
else
|
||||||
|
echo "$current_fpm_footprint"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Footprint for php-fpm
|
get__free_footprint() {
|
||||||
old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)"
|
# Free footprint value for php-fpm
|
||||||
fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}"
|
# Check if current_fpm_footprint is an integer
|
||||||
|
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||||
# Free footprint value for php-fpm
|
then
|
||||||
# Check if fpm_footprint is an integer
|
# If current_fpm_footprint is an integer, that's a numeric value for the footprint
|
||||||
if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null
|
echo "$current_fpm_footprint"
|
||||||
then
|
else
|
||||||
# If fpm_footprint is an integer, that's a numeric value for the footprint
|
echo "0"
|
||||||
old_free_footprint=$fpm_footprint
|
fi
|
||||||
fpm_footprint=specific
|
|
||||||
else
|
|
||||||
old_free_footprint=0
|
|
||||||
fi
|
|
||||||
free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}"
|
|
||||||
|
|
||||||
# Usage for php-fpm
|
|
||||||
old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)"
|
|
||||||
fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
show_config() {
|
|
||||||
# here you are supposed to read some config file/database/other then print the values
|
|
||||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY THE CONFIGURATION
|
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
apply_config() {
|
set__fpm_footprint() {
|
||||||
|
if [ "$fpm_footprint" != "specific" ]
|
||||||
#=================================================
|
|
||||||
# RECONFIGURE PHP-FPM
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] || [ "$free_footprint" != "$old_free_footprint" ]
|
|
||||||
then
|
then
|
||||||
# If fpm_footprint is set to 'specific', use $free_footprint value.
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set__free_footprint() {
|
||||||
if [ "$fpm_footprint" = "specific" ]
|
if [ "$fpm_footprint" = "specific" ]
|
||||||
then
|
then
|
||||||
fpm_footprint=$free_footprint
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$fpm_footprint" != "0" ]
|
|
||||||
then
|
|
||||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies"
|
|
||||||
else
|
|
||||||
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# 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
|
ynh_app_config_run $1
|
||||||
|
|
Loading…
Add table
Reference in a new issue