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"
|
513
xo-install.sh
513
xo-install.sh
@@ -6,117 +6,118 @@
|
|||||||
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 ##
|
||||||
|
|
||||||
function CheckUser {
|
function CheckUser {
|
||||||
|
|
||||||
# Make sure the script is ran as root
|
# Make sure the script is ran as root
|
||||||
|
|
||||||
if [[ ! $(whoami) == "root" ]]; then
|
if [[ ! $(whoami) == "root" ]]; then
|
||||||
echo "This script needs to be ran as root"
|
echo "This script needs to be ran as root"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallDependenciesCentOS {
|
function InstallDependenciesCentOS {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Install necessary dependencies for XO build
|
# Install necessary dependencies for XO build
|
||||||
|
|
||||||
# only run automated node install if package not found
|
# only run automated node install if package not found
|
||||||
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_6.x | bash - >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
if [[ -z $(rpm -qa | grep yarn) ]]; then
|
if [[ -z $(rpm -qa | grep yarn) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing yarn..."
|
echo -n "Installing yarn..."
|
||||||
curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo >/dev/null 2>$LOGFILE && \
|
curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo >/dev/null 2>$LOGFILE && \
|
||||||
yum -y install yarn >/dev/null 2>$LOGFILE
|
yum -y install yarn >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install epel-release if doesn't exist
|
# only install epel-release if doesn't exist
|
||||||
if [[ -z $(rpm -qa | grep epel-release) ]]; then
|
if [[ -z $(rpm -qa | grep epel-release) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing epel-repo..."
|
echo -n "Installing epel-repo..."
|
||||||
yum -y install epel-release >/dev/null 2>$LOGFILE
|
yum -y install epel-release >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install
|
# install
|
||||||
echo
|
echo
|
||||||
echo -n "Installing build dependencies, redis server, python and git..."
|
echo -n "Installing build dependencies, redis server, python and git..."
|
||||||
yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python git >/dev/null 2>$LOGFILE
|
yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python git >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Enabling and starting redis service"
|
echo "Enabling and starting redis service"
|
||||||
/bin/systemctl enable redis >/dev/null 2>$LOGFILE && /bin/systemctl start redis >/dev/null 2>$LOGFILE
|
/bin/systemctl enable redis >/dev/null 2>$LOGFILE && /bin/systemctl start redis >/dev/null 2>$LOGFILE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallDependenciesDebian {
|
function InstallDependenciesDebian {
|
||||||
# Install necessary dependencies for XO build
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo
|
# Install necessary dependencies for XO build
|
||||||
echo -n "Running apt-get update..."
|
|
||||||
apt-get update >/dev/null 2>$LOGFILE
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
# Install apt-transport-https and ca-certificates because of yarn https repo url
|
|
||||||
echo
|
echo
|
||||||
echo -n "Installing apt-transport-https and ca-certificates packages to support https repos"
|
echo -n "Running apt-get update..."
|
||||||
apt-get install -y apt-transport-https ca-certificates >/dev/null 2>$LOGFILE
|
apt-get update >/dev/null 2>$LOGFLE
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
# install curl for later tasks if missing
|
# Install apt-transport-https and ca-certificates because of yarn https repo url
|
||||||
if [[ ! $(which curl) ]]; then
|
echo
|
||||||
|
echo -n "Installing apt-transport-https and ca-certificates packages to support https repos"
|
||||||
|
apt-get install -y apt-transport-https ca-certificates >/dev/null 2>$LOGFILE
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
# install curl for later tasks if missing
|
||||||
|
if [[ ! $(which curl) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing curl..."
|
echo -n "Installing curl..."
|
||||||
apt-get install -y curl >/dev/null 2>$LOGFILE
|
apt-get install -y curl >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
if [[ -z $(dpkg -l | grep yarn) ]]; then
|
if [[ -z $(dpkg -l | grep yarn) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Installing yarn..."
|
echo -n "Installing yarn..."
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >/dev/null 2>$LOGFILE
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >/dev/null 2>$LOGFILE
|
||||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >/dev/null 2>$LOGFILE
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >/dev/null 2>$LOGFILE
|
||||||
apt-get update >/dev/null 2>$LOGFILE
|
apt-get update >/dev/null 2>$LOGFILE
|
||||||
apt-get install -y yarn >/dev/null 2>$LOGFILE
|
apt-get install -y yarn >/dev/null 2>$LOGFILE
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# only run automated node install if package not found
|
# only run automated node install if package not found
|
||||||
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_6.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
|
||||||
|
|
||||||
|
|
||||||
# install packages
|
# install packages
|
||||||
echo
|
echo
|
||||||
echo -n "Installing build dependencies, redis server, python and git..."
|
echo -n "Installing build dependencies, redis server, python and git..."
|
||||||
apt-get install -y build-essential redis-server libpng-dev git python-minimal >/dev/null 2>$LOGFILE
|
apt-get install -y build-essential redis-server libpng-dev git python-minimal >/dev/null 2>$LOGFILE
|
||||||
|
|
||||||
echo "Enabling and starting redis service"
|
echo "Enabling and starting redis service"
|
||||||
/bin/systemctl enable redis-server >/dev/null 2>$LOGFILE && /bin/systemctl start redis-server >/dev/null 2>$LOGFILE
|
/bin/systemctl enable redis-server >/dev/null 2>$LOGFILE && /bin/systemctl start redis-server >/dev/null 2>$LOGFILE
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -124,120 +125,121 @@ function InstallDependenciesDebian {
|
|||||||
|
|
||||||
function InstallXO {
|
function InstallXO {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
TIME=`date +%Y%d%m%H%M`
|
TIME=`date +%Y%d%m%H%M`
|
||||||
|
|
||||||
# Create user if doesn't exist (if defined)
|
# Create user if doesn't exist (if defined)
|
||||||
|
|
||||||
if [ $XOUSER ]; then
|
if [ $XOUSER ]; then
|
||||||
if [[ -z $(getent passwd $XOUSER) ]]; then
|
if [[ -z $(getent passwd $XOUSER) ]]; then
|
||||||
echo
|
echo
|
||||||
echo "Creating $XOUSER user"
|
echo "Creating $XOUSER user"
|
||||||
useradd -s /sbin/nologin $XOUSER
|
useradd -s /sbin/nologin $XOUSER
|
||||||
echo
|
echo
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create installation directory if doesn't exist already
|
# Create installation directory if doesn't exist already
|
||||||
if [[ ! -d "$INSTALLDIR" ]] ; then
|
if [[ ! -d "$INSTALLDIR" ]] ; then
|
||||||
echo "Creating missing basedir to $INSTALLDIR"
|
echo "Creating missing basedir to $INSTALLDIR"
|
||||||
mkdir -p "$INSTALLDIR"
|
mkdir -p "$INSTALLDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-server-$TIME"
|
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-server-$TIME"
|
||||||
mkdir -p "$INSTALLDIR/xo-builds/xo-server-$TIME"
|
mkdir -p "$INSTALLDIR/xo-builds/xo-server-$TIME"
|
||||||
sleep 2
|
sleep 2
|
||||||
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-web-$TIME"
|
echo "Creating install directory: $INSTALLDIR/xo-builds/xo-web-$TIME"
|
||||||
mkdir -p "$INSTALLDIR/xo-builds/xo-web-$TIME"
|
mkdir -p "$INSTALLDIR/xo-builds/xo-web-$TIME"
|
||||||
sleep 2
|
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 http://github.com/vatesfr/xo-server $INSTALLDIR/xo-builds/xo-server-$TIME
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
git clone -b $BRANCH http://github.com/vatesfr/xo-web $INSTALLDIR/xo-builds/xo-web-$TIME
|
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 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 "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
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
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
|
||||||
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
|
||||||
|
|
||||||
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/xo-server-$TIME/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..."
|
||||||
setcap 'cap_net_bind_service=+ep' /usr/bin/node >/dev/null 2>$LOGFILE \
|
setcap 'cap_net_bind_service=+ep' /usr/bin/node >/dev/null 2>$LOGFILE \
|
||||||
&& echo "Success" || echo "Failed. Non-privileged user might not be able to bind to <1024 port"
|
&& echo "Success" || echo "Failed. Non-privileged user might not be able to bind to <1024 port"
|
||||||
else
|
else
|
||||||
echo -n "Attempting to set cap_net_bind_service permission for /usr/bin/nodejs..."
|
echo -n "Attempting to set cap_net_bind_service permission for /usr/bin/nodejs..."
|
||||||
setcap 'cap_net_bind_service=+ep' /usr/bin/nodejs >/dev/null 2>$LOGFILE \
|
setcap 'cap_net_bind_service=+ep' /usr/bin/nodejs >/dev/null 2>$LOGFILE \
|
||||||
&& echo "Success" || echo "Failed. Non-privileged user might not be able to bind to <1024 port"
|
&& echo "Success" || echo "Failed. Non-privileged user might not be able to bind to <1024 port"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xo-server-$TIME/xo-server.service /etc/systemd/system/xo-server.service
|
echo
|
||||||
sleep 2
|
echo "Symlinking systemd service configuration"
|
||||||
echo "Reloading systemd configuration"
|
ln -sfn $INSTALLDIR/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
||||||
echo
|
sleep 2
|
||||||
/bin/systemctl daemon-reload
|
echo "Reloading systemd configuration"
|
||||||
sleep 2
|
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/xo-server-$TIME/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/xo-server-$TIME/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/xo-server-$TIME/sample.config.yaml $INSTALLDIR/xo-builds/xo-server-$TIME/.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/xo-server-$TIME $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/xo-web-$TIME $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/xo-web-$TIME
|
||||||
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xo-server-$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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown $XOUSER:$XOUSER /var/lib/xo-server
|
chown $XOUSER:$XOUSER /var/lib/xo-server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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 | grep "http:\/\/\[::\]:$PORT") ]]; do
|
||||||
@@ -259,46 +261,50 @@ function InstallXO {
|
|||||||
|
|
||||||
function UpdateXO {
|
function UpdateXO {
|
||||||
|
|
||||||
/bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; }
|
|
||||||
InstallXO
|
|
||||||
|
|
||||||
# remove old builds. leave 5 latest
|
if [[ $(ps aux | grep xo-server | grep -v grep) ]]; then
|
||||||
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xo-web*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -5 | xargs -r rm -r
|
/bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; }
|
||||||
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xo-server*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -5 | xargs -r rm -r
|
fi
|
||||||
|
|
||||||
|
InstallXO
|
||||||
|
|
||||||
|
# remove old builds. leave 5 latest
|
||||||
|
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xo-web*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -5 | 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 -5 | xargs -r rm -r
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckOS {
|
function CheckOS {
|
||||||
|
|
||||||
if [ -f /etc/centos-release ] ; then
|
if [ -f /etc/centos-release ] ; then
|
||||||
OSVERSION=$(grep -Eo "[0-9]" /etc/centos-release | head -1)
|
OSVERSION=$(grep -Eo "[0-9]" /etc/centos-release | head -1)
|
||||||
OSNAME="CentOS"
|
OSNAME="CentOS"
|
||||||
if [[ ! $OSVERSION == "7" ]]; then
|
if [[ ! $OSVERSION == "7" ]]; then
|
||||||
echo "Only CentOS 7 supported"
|
echo "Only CentOS 7 supported"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
elif [[ -f /etc/os-release ]]; then
|
elif [[ -f /etc/os-release ]]; then
|
||||||
OSVERSION=$(grep ^VERSION_ID /etc/os-release | cut -d'=' -f2 | grep -Eo "[0-9]{1,2}" | head -1)
|
OSVERSION=$(grep ^VERSION_ID /etc/os-release | cut -d'=' -f2 | grep -Eo "[0-9]{1,2}" | head -1)
|
||||||
OSNAME=$(grep ^NAME /etc/os-release | cut -d'=' -f2 | sed 's/"//g' | awk '{print $1}')
|
OSNAME=$(grep ^NAME /etc/os-release | cut -d'=' -f2 | sed 's/"//g' | awk '{print $1}')
|
||||||
if [[ $OSNAME == "Debian" ]] && [[ ! $OSVERSION =~ ^(8|9)$ ]]; then
|
if [[ $OSNAME == "Debian" ]] && [[ ! $OSVERSION =~ ^(8|9)$ ]]; then
|
||||||
echo "Only Debian 8/9 supported"
|
echo "Only Debian 8/9 supported"
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ $OSNAME == "Ubuntu" ]] && [[ ! $OSVERSION == "16" ]]; then
|
elif [[ $OSNAME == "Ubuntu" ]] && [[ ! $OSVERSION == "16" ]]; then
|
||||||
echo "Only Ubuntu 16 supported"
|
echo "Only Ubuntu 16 supported"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Only CentOS 7 / Ubuntu 16 and Debian 8/9 supported"
|
echo "Only CentOS 7 / Ubuntu 16 and Debian 8/9 supported"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckSystemd {
|
function CheckSystemd {
|
||||||
|
|
||||||
if [ ! $(which systemctl) ]; then
|
if [ ! $(which systemctl) ]; then
|
||||||
echo "This tool is implemented to work with systemd enabled systems only"
|
echo "This tool is implemented to work with systemd enabled systems only"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckUser
|
CheckUser
|
||||||
@@ -324,9 +330,9 @@ echo "OS: $OSNAME $OSVERSION"
|
|||||||
echo "Basedir: $INSTALLDIR"
|
echo "Basedir: $INSTALLDIR"
|
||||||
|
|
||||||
if [ $XOUSER ]; then
|
if [ $XOUSER ]; then
|
||||||
echo "User: $XOUSER"
|
echo "User: $XOUSER"
|
||||||
else
|
else
|
||||||
echo "User: root"
|
echo "User: root"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Port: $PORT"
|
echo "Port: $PORT"
|
||||||
@@ -338,50 +344,83 @@ 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
|
||||||
|
|
||||||
case $option in
|
case $option in
|
||||||
1)
|
1)
|
||||||
if [[ $(ps aux | grep xo-server | grep -v grep) ]]; then
|
if [[ $(ps aux | grep xo-server | grep -v grep) ]]; then
|
||||||
echo "Looks like xo-server process is already running, consider running update instead. Continue anyway?"
|
echo "Looks like xo-server process is already running, consider running update instead. Continue anyway?"
|
||||||
read -p "[y/N]: " answer
|
read -p "[y/N]: " answer
|
||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
echo "Stopping xo-server..."
|
echo "Stopping xo-server..."
|
||||||
/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; }
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $OSNAME == "CentOS" ]; then
|
if [ $OSNAME == "CentOS" ]; then
|
||||||
InstallDependenciesCentOS
|
InstallDependenciesCentOS
|
||||||
InstallXO
|
InstallXO
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
InstallDependenciesDebian
|
InstallDependenciesDebian
|
||||||
InstallXO
|
InstallXO
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
UpdateXO
|
UpdateXO
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
exit 0
|
echo
|
||||||
;;
|
echo "Build image locally or fetch from docker hub?"
|
||||||
*)
|
echo "1. Build"
|
||||||
echo "Please choose one of the options"
|
echo "2. Pull"
|
||||||
echo
|
read -p ": " container
|
||||||
exit 0
|
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
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please choose one of the options"
|
||||||
|
echo
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user