mirror of
https://github.com/YunoHost-Apps/grav_ynh.git
synced 2024-09-03 19:16:01 +02:00
Fuck the stupid broken PHP-FPM config, to be standardized and integrated in the core
This commit is contained in:
parent
e1e7ea0289
commit
27a8a16e08
4 changed files with 4 additions and 123 deletions
|
@ -17,29 +17,3 @@ name = "Grav configuration"
|
||||||
optional = true
|
optional = true
|
||||||
visible = "with_sftp"
|
visible = "with_sftp"
|
||||||
help = "If a password already exists, leave blank and it will not be replaced."
|
help = "If a password already exists, leave blank and it will not be replaced."
|
||||||
|
|
||||||
[main.php_fpm_config]
|
|
||||||
name = "PHP-FPM configuration"
|
|
||||||
|
|
||||||
[main.php_fpm_config.fpm_footprint]
|
|
||||||
ask = "Memory footprint"
|
|
||||||
type = "select"
|
|
||||||
choices.low = "Low, <= 20Mb per pool"
|
|
||||||
choices.medium = "Medium, between 20Mb and 40Mb per pool"
|
|
||||||
choices.high = "High, > 40Mb per pool"
|
|
||||||
choices.specific = "Use specific value"
|
|
||||||
default = "low"
|
|
||||||
|
|
||||||
[main.php_fpm_config.fpm_free_footprint]
|
|
||||||
visible = "fpm_footprint == 'specific'"
|
|
||||||
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"
|
|
||||||
type = "select"
|
|
||||||
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.<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."
|
|
||||||
|
|
|
@ -1,55 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
||||||
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 VALIDATORS FOR TOML SHORT KEYS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -61,20 +16,6 @@ set__password() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set__fpm_footprint() {
|
|
||||||
if [ "$fpm_footprint" != "specific" ]
|
|
||||||
then
|
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set__fpm_free_footprint() {
|
|
||||||
if [ "$fpm_footprint" = "specific" ]
|
|
||||||
then
|
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_free_footprint"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,20 +27,6 @@ ynh_app_config_validate() {
|
||||||
then
|
then
|
||||||
ynh_die --message="You need to set a password to enable SSH and SFTP"
|
ynh_die --message="You need to set a password to enable SSH and SFTP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then
|
|
||||||
# If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
|
|
||||||
if [ "$fpm_footprint" = "specific" ]
|
|
||||||
then
|
|
||||||
fpm_footprint=$fpm_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() {
|
||||||
|
@ -119,8 +46,6 @@ ynh_app_config_apply() {
|
||||||
ynh_system_user_del_group --username=$app --groups="sftp.app ssh.app"
|
ynh_system_user_del_group --username=$app --groups="sftp.app ssh.app"
|
||||||
usermod --shel /usr/sbin/nologin $app
|
usermod --shel /usr/sbin/nologin $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_app_config_run $1
|
ynh_app_config_run $1
|
||||||
|
|
|
@ -12,9 +12,6 @@ source /usr/share/yunohost/helpers
|
||||||
# Initialize the SFTP setting for the config panel
|
# Initialize the SFTP setting for the config panel
|
||||||
ynh_app_setting_set --app=$app --key=with_sftp --value="false"
|
ynh_app_setting_set --app=$app --key=with_sftp --value="false"
|
||||||
ynh_app_setting_set --app=$app --key=password --value=$(ynh_string_random)
|
ynh_app_setting_set --app=$app --key=password --value=$(ynh_string_random)
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="medium"
|
|
||||||
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value="0"
|
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value="medium"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -38,7 +35,9 @@ find "$install_dir" -type d -exec chmod +s {} \;
|
||||||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=3
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=3
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM config
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config --usage=medium --footprint=medium
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value="medium"
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_usage --value="medium"
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
|
|
@ -23,29 +23,12 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# If fpm_footprint doesn't exist, create it
|
|
||||||
if [ -z "${fpm_footprint:-}" ]; then
|
|
||||||
fpm_footprint=medium
|
|
||||||
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=medium
|
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If with_sftp or password don't exist, create them
|
# If with_sftp or password don't exist, create them
|
||||||
if [ -z "${with_sftp:-}" ] || [ -z "${password:-}" ]; then
|
if [ -z "${with_sftp:-}" ] || [ -z "${password:-}" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=with_sftp --value="false"
|
ynh_app_setting_set --app=$app --key=with_sftp --value="false"
|
||||||
ynh_app_setting_set --app=$app --key=password --value=$(ynh_string_random)
|
ynh_app_setting_set --app=$app --key=password --value=$(ynh_string_random)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete existing ini configuration file (backward compatibility)
|
|
||||||
if [ -f /etc/php/$phpversion/fpm/conf.d/20-$app.ini ]; then
|
|
||||||
ynh_secure_remove --file=/etc/php/$phpversion/fpm/conf.d/20-$app.ini
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -72,7 +55,7 @@ find "$install_dir" -type d -exec chmod +s {} \;
|
||||||
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM config
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
ynh_add_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
|
Loading…
Reference in a new issue