mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
New helpers ynh_add_nginx_config and ynh_remove_nginx_config (#285)
* New helpers ynh_add_nginx_config and ynh_remove_nginx_config Standard configuration of nginx Use local files stored in conf/, so it's still possible to use a specific config * ynh_substitute_char was renamed ynh_replace_string * ynh_compare_checksum_config -> ynh_backup_if_checksum_is_different * Upgrade helpers * Add some description of which keywords are replaced by which variable
This commit is contained in:
parent
bf45cd7c4b
commit
80242a8edc
1 changed files with 48 additions and 0 deletions
|
@ -62,6 +62,54 @@ ynh_remove_logrotate () {
|
|||
fi
|
||||
}
|
||||
|
||||
# Create a dedicated nginx config
|
||||
#
|
||||
# This will use a template in ../conf/nginx.conf
|
||||
# and will replace the following keywords with
|
||||
# global variables that should be defined before calling
|
||||
# this helper :
|
||||
#
|
||||
# __PATH__ by $path_url
|
||||
# __DOMAIN__ by $domain
|
||||
# __PORT__ by $port
|
||||
# __NAME__ by $app
|
||||
# __FINALPATH__ by $final_path
|
||||
#
|
||||
# usage: ynh_add_nginx_config
|
||||
ynh_add_nginx_config () {
|
||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
# Substitute in a nginx config file only if the variable is not empty
|
||||
if test -n "${path_url:-}"; then
|
||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${domain:-}"; then
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${port:-}"; then
|
||||
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${app:-}"; then
|
||||
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
|
||||
fi
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
|
||||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
#
|
||||
# usage: ynh_remove_nginx_config
|
||||
ynh_remove_nginx_config () {
|
||||
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
#
|
||||
# usage: ynh_add_fpm_config
|
||||
|
|
Loading…
Add table
Reference in a new issue