mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
regenconf: factorize nginx regenconf a bit
This commit is contained in:
parent
ce529107be
commit
ceace620da
1 changed files with 22 additions and 33 deletions
|
@ -4,13 +4,10 @@ set -e
|
||||||
|
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
do_base_regen() {
|
||||||
|
|
||||||
|
pending_dir=$1
|
||||||
do_init_regen() {
|
nginx_dir="${pending_dir}/etc/nginx"
|
||||||
|
|
||||||
cd /usr/share/yunohost/conf/nginx
|
|
||||||
|
|
||||||
nginx_dir="/etc/nginx"
|
|
||||||
nginx_conf_dir="${nginx_dir}/conf.d"
|
nginx_conf_dir="${nginx_dir}/conf.d"
|
||||||
mkdir -p "$nginx_conf_dir"
|
mkdir -p "$nginx_conf_dir"
|
||||||
|
|
||||||
|
@ -21,11 +18,6 @@ do_init_regen() {
|
||||||
cp yunohost_http_errors.conf.inc "$nginx_conf_dir"
|
cp yunohost_http_errors.conf.inc "$nginx_conf_dir"
|
||||||
cp yunohost_sso.conf.inc "$nginx_conf_dir"
|
cp yunohost_sso.conf.inc "$nginx_conf_dir"
|
||||||
|
|
||||||
|
|
||||||
# probably run with init: just disable default site, restart NGINX and exit
|
|
||||||
rm -f "${nginx_dir}/sites-enabled/default"
|
|
||||||
|
|
||||||
export compatibility="intermediate"
|
|
||||||
ynh_render_template "security.conf.inc" "${nginx_conf_dir}/security.conf.inc"
|
ynh_render_template "security.conf.inc" "${nginx_conf_dir}/security.conf.inc"
|
||||||
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
||||||
ynh_render_template "yunohost_admin.conf.inc" "${nginx_conf_dir}/yunohost_admin.conf.inc"
|
ynh_render_template "yunohost_admin.conf.inc" "${nginx_conf_dir}/yunohost_admin.conf.inc"
|
||||||
|
@ -33,6 +25,17 @@ do_init_regen() {
|
||||||
|
|
||||||
mkdir -p $nginx_conf_dir/default.d/
|
mkdir -p $nginx_conf_dir/default.d/
|
||||||
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
||||||
|
}
|
||||||
|
|
||||||
|
do_init_regen() {
|
||||||
|
|
||||||
|
cd /usr/share/yunohost/conf/nginx
|
||||||
|
|
||||||
|
export compatibility="intermediate"
|
||||||
|
do_base_regen ""
|
||||||
|
|
||||||
|
# probably run with init: just disable default site, restart NGINX and exit
|
||||||
|
rm -f "${nginx_dir}/sites-enabled/default"
|
||||||
|
|
||||||
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
||||||
nginx -t 2>/dev/null || {
|
nginx -t 2>/dev/null || {
|
||||||
|
@ -56,24 +59,17 @@ do_pre_regen() {
|
||||||
nginx_conf_dir="${nginx_dir}/conf.d"
|
nginx_conf_dir="${nginx_dir}/conf.d"
|
||||||
mkdir -p "$nginx_conf_dir"
|
mkdir -p "$nginx_conf_dir"
|
||||||
|
|
||||||
# install / update plain conf files
|
export webadmin_allowlist_enabled="$(jq -r '.webadmin_allowlist_enabled' <<< "$YNH_SETTINGS" | int_to_bool)"
|
||||||
cp acme-challenge.conf.in "$nginx_conf_dir"
|
if [ "$webadmin_allowlist_enabled" == "True" ]; then
|
||||||
cp global.conf "$nginx_conf_dir"
|
export webadmin_allowlist="$(jq -r '.webadmin_allowlist' <<< "$YNH_SETTINGS" | sed 's/^null$//g')"
|
||||||
cp ssowat.conf "$nginx_conf_dir"
|
fi
|
||||||
cp yunohost_http_errors.conf.inc "$nginx_conf_dir"
|
|
||||||
cp yunohost_sso.conf.inc "$nginx_conf_dir"
|
|
||||||
|
|
||||||
# Legacy file to remove
|
|
||||||
touch "$nginx_conf_dir"/yunohost_panel.conf.inc
|
|
||||||
|
|
||||||
# retrieve variables
|
|
||||||
main_domain=$(cat /etc/yunohost/current_host)
|
|
||||||
|
|
||||||
# Support different strategy for security configurations
|
# Support different strategy for security configurations
|
||||||
export redirect_to_https="$(jq -r '.nginx_redirect_to_https' <<< "$YNH_SETTINGS" | int_to_bool)"
|
export redirect_to_https="$(jq -r '.nginx_redirect_to_https' <<< "$YNH_SETTINGS" | int_to_bool)"
|
||||||
export compatibility="$(jq -r '.nginx_compatibility' <<< "$YNH_SETTINGS" | int_to_bool)"
|
export compatibility="$(jq -r '.nginx_compatibility' <<< "$YNH_SETTINGS" | int_to_bool)"
|
||||||
export experimental="$(jq -r '.security_experimental_enabled' <<< "$YNH_SETTINGS" | int_to_bool)"
|
export experimental="$(jq -r '.security_experimental_enabled' <<< "$YNH_SETTINGS" | int_to_bool)"
|
||||||
ynh_render_template "security.conf.inc" "${nginx_conf_dir}/security.conf.inc"
|
|
||||||
|
do_base_regen "${pending_dir}"
|
||||||
|
|
||||||
cert_status=$(yunohost domain cert status --json)
|
cert_status=$(yunohost domain cert status --json)
|
||||||
|
|
||||||
|
@ -114,15 +110,8 @@ do_pre_regen() {
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
export webadmin_allowlist_enabled="$(jq -r '.webadmin_allowlist_enabled' <<< "$YNH_SETTINGS" | int_to_bool)"
|
# Legacy file to remove
|
||||||
if [ "$webadmin_allowlist_enabled" == "True" ]; then
|
touch "$nginx_conf_dir"/yunohost_panel.conf.inc
|
||||||
export webadmin_allowlist="$(jq -r '.webadmin_allowlist' <<< "$YNH_SETTINGS" | sed 's/^null$//g')"
|
|
||||||
fi
|
|
||||||
ynh_render_template "yunohost_admin.conf.inc" "${nginx_conf_dir}/yunohost_admin.conf.inc"
|
|
||||||
ynh_render_template "yunohost_api.conf.inc" "${nginx_conf_dir}/yunohost_api.conf.inc"
|
|
||||||
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
|
|
||||||
mkdir -p $nginx_conf_dir/default.d/
|
|
||||||
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
|
||||||
|
|
||||||
# remove old domain conf files
|
# remove old domain conf files
|
||||||
conf_files=$(ls -1 /etc/nginx/conf.d \
|
conf_files=$(ls -1 /etc/nginx/conf.d \
|
||||||
|
|
Loading…
Add table
Reference in a new issue