From 4c1cdcb997a1f663877cc6fe26573e0c7c8a3f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roni=20V=C3=A4yrynen?= Date: Sun, 22 Dec 2024 15:58:25 +0200 Subject: [PATCH] feat: add possibility to use custom listen address in XO config --- sample.xo-install.cfg | 5 +++++ xo-install.sh | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/sample.xo-install.cfg b/sample.xo-install.cfg index d65f6e9..67b86b7 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -22,6 +22,11 @@ PORT="80" # Port number to where xo-proxy service is bound PROXY_PORT="443" +# IP-address which xo-server listens to +# By default XO will listen to all available IPv6 addresses and if none exists, all IPv4 addresses +# With this you can force XO to listen only specific address, or e.g. all IPv4 addresses with 0.0.0.0 +#LISTEN_ADDRESS="0.0.0.0" + # Base dir for installation and future updates INSTALLDIR="/opt/xo" diff --git a/xo-install.sh b/xo-install.sh index 36167bc..d925dee 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -23,6 +23,7 @@ source "$CONFIG_FILE" # Set some default variables if sourcing config file fails for some reason SELFUPGRADE=${SELFUPGRADE:-"true"} PORT=${PORT:-80} +LISTEN_ADDRESS=${LISTEN_ADDRESS:-""} PROXY_PORT=${PROXY_PORT:-443} INSTALLDIR=${INSTALLDIR:-"/opt/xo"} BRANCH=${BRANCH:-"master"} @@ -789,6 +790,11 @@ function InstallXO { sleep 2 fi + if [[ -n "$LISTEN_ADDRESS" ]]; then + printinfo "Changing listen address in xo-server configuration file" + runcmd "sed -i \"s%^# hostname = 'localhost'%hostname = '$LISTEN_ADDRESS'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml" + fi + if [[ "$HTTPS" == "true" ]]; then printinfo "Enabling HTTPS in xo-server configuration file" # shellcheck disable=SC1117 @@ -1450,6 +1456,9 @@ function StartUpScreen { echo -e "Basedir: ${COLOR_WHITE}$INSTALLDIR ${COLOR_N}" echo -e "User: ${COLOR_WHITE}$XOUSER ${COLOR_N}" echo -e "Port: ${COLOR_WHITE}$PORT${COLOR_N}" + if [[ -n "$LISTEN_ADDRESS" ]]; then + echo -e "Listen address: ${COLOR_WHITE}$LISTEN_ADDRESS${COLOR_N}" + fi echo -e "HTTPS: ${COLOR_WHITE}${HTTPS}${COLOR_N}" echo -e "Git Branch for source: ${COLOR_WHITE}$BRANCH${COLOR_N}" echo -e "Following plugins will be installed: ${COLOR_WHITE}$PLUGINS${COLOR_N}"