Merge pull request #270 from ronivay/feat/custom-listen-address

feat: add possibility to use custom listen address in XO config
This commit is contained in:
Roni Väyrynen
2024-12-22 16:09:00 +02:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@@ -22,6 +22,11 @@ PORT="80"
# Port number to where xo-proxy service is bound # Port number to where xo-proxy service is bound
PROXY_PORT="443" 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 # Base dir for installation and future updates
INSTALLDIR="/opt/xo" INSTALLDIR="/opt/xo"

View File

@@ -23,6 +23,7 @@ source "$CONFIG_FILE"
# Set some default variables if sourcing config file fails for some reason # Set some default variables if sourcing config file fails for some reason
SELFUPGRADE=${SELFUPGRADE:-"true"} SELFUPGRADE=${SELFUPGRADE:-"true"}
PORT=${PORT:-80} PORT=${PORT:-80}
LISTEN_ADDRESS=${LISTEN_ADDRESS:-""}
PROXY_PORT=${PROXY_PORT:-443} PROXY_PORT=${PROXY_PORT:-443}
INSTALLDIR=${INSTALLDIR:-"/opt/xo"} INSTALLDIR=${INSTALLDIR:-"/opt/xo"}
BRANCH=${BRANCH:-"master"} BRANCH=${BRANCH:-"master"}
@@ -789,6 +790,11 @@ function InstallXO {
sleep 2 sleep 2
fi 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 if [[ "$HTTPS" == "true" ]]; then
printinfo "Enabling HTTPS in xo-server configuration file" printinfo "Enabling HTTPS in xo-server configuration file"
# shellcheck disable=SC1117 # shellcheck disable=SC1117
@@ -1450,6 +1456,9 @@ function StartUpScreen {
echo -e "Basedir: ${COLOR_WHITE}$INSTALLDIR ${COLOR_N}" echo -e "Basedir: ${COLOR_WHITE}$INSTALLDIR ${COLOR_N}"
echo -e "User: ${COLOR_WHITE}$XOUSER ${COLOR_N}" echo -e "User: ${COLOR_WHITE}$XOUSER ${COLOR_N}"
echo -e "Port: ${COLOR_WHITE}$PORT${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 "HTTPS: ${COLOR_WHITE}${HTTPS}${COLOR_N}"
echo -e "Git Branch for source: ${COLOR_WHITE}$BRANCH${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}" echo -e "Following plugins will be installed: ${COLOR_WHITE}$PLUGINS${COLOR_N}"