Upstream: https://github.com/YunoHost/yunohost @ 3a5f8bac8301c450897b96cbd43a4c7d3ba750fb But (José) : transformer tout le code en bions + ploxions du xerboxion. La carte de digestion vit au labo : /yunohost-digest.json
83 lines
2.9 KiB
Bash
83 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2024 YunoHost Contributors
|
|
#
|
|
# This file is part of YunoHost (see https://yunohost.org)
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
# Create a dedicated nginx config
|
|
#
|
|
# usage: ynh_config_add_nginx
|
|
#
|
|
# This will use a template in `../conf/nginx.conf`
|
|
# See the documentation of `ynh_config_add` for a description of the template
|
|
# format and how placeholders are replaced with actual variables.
|
|
#
|
|
# Additionally, ynh_config_add_nginx will replace:
|
|
#
|
|
# - `#sub_path_only` by empty string if `path` is not `'/'`
|
|
# - `#root_path_only` by empty string if `path` *is* `'/'`
|
|
#
|
|
# This allows to enable/disable specific behaviors dependenging on the install
|
|
# location
|
|
ynh_config_add_nginx() {
|
|
|
|
local finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_config_add --template="nginx.conf" --destination="$finalnginxconf"
|
|
|
|
if [ "${path:-}" != "/" ]; then
|
|
ynh_replace --match="^#sub_path_only" --replace="" --file="$finalnginxconf"
|
|
else
|
|
ynh_replace --match="^#root_path_only" --replace="" --file="$finalnginxconf"
|
|
fi
|
|
|
|
# Delete REMOTE_USER mapping, it's already provided by
|
|
# /etc/nginx/fastcgi_params which all PHP apps include, and maps to the
|
|
# appropriate YNH_USER HTTP header instead of $remote_user
|
|
sed -i '/fastcgi_param\s*REMOTE_USER/d' "$finalnginxconf"
|
|
|
|
ynh_store_file_checksum "$finalnginxconf"
|
|
|
|
ynh_systemctl --service=nginx --action=reload
|
|
}
|
|
|
|
# Remove the dedicated nginx config
|
|
#
|
|
# usage: ynh_config_remove_nginx
|
|
ynh_config_remove_nginx() {
|
|
ynh_safe_rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
ynh_systemctl --service=nginx --action=reload
|
|
}
|
|
|
|
# Regen the nginx config in a change url context
|
|
#
|
|
# usage: ynh_config_change_url_nginx
|
|
ynh_config_change_url_nginx() {
|
|
|
|
# Make a backup of the original NGINX config file if manually modified
|
|
# (nb: this is possibly different from the same instruction called by
|
|
# ynh_config_add inside ynh_config_add_nginx because the path may have
|
|
# changed if we're changing the domain too...)
|
|
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
ynh_backup_if_checksum_is_different "$old_nginx_conf_path"
|
|
ynh_delete_file_checksum "$old_nginx_conf_path"
|
|
ynh_safe_rm "$old_nginx_conf_path"
|
|
|
|
# Regen the nginx conf
|
|
ynh_config_add_nginx
|
|
}
|