Merge branch '3.0.x' into main

This commit is contained in:
jo 2023-02-26 20:16:38 +01:00
commit 9384df7be2
No known key found for this signature in database
GPG key ID: B2FEC9B22722B984
16 changed files with 200 additions and 61 deletions

106
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
@ -208,24 +217,41 @@ backup_if_exists() {
fi
}
# diff_if_exists <src> <dest>
diff_if_exists() {
src="$1"
dest="$2"
shift 2
if [[ -f "$dest" ]]; then
src_explicit_filename="$(dirname "$src")/$(basename "$dest").new"
cp "$src" "$src_explicit_filename"
# print what the existing file $dest would become if $src is copied
diff -u --color=always "$dest" "$src_explicit_filename" || :
rm -f "$src_explicit_filename"
fi
}
# cp_if_different <src> <dest>
cp_if_different() {
if [[ -f "$2" ]] && diff -q "$1" "$2" > /dev/null; then
return
fi
diff_if_exists "$1" "$2"
backup_if_exists "$2"
cp "$1" "$2"
}
# template_file <src> <dest> <render...>
# template_file <action> <src> <dest> <render...>
template_file() {
src="$1"
dest="$2"
shift 2
action="$1"
src="$2"
dest="$3"
shift 3
tmp_file=$(mktemp)
"$@" "$src" > "$tmp_file"
cp_if_different "$tmp_file" "$dest"
$action "$tmp_file" "$dest"
rm "$tmp_file"
}
@ -268,7 +294,11 @@ install_service() {
[[ -f "$service_src" ]] || error "service '$service_name' src path '$service_src' does not exists!"
template_file "$service_src" "$service_dest" \
if [[ ! -d "$SERVICE_DIR" ]]; then
mkdir -p "$SERVICE_DIR"
fi
template_file cp_if_different "$service_src" "$service_dest" \
sed \
-e "s|^User=.*|User=${LIBRETIME_USER}|" \
-e "s|^Group=.*|Group=${LIBRETIME_USER}|" \
@ -308,17 +338,15 @@ check_distribution() {
ubuntu-20.04) is_ubuntu=true && distro="focal" ;;
debian-11) is_debian=true && distro="bullseye" ;;
*)
error << "EOF"
could not determine supported distribution "$ID-$VERSION_ID"!
error "could not determine supported distribution '$ID-$VERSION_ID'
Support for installing LibreTime on Buster has dropped since 3.1.0.
Support for installing LibreTime on Bionic has dropped since 3.1.0.
Support for installing LibreTime on Xenial has dropped since 3.0.0-alpha.10.
Support for installing LibreTime on Stretch has dropped since 3.0.0-alpha.10.
Support for installing LibreTime on Jessie has dropped since 3.0.0-alpha.8.
Please check the documentation to find the supported distributions.
EOF
exit 1
Support for installing LibreTime on Buster has dropped since 3.1.0.
Support for installing LibreTime on Bionic has dropped since 3.1.0.
Support for installing LibreTime on Xenial has dropped since 3.0.0-alpha.10.
Support for installing LibreTime on Stretch has dropped since 3.0.0-alpha.10.
Support for installing LibreTime on Jessie has dropped since 3.0.0-alpha.8."
;;
esac
}
@ -565,7 +593,9 @@ install_service "libretime-liquidsoap.service" "$SCRIPT_DIR/playout/install/syst
install_service "libretime-playout.service" "$SCRIPT_DIR/playout/install/systemd/libretime-playout.service"
info "deploying libretime-liquidsoap logrotate config"
template_file "$SCRIPT_DIR/playout/install/logrotate/libretime-liquidsoap.conf" "/etc/logrotate.d/libretime-liquidsoap" \
template_file cp_if_different \
"$SCRIPT_DIR/playout/install/logrotate/libretime-liquidsoap.conf" \
"/etc/logrotate.d/libretime-liquidsoap" \
sed \
-e "s|@@LOG_DIR@@|${LOG_DIR}|g" \
-e "s|@@USER@@|${LIBRETIME_USER}|g"
@ -652,13 +682,17 @@ fi
PHP_VERSION="$(php-config --version | awk -F . '{ print $1 "." $2 }')"
info "deploying libretime-legacy php-fpm config"
template_file "$SCRIPT_DIR/legacy/install/php-fpm/libretime-legacy.conf" "/etc/php/$PHP_VERSION/fpm/pool.d/libretime-legacy.conf" \
template_file cp_if_different \
"$SCRIPT_DIR/legacy/install/php-fpm/libretime-legacy.conf" \
"/etc/php/$PHP_VERSION/fpm/pool.d/libretime-legacy.conf" \
sed \
-e "s|@@DEFAULT_WEB_USER@@|${DEFAULT_WEB_USER}|g" \
-e "s|@@USER@@|${LIBRETIME_USER}|g"
info "deploying libretime-legacy logrotate config"
template_file "$SCRIPT_DIR/legacy/install/logrotate/libretime-legacy.conf" "/etc/logrotate.d/libretime-legacy" \
template_file cp_if_different \
"$SCRIPT_DIR/legacy/install/logrotate/libretime-legacy.conf" \
"/etc/logrotate.d/libretime-legacy" \
sed \
-e "s|@@LOG_DIR@@|${LOG_DIR}|g" \
-e "s|@@USER@@|${LIBRETIME_USER}|g"
@ -668,21 +702,35 @@ template_file "$SCRIPT_DIR/legacy/install/logrotate/libretime-legacy.conf" "/etc
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 "${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
########################################################################################