fix(installer): only setup nginx on first install

Users usually want to setup a ssl certificate for LibreTime. Disabling any nginx config change unless it is the first install should prevent breaking a possible certbot setup.
This commit is contained in:
jo 2023-02-03 14:18:35 +01:00 committed by Jonas L
parent 9a65e08890
commit e92be34e2a
2 changed files with 40 additions and 13 deletions

47
install
View file

@ -73,6 +73,8 @@ Options:
--no-setup-postgresql Do not setup Postgresql.
--no-setup-rabbitmq Do not setup RabbitMQ.
--update-nginx Update nginx files during upgrades.
Environment variables:
Advanced options can be changed using environment variables (flags will take
@ -113,6 +115,9 @@ LIBRETIME_SETUP_POSTGRESQL=${LIBRETIME_SETUP_POSTGRESQL:-true}
# > Create a default rabbitmq user with a random password.
LIBRETIME_SETUP_RABBITMQ=${LIBRETIME_SETUP_RABBITMQ:-true}
# > Update nginx files during upgrades.
LIBRETIME_UPDATE_NGINX=${LIBRETIME_UPDATE_NGINX:-false}
# > Comma separated list of sections to exclude from packages list.
LIBRETIME_PACKAGES_EXCLUDES=${LIBRETIME_PACKAGES_EXCLUDES:-}
@ -130,6 +135,10 @@ while [[ $# -gt 0 ]]; do
LIBRETIME_INSTALL_IN_PLACE=true
shift 1
;;
--update-nginx)
LIBRETIME_UPDATE_NGINX=true
shift 1
;;
--no-setup-icecast)
LIBRETIME_SETUP_ICECAST=false
shift 1
@ -730,23 +739,35 @@ template_file cp_if_different \
section "Nginx"
install_packages nginx
if $is_first_install || $LIBRETIME_UPDATE_NGINX; then
install_packages nginx
info "disabling nginx default site"
rm -f "/etc/nginx/sites-enabled/default"
info "disabling nginx default site"
rm -f "/etc/nginx/sites-enabled/default"
fi
info "deploying libretime nginx config"
template_file cp_if_different \
"${SCRIPT_DIR}/installer/nginx/libretime.conf" \
"/etc/nginx/sites-available/libretime.conf" \
sed \
-e "s|@@LISTEN_PORT@@|${LIBRETIME_LISTEN_PORT}|g" \
nginx_config_template_args=(
"${SCRIPT_DIR}/installer/nginx/libretime.conf"
"/etc/nginx/sites-available/libretime.conf"
sed
-e "s|@@LISTEN_PORT@@|${LIBRETIME_LISTEN_PORT}|g"
-e "s|@@LEGACY_WEB_ROOT@@|${LEGACY_WEB_ROOT}|g"
)
info "enabling libretime nginx config"
ln -s --force \
"/etc/nginx/sites-available/libretime.conf" \
"/etc/nginx/sites-enabled/libretime.conf"
if $is_first_install || $LIBRETIME_UPDATE_NGINX; then
info "deploying libretime nginx config"
template_file cp_if_different "${nginx_config_template_args[@]}"
else
info "printing libretime nginx config differences"
template_file diff_if_exists "${nginx_config_template_args[@]}"
fi
if $is_first_install || $LIBRETIME_UPDATE_NGINX; then
info "enabling libretime nginx config"
ln -s --force \
"/etc/nginx/sites-available/libretime.conf" \
"/etc/nginx/sites-enabled/libretime.conf"
fi
# Finalize
########################################################################################