Update to work with new Xen-Orchestra repo and structure. Minor updates on top of it
This commit is contained in:
@@ -4,8 +4,8 @@ MAINTAINER Roni Väyrynen <roni@vayrynen.info>
|
|||||||
|
|
||||||
# Install set of dependencies to support running Xen-Orchestra
|
# Install set of dependencies to support running Xen-Orchestra
|
||||||
|
|
||||||
# Node v6
|
# Node v8
|
||||||
RUN curl -s -L https://rpm.nodesource.com/setup_6.x | bash -
|
RUN curl -s -L https://rpm.nodesource.com/setup_8.x | bash -
|
||||||
|
|
||||||
# yarn for installing node packages
|
# yarn for installing node packages
|
||||||
RUN curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo
|
RUN curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo
|
||||||
@@ -22,23 +22,21 @@ RUN yum -y install monit
|
|||||||
ADD monit-services /etc/monit.d/services
|
ADD monit-services /etc/monit.d/services
|
||||||
|
|
||||||
# Fetch Xen-Orchestra sources from git stable branch
|
# Fetch Xen-Orchestra sources from git stable branch
|
||||||
RUN git clone -b stable http://github.com/vatesfr/xo-server /etc/xo-server
|
RUN git clone -b master https://github.com/vatesfr/xen-orchestra /etc/xen-orchestra
|
||||||
RUN git clone -b stable http://github.com/vatesfr/xo-web /etc/xo-web
|
|
||||||
|
|
||||||
# Run build tasks against sources
|
# Run build tasks against sources
|
||||||
RUN cd /etc/xo-server && yarn
|
RUN cd /etc/xen-orchestra && yarn && yarn build
|
||||||
RUN cd /etc/xo-web && yarn
|
|
||||||
|
|
||||||
# Fix path for xo-web content in xo-server configuration
|
# Fix path for xo-web content in xo-server configuration
|
||||||
RUN sed -i "s/#'\/': '\/path\/to\/xo-web\/dist\//'\/': '..\/xo-web\/dist\//" /etc/xo-server/sample.config.yaml
|
RUN sed -i "s/#'\/': '\/path\/to\/xo-web\/dist\//'\/': '..\/xo-web\/dist\//" /etc/xo-server/sample.config.yaml
|
||||||
|
|
||||||
# Move edited config sample to place
|
# Move edited config sample to place
|
||||||
RUN mv /etc/xo-server/sample.config.yaml /etc/xo-server/.xo-server.yaml
|
RUN mv /etc/xen-orchestra/packages/xo-server/sample.config.yaml /etc/xen-orchestra/packages/xo-server/.xo-server.yaml
|
||||||
|
|
||||||
# Install forever for starting/stopping Xen-Orchestra
|
# Install forever for starting/stopping Xen-Orchestra
|
||||||
RUN npm install forever -g
|
RUN npm install forever -g
|
||||||
|
|
||||||
WORKDIR /etc/xo-server
|
WORKDIR /etc/xen-orchestra/xo-server
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
set init
|
set init
|
||||||
|
|
||||||
check process xo-server with pidfile /var/run/xo-server.pid
|
check process xo-server with pidfile /var/run/xo-server.pid
|
||||||
start program = "/usr/bin/forever start --pidFile /var/run/xo-server.pid --sourceDir /etc/xo-server bin/xo-server"
|
start program = "/usr/bin/forever start --pidFile /var/run/xo-server.pid --sourceDir /etc/xen-orchestra/packages/xo-server bin/xo-server"
|
||||||
stop program = "/usr/bin/forever stop /etc/xo-server/bin/xo-server"
|
stop program = "/usr/bin/forever stop /etc/xen-orchestra/packages/xo-server/bin/xo-server"
|
||||||
|
|
||||||
|
|
||||||
check process redis with pidfile /var/run/redis/redis.pid
|
check process redis with pidfile /var/run/redis/redis.pid
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#XOUSER="node"
|
#XOUSER="node"
|
||||||
PORT="80"
|
PORT="80"
|
||||||
INSTALLDIR="/etc/xo"
|
INSTALLDIR="/etc/xo"
|
||||||
BRANCH="stable"
|
BRANCH="master"
|
||||||
LOGFILE="$(dirname $0)/xo-install.log"
|
LOGFILE="$(dirname $0)/xo-install.log"
|
||||||
|
|
||||||
## Modify to your need ##
|
## Modify to your need ##
|
||||||
@@ -31,7 +31,7 @@ function InstallDependenciesCentOS {
|
|||||||
if [[ -z $(rpm -qa | grep ^node) ]]; then
|
if [[ -z $(rpm -qa | grep ^node) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing node.js..."
|
echo -n "Installing node.js..."
|
||||||
curl -s -L https://rpm.nodesource.com/setup_6.x | bash - >/dev/null 2>$LOGFILE
|
curl -s -L https://rpm.nodesource.com/setup_8.x | bash - >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ function InstallDependenciesDebian {
|
|||||||
if [[ -z $(dpkg -l | grep node) ]] || [[ -z $(which npm) ]]; then
|
if [[ -z $(dpkg -l | grep node) ]] || [[ -z $(which npm) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing node.js..."
|
echo -n "Installing node.js..."
|
||||||
curl -sL https://deb.nodesource.com/setup_6.x | bash - >/dev/null 2>$LOGFILE
|
curl -sL https://deb.nodesource.com/setup_8.x | bash - >/dev/null 2>$LOGFILE
|
||||||
apt-get install -y nodejs >/dev/null 2>$LOGFILE
|
apt-get install -y nodejs >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
@@ -148,43 +148,33 @@ function InstallXO {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-server-$TIME"
|
echo "Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
mkdir -p "$INSTALLDIR/xo-builds/xo-server-$TIME"
|
mkdir -p "$INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
sleep 2
|
|
||||||
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-web-$TIME"
|
|
||||||
mkdir -p "$INSTALLDIR/xo-builds/xo-web-$TIME"
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Fetching source code from branch: $BRANCH ..."
|
echo "Fetching source code from branch: $BRANCH ..."
|
||||||
echo
|
echo
|
||||||
git clone -b $BRANCH http://github.com/vatesfr/xo-server $INSTALLDIR/xo-builds/xo-server-$TIME
|
git clone -b $BRANCH https://github.com/vatesfr/xen-orchestra $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
||||||
echo
|
|
||||||
echo
|
|
||||||
git clone -b $BRANCH http://github.com/vatesfr/xo-web $INSTALLDIR/xo-builds/xo-web-$TIME
|
|
||||||
echo
|
echo
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "xo-server and xo-web build quite a while. Grab a cup of coffee and lay back"
|
echo "xo-server and xo-web build quite a while. Grab a cup of coffee and lay back"
|
||||||
echo
|
echo
|
||||||
echo -n "Running xo-server install..."
|
echo -n "Running installation"
|
||||||
cd $INSTALLDIR/xo-builds/xo-server-$TIME && yarn >/dev/null 2>$LOGFILE
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null 2>$LOGFILE && yarn build >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
|
||||||
echo -n "Running xo-web install..."
|
|
||||||
cd $INSTALLDIR/xo-builds/xo-web-$TIME && yarn >/dev/null 2>$LOGFILE
|
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Fixing binary path in systemd service configuration and symlinking to /etc/systemd/system/xo-server.service"
|
echo "Fixing binary path in systemd service configuration and symlinking to /etc/systemd/system/xo-server.service"
|
||||||
sed -i "s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/bin\/xo-server#" $INSTALLDIR/xo-builds/xo-server-$TIME/xo-server.service
|
sed -i "s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/bin\/xo-server#" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service
|
||||||
echo
|
echo
|
||||||
echo "Adding WorkingDirectory parameter to systemd service configuration"
|
echo "Adding WorkingDirectory parameter to systemd service configuration"
|
||||||
sed -i "/ExecStart=.*/a WorkingDirectory=/etc/xo/xo-server" $INSTALLDIR/xo-builds/xo-server-$TIME/xo-server.service
|
sed -i "/ExecStart=.*/a WorkingDirectory=/etc/xo/xo-server" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service
|
||||||
|
|
||||||
if [ $XOUSER ]; then
|
if [ $XOUSER ]; then
|
||||||
echo "Adding user to systemd config"
|
echo "Adding user to systemd config"
|
||||||
sed -i "/SyslogIdentifier=.*/a User=$XOUSER" $INSTALLDIR/xo-builds/xo-server-$TIME/xo-server.service
|
sed -i "/SyslogIdentifier=.*/a User=$XOUSER" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service
|
||||||
|
|
||||||
if [ $OSNAME == "CentOS" ]; then
|
if [ $OSNAME == "CentOS" ]; then
|
||||||
echo -n "Attempting to set cap_net_bind_service permission for /usr/bin/node..."
|
echo -n "Attempting to set cap_net_bind_service permission for /usr/bin/node..."
|
||||||
@@ -197,38 +187,28 @@ function InstallXO {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Symlinking systemd service configuration"
|
|
||||||
ln -sfn $INSTALLDIR/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
|
||||||
sleep 2
|
|
||||||
echo "Reloading systemd configuration"
|
|
||||||
echo
|
|
||||||
/bin/systemctl daemon-reload
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
echo "Fixing relative path to xo-web installation in xo-server configuration file"
|
echo "Fixing relative path to xo-web installation in xo-server configuration file"
|
||||||
sed -i "s/#'\/': '\/path\/to\/xo-web\/dist\//'\/': '..\/..\/xo-web\/dist\//" $INSTALLDIR/xo-builds/xo-server-$TIME/sample.config.yaml
|
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
|
sleep 2
|
||||||
|
|
||||||
if [[ $PORT != "80" ]]; then
|
if [[ $PORT != "80" ]]; then
|
||||||
echo "Changing port in xo-server configuration file"
|
echo "Changing port in xo-server configuration file"
|
||||||
sed -i "s/port: 80/port: $PORT/" $INSTALLDIR/xo-builds/xo-server-$TIME/sample.config.yaml
|
sed -i "s/port: 80/port: $PORT/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Activating modified configuration file"
|
echo "Activating modified configuration file"
|
||||||
mv $INSTALLDIR/xo-builds/xo-server-$TIME/sample.config.yaml $INSTALLDIR/xo-builds/xo-server-$TIME/.xo-server.yaml
|
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
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server"
|
echo "Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server"
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xo-server-$TIME $INSTALLDIR/xo-server
|
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server
|
||||||
sleep 2
|
sleep 2
|
||||||
echo "Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
echo "Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xo-web-$TIME $INSTALLDIR/xo-web
|
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web
|
||||||
|
|
||||||
if [ $XOUSER ]; then
|
if [ $XOUSER ]; then
|
||||||
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xo-web-$TIME
|
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
||||||
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xo-server-$TIME
|
|
||||||
|
|
||||||
if [ ! -d /var/lib/xo-server ]; then
|
if [ ! -d /var/lib/xo-server ]; then
|
||||||
mkdir /var/lib/xo-server 2>/dev/null
|
mkdir /var/lib/xo-server 2>/dev/null
|
||||||
@@ -237,12 +217,21 @@ function InstallXO {
|
|||||||
chown $XOUSER:$XOUSER /var/lib/xo-server
|
chown $XOUSER:$XOUSER /var/lib/xo-server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Symlinking systemd service configuration"
|
||||||
|
ln -sfn $INSTALLDIR/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
||||||
|
sleep 2
|
||||||
|
echo "Reloading systemd configuration"
|
||||||
|
echo
|
||||||
|
/bin/systemctl daemon-reload
|
||||||
|
sleep 2
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Starting xo-server..."
|
echo "Starting xo-server..."
|
||||||
/bin/systemctl start xo-server >/dev/null
|
/bin/systemctl start xo-server >/dev/null
|
||||||
|
|
||||||
timeout 60 bash <<-"EOF"
|
timeout 60 bash <<-"EOF"
|
||||||
while [[ -z $(journalctl -u xo-server | grep "http:\/\/\[::\]:$PORT") ]]; do
|
while [[ -z $(journalctl -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "http:\/\/\[::\]:$PORT") ]]; do
|
||||||
echo "waiting port to be open"
|
echo "waiting port to be open"
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
@@ -271,8 +260,7 @@ function UpdateXO {
|
|||||||
# remove old builds. leave 3 latest
|
# remove old builds. leave 3 latest
|
||||||
echo
|
echo
|
||||||
echo -n "Removing old installations (leaving 3 latest)..."
|
echo -n "Removing old installations (leaving 3 latest)..."
|
||||||
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xo-web*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -3 | xargs -r rm -r
|
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xen-orchestra*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -3 | xargs -r rm -r
|
||||||
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xo-server*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -3 | xargs -r rm -r
|
|
||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +390,7 @@ read -p ": " option
|
|||||||
case $container in
|
case $container in
|
||||||
1)
|
1)
|
||||||
echo
|
echo
|
||||||
docker build -t xen-orchestra $(dirname $0)/docker/.
|
docker build -t xen-orchestra $(dirname $0)/docker/. || exit 1
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo "Image built. Run container:"
|
echo "Image built. Run container:"
|
||||||
|
Reference in New Issue
Block a user