mirror of
https://github.com/YunoHost-Apps/phpinfo_ynh.git
synced 2024-09-03 19:56:23 +02:00
40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Create a dedicated php-fpm config
|
|
#
|
|
# usage: ynh_add_fpm_config [--phpversion=7.X]
|
|
# | arg: -v, --phpversion - Version of php to use.
|
|
ynh_add_fpm_config () {
|
|
# Declare an array to define the options of this helper.
|
|
local legacy_args=v
|
|
declare -Ar args_array=( [v]=phpversion= )
|
|
local phpversion
|
|
# Manage arguments with getopts
|
|
ynh_handle_getopts_args "$@"
|
|
phpversion="${phpversion:-7.0}"
|
|
|
|
local fpm_config_dir="/etc/php/$phpversion/fpm"
|
|
local fpm_service="php${phpversion}-fpm"
|
|
ynh_app_setting_set $app fpm_config_dir "$fpm_config_dir"
|
|
ynh_app_setting_set $app fpm_service "$fpm_service"
|
|
finalphpconf="$fpm_config_dir/pool.d/$app.conf"
|
|
ynh_backup_if_checksum_is_different "$finalphpconf"
|
|
sudo cp ../conf/php-fpm.conf "$finalphpconf"
|
|
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
|
|
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
|
|
ynh_replace_string "__USER__" "$app" "$finalphpconf"
|
|
ynh_replace_string "__PHPVERSION__" "$phpversion" "$finalphpconf"
|
|
sudo chown root: "$finalphpconf"
|
|
ynh_store_file_checksum "$finalphpconf"
|
|
|
|
if [ -e "../conf/php-fpm.ini" ]
|
|
then
|
|
echo "Packagers ! Please do not use a separate php ini file, merge your directives in the pool file instead." >&2
|
|
finalphpini="$fpm_config_dir/conf.d/20-$app.ini"
|
|
ynh_backup_if_checksum_is_different "$finalphpini"
|
|
sudo cp ../conf/php-fpm.ini "$finalphpini"
|
|
sudo chown root: "$finalphpini"
|
|
ynh_store_file_checksum "$finalphpini"
|
|
fi
|
|
sudo systemctl reload $fpm_service
|
|
}
|