fix issue #27: use config.toml file instead of xo-server.toml. remove old support for .yaml config

This commit is contained in:
ronivay
2019-11-27 20:28:20 +02:00
parent 5db6ceee04
commit 9831571cea
2 changed files with 15 additions and 26 deletions

View File

@@ -7,6 +7,9 @@ PORT="80"
# Base dir for installation and future updates # Base dir for installation and future updates
INSTALLDIR="/etc/xo" INSTALLDIR="/etc/xo"
# Configuration is stored in XOUSER's home directory and by default will be overwritten with every update done by this script. Set CONFIGUPDATE to false if you don't want this to happen
CONFIGUPDATE=true
# Git branch or tag (append tags/ before the tag name) where xen-orchestra sources are fetched. # Git branch or tag (append tags/ before the tag name) where xen-orchestra sources are fetched.
# Also, you can set this to "release" to use the latest tagged branch. # Also, you can set this to "release" to use the latest tagged branch.
BRANCH="master" BRANCH="master"

View File

@@ -24,6 +24,8 @@ BRANCH=${BRANCH:-"master"}
LOGFILE=${LOGFILE:-"$(dirname $0)/xo-install.log"} LOGFILE=${LOGFILE:-"$(dirname $0)/xo-install.log"}
AUTOUPDATE=${AUTOUPDATE:-"true"} AUTOUPDATE=${AUTOUPDATE:-"true"}
PRESERVE=${PRESERVE:-"3"} PRESERVE=${PRESERVE:-"3"}
XOUSER=${XOUSER:-"root"}
CONFIGPATH="$(getent passwd $XOUSER | cut -d: -f6)"
# Set path where new source is cloned/pulled # Set path where new source is cloned/pulled
XO_SRC_DIR="$INSTALLDIR/xo-src/xen-orchestra" XO_SRC_DIR="$INSTALLDIR/xo-src/xen-orchestra"
@@ -414,32 +416,12 @@ function InstallXO {
fi fi
fi fi
echo -e ${INFO} "Fixing relative path to xo-web installation in xo-server configuration file" if [[ ! -f $CONFIGPATH/.config/xo-server/config.toml ]] || [[ "$CONFIGUPDATE" == "true" ]]; then
# temporarily look for .yaml file first, if not found then assume that new .toml format exists
if [[ -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml ]]; then
sed -i "s/#'\/': '\/path\/to\/xo-web\/dist\//'\/': '..\/xo-web\/dist\//" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
sleep 2
if [[ $PORT != "80" ]]; then echo -e ${INFO} "Fixing relative path to xo-web installation in xo-server configuration file"
echo -e "${INFO} Changing port in xo-server configuration file"
sed -i "s/port: 80/port: $PORT/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
sleep 2
fi
if $HTTPS ; then INSTALLDIRESC=$(echo $INSTALLDIR | sed 's/\//\\\//g')
echo -e "${INFO} Enabling HTTPS in xo-server configuration file" sed -i "s/#'\/any\/url' = '\/path\/to\/directory'/'\/' = '$INSTALLDIRESC\/xo-web\/dist\/'/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml
sed -i "s%# cert: '.\/certificate.pem'% cert: '$PATH_TO_HTTPS_CERT'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
sed -i "s%# key: '.\/key.pem'% key: '$PATH_TO_HTTPS_KEY'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
sed -i "s/#redirectToHttps/redirectToHttps/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
sleep 2
fi
echo -e "${INFO} Activating modified configuration file"
mv $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/.xo-server.yaml
else
sed -i "s/#'\/' = '\/path\/to\/xo-web\/dist\//'\/' = '..\/xo-web\/dist\//" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml
sleep 2 sleep 2
if [[ $PORT != "80" ]]; then if [[ $PORT != "80" ]]; then
@@ -457,8 +439,10 @@ function InstallXO {
fi fi
echo -e "${INFO} Activating modified configuration file" echo -e "${INFO} Activating modified configuration file"
mv $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/.xo-server.toml mkdir -p $CONFIGPATH/.config/xo-server
fi mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml
fi
echo echo
echo -e "${INFO} Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server" echo -e "${INFO} Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server"
@@ -720,6 +704,8 @@ echo "Following plugins will be installed: "$PLUGINS""
echo "Number of previous installations to preserve: $PRESERVE" echo "Number of previous installations to preserve: $PRESERVE"
echo echo
echo "Errorlog is stored to $LOGFILE for debug purposes" echo "Errorlog is stored to $LOGFILE for debug purposes"
echo
echo "Xen Orchestra configuration will be stored to $CONFIGPATH/.config/xo-server/config.toml, if you don't want it to be replaced with every update, set CONFIGUPDATE to false in xo-server.cfg"
echo "-----------------------------------------" echo "-----------------------------------------"
echo echo