Add Docker container, update readme and fix indentations
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
This tool will will install and update [Xen Orchestra](https://xen-orchestra.com/#!/) automatically. xo-server and xo-web components are built from sources.
|
This tool will will install and update [Xen Orchestra](https://xen-orchestra.com/#!/) automatically. xo-server and xo-web components are built from sources.
|
||||||
|
|
||||||
|
There's also an option to build/pull docker image to get things up and running quickly.
|
||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
|
|
||||||
Clone this repository and run xo-install.sh script as root
|
Clone this repository and run xo-install.sh script as root
|
||||||
@@ -12,13 +14,15 @@ Clone this repository and run xo-install.sh script as root
|
|||||||
./install-xo.sh
|
./install-xo.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Tool makes some checks and offers options to update/install Xen-Orchestra or deploy a container.
|
||||||
|
|
||||||
Tool has been tested to work with following distros:
|
Tool has been tested to work with following distros:
|
||||||
|
|
||||||
- CentOS 7
|
- CentOS 7
|
||||||
- Debian 8
|
- Debian 8
|
||||||
- Ubuntu 16.05
|
- Ubuntu 16.05
|
||||||
|
|
||||||
CentOS was tested without SELinux. You need to deal with labels yourself if you want to use it.
|
CentOS was tested without SELinux. You need to deal with labels and permissions yourself if you want to use it.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
43
docker/Dockerfile
Normal file
43
docker/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
FROM centos:latest
|
||||||
|
|
||||||
|
MAINTAINER Roni Väyrynen <roni@vayrynen.info>
|
||||||
|
|
||||||
|
# Install set of dependencies to support running Xen-Orchestra
|
||||||
|
|
||||||
|
# Node v6
|
||||||
|
RUN curl -s -L https://rpm.nodesource.com/setup_6.x | bash -
|
||||||
|
|
||||||
|
# yarn for installing node packages
|
||||||
|
RUN curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo
|
||||||
|
RUN yum -y install yarn
|
||||||
|
|
||||||
|
# epel-release for various packages not available from base repo
|
||||||
|
RUN yum -y install epel-release
|
||||||
|
|
||||||
|
# build dependencies, git for fetchin source and redis server for storing ata
|
||||||
|
RUN yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python git
|
||||||
|
|
||||||
|
# monit to keep an eye on processes
|
||||||
|
RUN yum -y install monit
|
||||||
|
ADD monit-services /etc/monit.d/services
|
||||||
|
|
||||||
|
# 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 stable http://github.com/vatesfr/xo-web /etc/xo-web
|
||||||
|
|
||||||
|
# Run build tasks against sources
|
||||||
|
RUN cd /etc/xo-server && yarn
|
||||||
|
RUN cd /etc/xo-web && yarn
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Move edited config sample to place
|
||||||
|
RUN mv /etc/xo-server/sample.config.yaml /etc/xo-server/.xo-server.yaml
|
||||||
|
|
||||||
|
# Install forever for starting/stopping Xen-Orchestra
|
||||||
|
RUN npm install forever -g
|
||||||
|
|
||||||
|
WORKDIR /etc/xo-server
|
||||||
|
|
||||||
|
CMD ["/usr/bin/monit"]
|
10
docker/monit-services
Normal file
10
docker/monit-services
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
set init
|
||||||
|
|
||||||
|
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"
|
||||||
|
stop program = "/usr/bin/forever stop /etc/xo-server/bin/xo-server"
|
||||||
|
|
||||||
|
|
||||||
|
check process redis with pidfile /var/run/redis/redis.pid
|
||||||
|
start program = "/usr/bin/redis-server /etc/redis.conf --daemonize yes"
|
||||||
|
stop program = "/usr/bin/redis-cli shutdown"
|
@@ -6,7 +6,7 @@
|
|||||||
PORT="80"
|
PORT="80"
|
||||||
INSTALLDIR="/etc/xo"
|
INSTALLDIR="/etc/xo"
|
||||||
BRANCH="stable"
|
BRANCH="stable"
|
||||||
LOGFILE=$(dirname $0)/xo-install.log
|
LOGFILE="$(dirname $0)/xo-install.log"
|
||||||
|
|
||||||
## Modify to your need ##
|
## Modify to your need ##
|
||||||
|
|
||||||
@@ -65,13 +65,14 @@ function InstallDependenciesCentOS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function InstallDependenciesDebian {
|
function InstallDependenciesDebian {
|
||||||
# Install necessary dependencies for XO build
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Install necessary dependencies for XO build
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -n "Running apt-get update..."
|
echo -n "Running apt-get update..."
|
||||||
apt-get update >/dev/null 2>$LOGFILE
|
apt-get update >/dev/null 2>$LOGFLE
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
# Install apt-transport-https and ca-certificates because of yarn https repo url
|
# Install apt-transport-https and ca-certificates because of yarn https repo url
|
||||||
@@ -168,16 +169,15 @@ function InstallXO {
|
|||||||
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 xo-server install..."
|
||||||
cd $INSTALLDIR/xo-builds/xo-server-$TIME && yarn >/dev/null 2>$LOGFILE && yarn run build >/dev/null 2>$LOGFILE
|
cd $INSTALLDIR/xo-builds/xo-server-$TIME && yarn >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
echo -n "Running xo-web install..."
|
echo -n "Running xo-web install..."
|
||||||
cd $INSTALLDIR/xo-builds/xo-web-$TIME && yarn >/dev/null 2>$LOGFILE && yarn run build >/dev/null 2>$LOGFILE
|
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/xo-server-$TIME/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/xo-server-$TIME/xo-server.service
|
||||||
@@ -197,7 +197,9 @@ function InstallXO {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xo-server-$TIME/xo-server.service /etc/systemd/system/xo-server.service
|
echo
|
||||||
|
echo "Symlinking systemd service configuration"
|
||||||
|
ln -sfn $INSTALLDIR/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
||||||
sleep 2
|
sleep 2
|
||||||
echo "Reloading systemd configuration"
|
echo "Reloading systemd configuration"
|
||||||
echo
|
echo
|
||||||
@@ -259,7 +261,11 @@ function InstallXO {
|
|||||||
|
|
||||||
function UpdateXO {
|
function UpdateXO {
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $(ps aux | grep xo-server | grep -v grep) ]]; then
|
||||||
/bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; }
|
/bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
InstallXO
|
InstallXO
|
||||||
|
|
||||||
# remove old builds. leave 5 latest
|
# remove old builds. leave 5 latest
|
||||||
@@ -338,7 +344,8 @@ echo "-----------------------------------------"
|
|||||||
echo
|
echo
|
||||||
echo "1. Install"
|
echo "1. Install"
|
||||||
echo "2. Update"
|
echo "2. Update"
|
||||||
echo "3. Exit"
|
echo "3. Run with docker"
|
||||||
|
echo "4. Exit"
|
||||||
echo
|
echo
|
||||||
read -p ": " option
|
read -p ": " option
|
||||||
|
|
||||||
@@ -376,6 +383,38 @@ read -p ": " option
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
|
echo
|
||||||
|
echo "Build image locally or fetch from docker hub?"
|
||||||
|
echo "1. Build"
|
||||||
|
echo "2. Pull"
|
||||||
|
read -p ": " container
|
||||||
|
case $container in
|
||||||
|
1)
|
||||||
|
echo
|
||||||
|
docker build -t xen-orchestra $(dirname $0)/docker/image/.
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Image built. Run container:"
|
||||||
|
echo "docker run -itd -p 80:80 xen-orchestra"
|
||||||
|
echo
|
||||||
|
echo "If you want to persist xen-orchestra and redis data, use volume flags like:"
|
||||||
|
echo "docker run -itd -p 80:80 -v /path/to/data/xo-server:/var/lib/xo-server -v /path/to/data/redis:/var/lib/redis xen-orchestra"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo
|
||||||
|
docker pull ronivay/xen-orchestra
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Image built. Run container:"
|
||||||
|
echo "docker run -itd -p 80:80 ronivay/xen-orchestra"
|
||||||
|
echo
|
||||||
|
echo "If you want to persist xen-orchestra and redis data, use volume flags like:"
|
||||||
|
echo "docker run -itd -p 80:80 -v /path/to/data/xo-server:/var/lib/xo-server -v /path/to/data/redis:/var/lib/redis ronivay/xen-orchestra"
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
4)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
Reference in New Issue
Block a user