From 2da60d7c309e4d958fe7aa6ac013478df9be9989 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 23 Mar 2023 19:53:18 +0800 Subject: [PATCH] feat: add port settings --- init.sh | 20 +++++++++++++++----- nginx/alltube.conf | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/init.sh b/init.sh index 6558475..4ca15f1 100755 --- a/init.sh +++ b/init.sh @@ -1,28 +1,38 @@ #!/usr/bin/env sh +DEFAULT_PORT="80" + +NGINX_CONFIG="/etc/nginx/alltube.conf" CONFIG="/var/www/alltube/config/config.yml" sed -i "s,^audioBitrate:.*,audioBitrate: 320," "${CONFIG}" sed -i "s,^youtubedl:.*,youtubedl: /usr/bin/yt-dlp," "${CONFIG}" -if [ "$REMUX" = "TRUE" ] || [ "$REMUX" = "ON" ]; then +if [ -n "${PORT}" ]; then + echo "Port: ${PORT}" + sed -i "s/@PORT@/${PORT}/g" "${NGINX_CONFIG}" +else + sed -i "s/@PORT@/${DEFAULT_PORT}/g" "${NGINX_CONFIG}" +fi + +if [ "${REMUX}" = "TRUE" ] || [ "${REMUX}" = "ON" ]; then echo "Remux enabled" sed -i "s,^remux:.*,remux: true," "${CONFIG}" fi -if [ "$STREAM" = "TRUE" ] || [ "$STREAM" = "ON" ]; then +if [ "${STREAM}" = "TRUE" ] || [ "${STREAM}" = "ON" ]; then echo "Stream enabled" sed -i "s,^stream:.*,stream: ask," "${CONFIG}" fi -if [ "$CONVERT" = "TRUE" ] || [ "$CONVERT" = "ON" ]; then +if [ "${CONVERT}" = "TRUE" ] || [ "${CONVERT}" = "ON" ]; then echo "Convert enabled" sed -i "s,^convert:.*,convert: true," "${CONFIG}" sed -i "s,^convertAdvanced:.*,convertAdvanced: true," "${CONFIG}" fi -if [ -n "$TITLE" ]; then - echo "Title: ${TITLE}" +if [ -n "${TITLE}" ]; then + echo "Title: "'`'"${TITLE}"'`' sed -i "s,^appName:.*,appName: ${TITLE}," "${CONFIG}" fi diff --git a/nginx/alltube.conf b/nginx/alltube.conf index f202b4f..715fb35 100644 --- a/nginx/alltube.conf +++ b/nginx/alltube.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen @PORT@; index index.php; root /var/www/alltube/;