refactor logging completely
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ tests/*
|
|||||||
!tests/Debian/Vagrantfile
|
!tests/Debian/Vagrantfile
|
||||||
!tests/run-tests.sh
|
!tests/run-tests.sh
|
||||||
!tests/README.md
|
!tests/README.md
|
||||||
|
logs/*
|
||||||
|
@@ -14,8 +14,8 @@ CONFIGUPDATE=true
|
|||||||
# 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"
|
||||||
|
|
||||||
# Log path for possible errors
|
# Installation log path
|
||||||
LOGFILE="$(dirname $0)/xo-install.log"
|
LOGPATH="$(dirname $0)/logs"
|
||||||
|
|
||||||
# Only one PLUGIN variable can be used at a time. Comment out the other one if you change these below. Comment out both if you don't want any plugins to be installed.
|
# Only one PLUGIN variable can be used at a time. Comment out the other one if you change these below. Comment out both if you don't want any plugins to be installed.
|
||||||
|
|
||||||
|
356
xo-install.sh
356
xo-install.sh
@@ -21,7 +21,8 @@ source $CONFIG_FILE
|
|||||||
PORT=${PORT:-80}
|
PORT=${PORT:-80}
|
||||||
INSTALLDIR=${INSTALLDIR:-"/opt/xo"}
|
INSTALLDIR=${INSTALLDIR:-"/opt/xo"}
|
||||||
BRANCH=${BRANCH:-"master"}
|
BRANCH=${BRANCH:-"master"}
|
||||||
LOGFILE=${LOGFILE:-"$(dirname $0)/xo-install.log"}
|
LOGPATH="${LOGPATH:-$(dirname $0)/logs}"
|
||||||
|
LOGFILE="${LOGPATH}/xo-install.log-$(date +%Y%d%m%H%M)"
|
||||||
AUTOUPDATE=${AUTOUPDATE:-"true"}
|
AUTOUPDATE=${AUTOUPDATE:-"true"}
|
||||||
PRESERVE=${PRESERVE:-"3"}
|
PRESERVE=${PRESERVE:-"3"}
|
||||||
XOUSER=${XOUSER:-"root"}
|
XOUSER=${XOUSER:-"root"}
|
||||||
@@ -43,17 +44,17 @@ PROGRESS="[${COLOR_BLUE}..${COLOR_N}]"
|
|||||||
|
|
||||||
# Protocol to use for webserver. If both of the X.509 certificate files exist,
|
# Protocol to use for webserver. If both of the X.509 certificate files exist,
|
||||||
# then assume that we want to enable HTTPS for the server.
|
# then assume that we want to enable HTTPS for the server.
|
||||||
if [[ $PATH_TO_HTTPS_CERT ]] || [[ $PATH_TO_HTTPS_KEY ]]; then
|
if [[ -s $PATH_TO_HTTPS_CERT ]] && [[ -s $PATH_TO_HTTPS_KEY ]]; then
|
||||||
if [[ -s $PATH_TO_HTTPS_CERT ]] && [[ -s $PATH_TO_HTTPS_KEY ]]; then
|
HTTPS=true
|
||||||
HTTPS=true
|
|
||||||
else
|
|
||||||
HTTPS=false
|
|
||||||
HTTPSFAIL="- certificate or Key doesn't exist or file is empty"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
HTTPS=false
|
HTTPS=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# create logpath if doesn't exist
|
||||||
|
if [[ ! -d $LOGPATH ]]; then
|
||||||
|
mkdir -p $LOGPATH
|
||||||
|
fi
|
||||||
|
|
||||||
function CheckUser {
|
function CheckUser {
|
||||||
|
|
||||||
# Make sure the script is ran as root
|
# Make sure the script is ran as root
|
||||||
@@ -65,13 +66,19 @@ function CheckUser {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cmdlog {
|
||||||
|
echo "=== CMD ===: $@" >> $LOGFILE
|
||||||
|
echo >> $LOGFILE
|
||||||
|
}
|
||||||
|
|
||||||
function ErrorHandling {
|
function ErrorHandling {
|
||||||
|
|
||||||
echo -e "${FAIL} Something went wrong, exiting. Check $LOGFILE for more details and use rollback feature if needed"
|
echo -e "${FAIL} Something went wrong, exiting. Check $LOGFILE for more details and use rollback feature if needed"
|
||||||
|
|
||||||
if [[ -d $INSTALLDIR/xo-builds/xen-orchestra-$TIME ]]; then
|
if [[ -d $INSTALLDIR/xo-builds/xen-orchestra-$TIME ]]; then
|
||||||
echo -e "${FAIL} Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation."
|
echo -e "${FAIL} Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation."
|
||||||
rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cmdlog "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
|
rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME >> $LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,70 +90,84 @@ function InstallDependenciesCentOS {
|
|||||||
|
|
||||||
# Install necessary dependencies for XO build
|
# Install necessary dependencies for XO build
|
||||||
|
|
||||||
#determine which python package is needed. CentOS 7 requires python, 8 is python3
|
#determine which python package is needed. CentOS 7 requires python, 8 is python3
|
||||||
if [[ $OSVERSION == "8" ]]; then
|
if [[ $OSVERSION == "8" ]]; then
|
||||||
PYTHON="python3"
|
PYTHON="python3"
|
||||||
else
|
else
|
||||||
PYTHON="python"
|
PYTHON="python"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install packages
|
# install packages
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
echo -ne "${PROGRESS} Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
||||||
yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel $PYTHON git nfs-utils cifs-utils lvm2 >/dev/null
|
cmdlog "yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel $PYTHON git nfs-utils cifs-utils lvm2"
|
||||||
echo -e "\r${OK} Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel $PYTHON git nfs-utils cifs-utils lvm2 >>$LOGFILE 2>&1
|
||||||
|
echo -e "\r${OK} Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
||||||
|
|
||||||
# only run automated node install if executable not found
|
# only run automated node install if executable not found
|
||||||
if [[ -z $(which node) ]]; then
|
cmdlog "which node"
|
||||||
|
if [[ -z $(which node 2>>$LOGFILE) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing node.js"
|
echo -ne "${PROGRESS} Installing node.js"
|
||||||
curl -s -L https://rpm.nodesource.com/setup_12.x | bash - >/dev/null
|
cmdlog "curl -s -L https://rpm.nodesource.com/setup_12.x | bash -"
|
||||||
|
curl -s -L https://rpm.nodesource.com/setup_12.x | bash - >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing node.js"
|
echo -e "\r${OK} Installing node.js"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
if [[ -z $(which yarn) ]] ; then
|
cmdlog "which yarn"
|
||||||
|
if [[ -z $(which yarn 2>>$LOGFILE) ]] ; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing yarn"
|
echo -ne "${PROGRESS} Installing yarn"
|
||||||
curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo >/dev/null && \
|
cmdlog "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn"
|
||||||
yum -y install yarn >/dev/null
|
curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo >>$LOGFILE 2>&1 && \
|
||||||
|
yum -y install yarn >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing yarn"
|
echo -e "\r${OK} Installing yarn"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install epel-release if doesn't exist
|
# only install epel-release if doesn't exist
|
||||||
if [[ -z $(rpm -q epel-release) ]] ; then
|
cmdlog "rpm -q epel-release"
|
||||||
|
if [[ -z $(rpm -q epel-release 2>>$LOGFILE) ]] ; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing epel-repo"
|
echo -ne "${PROGRESS} Installing epel-repo"
|
||||||
yum -y install epel-release >/dev/null
|
cmdlog "yum -y install epel-release"
|
||||||
|
yum -y install epel-release >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing epel-repo"
|
echo -e "\r${OK} Installing epel-repo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install libvhdi-tools if vhdimount is not present
|
# only install libvhdi-tools if vhdimount is not present
|
||||||
if [[ -z $(which vhdimount) ]] ; then
|
cmdlog "which vhdimount"
|
||||||
|
if [[ -z $(which vhdimount 2>>$LOGFILE) ]] ; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing libvhdi-tools from forensics repository"
|
echo -ne "${PROGRESS} Installing libvhdi-tools from forensics repository"
|
||||||
if [[ $OSVERSION == "7" ]]; then
|
if [[ $OSVERSION == "7" ]]; then
|
||||||
rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm >/dev/null
|
cmdlog "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm"
|
||||||
|
rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
if [[ $OSVERSION == "8" ]]; then
|
if [[ $OSVERSION == "8" ]]; then
|
||||||
rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm >/dev/null
|
cmdlog "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm"
|
||||||
|
rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo
|
cmdlog "sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo"
|
||||||
yum --enablerepo=forensics install -y libvhdi-tools >/dev/null
|
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo >>$LOGFILE 2>&1
|
||||||
|
cmdlog "yum --enablerepo=forensics install -y libvhdi-tools"
|
||||||
|
yum --enablerepo=forensics install -y libvhdi-tools >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing libvhdi-tools from forensics repository"
|
echo -e "\r${OK} Installing libvhdi-tools from forensics repository"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Enabling and starting redis service"
|
echo -ne "${PROGRESS} Enabling and starting redis service"
|
||||||
/bin/systemctl enable redis >/dev/null && /bin/systemctl start redis >/dev/null
|
cmdlog "/bin/systemctl enable redis && /bin/systemctl start redis"
|
||||||
|
/bin/systemctl enable redis >>$LOGFILE 2>&1 && /bin/systemctl start redis >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Enabling and starting redis service"
|
echo -e "\r${OK} Enabling and starting redis service"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Enabling and starting rpcbind service"
|
echo -ne "${PROGRESS} Enabling and starting rpcbind service"
|
||||||
/bin/systemctl enable rpcbind >/dev/null && /bin/systemctl start rpcbind >/dev/null
|
cmdlog "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
||||||
|
/bin/systemctl enable rpcbind >>$LOGFILE 2>&1 && /bin/systemctl start rpcbind >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Enabling and starting rpcbind service"
|
echo -e "\r${OK} Enabling and starting rpcbind service"
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function InstallDependenciesDebian {
|
function InstallDependenciesDebian {
|
||||||
|
|
||||||
@@ -158,68 +179,84 @@ function InstallDependenciesDebian {
|
|||||||
|
|
||||||
if [[ $OSVERSION =~ (16|18|20) ]]; then
|
if [[ $OSVERSION =~ (16|18|20) ]]; then
|
||||||
echo -ne "${PROGRESS} OS Ubuntu so making sure universe repository is enabled"
|
echo -ne "${PROGRESS} OS Ubuntu so making sure universe repository is enabled"
|
||||||
add-apt-repository universe >/dev/null
|
cmdlog "add-apt-repository universe"
|
||||||
|
add-apt-repository universe >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} OS Ubuntu so making sure universe repository is enabled"
|
echo -e "\r${OK} OS Ubuntu so making sure universe repository is enabled"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Running apt-get update"
|
echo -ne "${PROGRESS} Running apt-get update"
|
||||||
apt-get update >/dev/null
|
cmdlog "apt-get update"
|
||||||
|
apt-get update >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Running apt-get update"
|
echo -e "\r${OK} Running apt-get update"
|
||||||
|
|
||||||
#determine which python package is needed. Ubuntu 20 requires python2-minimal, 16 and 18 are python-minimal
|
#determine which python package is needed. Ubuntu 20 requires python2-minimal, 16 and 18 are python-minimal
|
||||||
if [[ $OSVERSION == "20" ]]; then
|
if [[ $OSVERSION == "20" ]]; then
|
||||||
PYTHON="python2-minimal"
|
PYTHON="python2-minimal"
|
||||||
else
|
else
|
||||||
PYTHON="python-minimal"
|
PYTHON="python-minimal"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install packages
|
# install packages
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing build dependencies, redis server, git, libvhdi-utils, python-minimal, lvm2, nfs-common, cifs-utils, curl"
|
echo -ne "${PROGRESS} Installing build dependencies, redis server, git, libvhdi-utils, python-minimal, lvm2, nfs-common, cifs-utils, curl"
|
||||||
apt-get install -y build-essential redis-server libpng-dev git libvhdi-utils $PYTHON lvm2 nfs-common cifs-utils curl >/dev/null
|
cmdlog "apt-get install -y build-essential redis-server libpng-dev git libvhdi-utils $PYTHON lvm2 nfs-common cifs-utils curl"
|
||||||
echo -e "\r${OK} Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common, cifs-utils, curl"
|
apt-get install -y build-essential redis-server libpng-dev git libvhdi-utils $PYTHON lvm2 nfs-common cifs-utils curl >>$LOGFILE 2>&1
|
||||||
|
echo -e "\r${OK} Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common, cifs-utils, curl"
|
||||||
|
|
||||||
# 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
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing apt-transport-https and ca-certificates packages to support https repos"
|
echo -ne "${PROGRESS} Installing apt-transport-https and ca-certificates packages to support https repos"
|
||||||
apt-get install -y apt-transport-https ca-certificates >/dev/null
|
cmdlog "apt-get install -y apt-transport-https ca-certificates"
|
||||||
|
apt-get install -y apt-transport-https ca-certificates >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing apt-transport-https and ca-certificates packages to support https repos"
|
echo -e "\r${OK} Installing apt-transport-https and ca-certificates packages to support https repos"
|
||||||
|
|
||||||
if [[ $OSVERSION == "10" ]]; then
|
if [[ $OSVERSION == "10" ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Debian 10, so installing gnupg also"
|
echo -ne "${PROGRESS} Debian 10, so installing gnupg also"
|
||||||
apt-get install gnupg -y >/dev/null
|
cmdlog "apt-get install gnupg -y"
|
||||||
|
apt-get install gnupg -y >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Debian 10, so installing gnupg also"
|
echo -e "\r${OK} Debian 10, so installing gnupg also"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install setcap for non-root port binding if missing
|
# install setcap for non-root port binding if missing
|
||||||
if [[ -z $(which setcap) ]]; then
|
cmdlog "which setcap"
|
||||||
|
if [[ -z $(which setcap 2>>$LOGFILE) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing setcap"
|
echo -ne "${PROGRESS} Installing setcap"
|
||||||
apt-get install -y libcap2-bin >/dev/null
|
cmdlog "apt-get install -y libcap2-bin"
|
||||||
|
apt-get install -y libcap2-bin >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing setcap"
|
echo -e "\r${OK} Installing setcap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
if [[ -z $(which yarn) ]]; then
|
cmdlog "which yarn"
|
||||||
|
if [[ -z $(which yarn 2>>$LOGFILE) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing yarn"
|
echo -ne "${PROGRESS} Installing yarn"
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >/dev/null
|
cmdlog "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -"
|
||||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >/dev/null
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >>$LOGFILE 2>&1
|
||||||
apt-get update >/dev/null
|
cmdlog "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list"
|
||||||
apt-get install -y yarn >/dev/null
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >>$LOGFILE 2>&1
|
||||||
|
cmdlog "apt-get update"
|
||||||
|
apt-get update >>$LOGFILE 2>&1
|
||||||
|
cmdlog "apt-get install -y yarn"
|
||||||
|
apt-get install -y yarn >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing yarn"
|
echo -e "\r${OK} Installing yarn"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# only run automated node install if executable not found
|
# only run automated node install if executable not found
|
||||||
if [[ -z $(which node) ]] || [[ -z $(which npm) ]]; then
|
cmdlog "which node"
|
||||||
|
cmdlog "which npm"
|
||||||
|
if [[ -z $(which node 2>>$LOGFILE) ]] || [[ -z $(which npm 2>>$LOGFILE) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing node.js"
|
echo -ne "${PROGRESS} Installing node.js"
|
||||||
curl -sL https://deb.nodesource.com/setup_12.x | bash - >/dev/null
|
cmdlog "curl -sL https://deb.nodesource.com/setup_12.x | bash -"
|
||||||
apt-get install -y nodejs >/dev/null
|
curl -sL https://deb.nodesource.com/setup_12.x | bash - >>$LOGFILE 2>&1
|
||||||
|
cmdlog "apt-get install -y nodejs"
|
||||||
|
apt-get install -y nodejs >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing node.js"
|
echo -e "\r${OK} Installing node.js"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -229,23 +266,27 @@ function InstallDependenciesDebian {
|
|||||||
if [[ -n $NODEV ]] && [[ $NODEV < 12 ]]; then
|
if [[ -n $NODEV ]] && [[ $NODEV < 12 ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing node.js"
|
echo -ne "${PROGRESS} Installing node.js"
|
||||||
curl -sL https://deb.nodesource.com/setup_12.x | bash - >/dev/null
|
cmdlog "curl -sL https://deb.nodesource.com/setup_12.x | bash -"
|
||||||
apt-get install -y nodejs >/dev/null
|
curl -sL https://deb.nodesource.com/setup_12.x | bash - >>$LOGFILE 2>&1
|
||||||
|
cmdlog "apt-get install -y nodejs"
|
||||||
|
apt-get install -y nodejs >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing node.js"
|
echo -e "\r${OK} Installing node.js"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Enabling and starting redis service"
|
echo -ne "${PROGRESS} Enabling and starting redis service"
|
||||||
/bin/systemctl enable redis-server >/dev/null && /bin/systemctl start redis-server >/dev/null
|
cmdlog "/bin/systemctl enable redis-server && /bin/systemctl start redis-server"
|
||||||
|
/bin/systemctl enable redis-server >>$LOGFILE 2>&1 && /bin/systemctl start redis-server >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Enabling and starting redis service"
|
echo -e "\r${OK} Enabling and starting redis service"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Enabling and starting rpcbind service"
|
echo -ne "${PROGRESS} Enabling and starting rpcbind service"
|
||||||
/bin/systemctl enable rpcbind >/dev/null && /bin/systemctl start rpcbind >/dev/null
|
cmdlog "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
||||||
|
/bin/systemctl enable rpcbind >>$LOGFILE 2>&1 && /bin/systemctl start rpcbind >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Enabling and starting rpcbind service"
|
echo -e "\r${OK} Enabling and starting rpcbind service"
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function UpdateNodeYarn {
|
function UpdateNodeYarn {
|
||||||
|
|
||||||
@@ -254,17 +295,19 @@ function UpdateNodeYarn {
|
|||||||
if [ $OSNAME == "CentOS" ]; then
|
if [ $OSNAME == "CentOS" ]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Checking updates for nodejs and yarn"
|
echo -ne "${PROGRESS} Checking updates for nodejs and yarn"
|
||||||
yum update -y nodejs yarn > /dev/null
|
cmdlog "yum update -y nodejs yarn"
|
||||||
|
yum update -y nodejs yarn >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Checking updates for nodejs and yarn"
|
echo -e "\r${OK} Checking updates for nodejs and yarn"
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Checking updates for nodejs and yarn"
|
echo -ne "${PROGRESS} Checking updates for nodejs and yarn"
|
||||||
apt-get install -y --only-upgrade nodejs yarn > /dev/null
|
cmdlog "apt-get install -y --only-upgrade nodejs yarn"
|
||||||
|
apt-get install -y --only-upgrade nodejs yarn >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Checking updates for nodejs and yarn"
|
echo -e "\r${OK} Checking updates for nodejs and yarn"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function InstallXOPlugins {
|
function InstallXOPlugins {
|
||||||
|
|
||||||
@@ -277,6 +320,7 @@ function InstallXOPlugins {
|
|||||||
if [[ "$PLUGINS" == "all" ]]; then
|
if [[ "$PLUGINS" == "all" ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Installing plugins"
|
echo -ne "${PROGRESS} Installing plugins"
|
||||||
|
cmdlog "find \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/\" -maxdepth 1 -mindepth 1 -not -name \"xo-server\" -not -name \"xo-web\" -not -name \"xo-server-cloud\" -exec ln -sn {} \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/\""
|
||||||
find "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/" -maxdepth 1 -mindepth 1 -not -name "xo-server" -not -name "xo-web" -not -name "xo-server-cloud" -exec ln -sn {} "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/" \;
|
find "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/" -maxdepth 1 -mindepth 1 -not -name "xo-server" -not -name "xo-web" -not -name "xo-server-cloud" -exec ln -sn {} "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/" \;
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
@@ -284,19 +328,21 @@ function InstallXOPlugins {
|
|||||||
local PLUGINSARRAY=($(echo "$PLUGINS" | tr ',' ' '))
|
local PLUGINSARRAY=($(echo "$PLUGINS" | tr ',' ' '))
|
||||||
for x in "${PLUGINSARRAY[@]}"; do
|
for x in "${PLUGINSARRAY[@]}"; do
|
||||||
if [[ $(find $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages -type d -name "$x") ]]; then
|
if [[ $(find $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages -type d -name "$x") ]]; then
|
||||||
ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/
|
cmdlog "ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/"
|
||||||
|
ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/ >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build >/dev/null
|
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build"
|
||||||
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Installing plugins"
|
echo -e "\r${OK} Installing plugins"
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} No plugins to install"
|
echo -e "${INFO} No plugins to install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function InstallXO {
|
function InstallXO {
|
||||||
|
|
||||||
@@ -312,7 +358,8 @@ function InstallXO {
|
|||||||
if [[ -z $(getent passwd $XOUSER) ]]; then
|
if [[ -z $(getent passwd $XOUSER) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Creating missing $XOUSER user"
|
echo -ne "${PROGRESS} Creating missing $XOUSER user"
|
||||||
useradd -s /sbin/nologin $XOUSER
|
cmdlog "useradd -s /sbin/nologin $XOUSER"
|
||||||
|
useradd -s /sbin/nologin $XOUSER >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Creating missing $XOUSER user"
|
echo -e "\r${OK} Creating missing $XOUSER user"
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
@@ -321,6 +368,7 @@ function InstallXO {
|
|||||||
# 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 -ne "${PROGRESS} Creating missing basedir to $INSTALLDIR"
|
echo -ne "${PROGRESS} Creating missing basedir to $INSTALLDIR"
|
||||||
|
cmdlog "mkdir -p \"$INSTALLDIR\""
|
||||||
mkdir -p "$INSTALLDIR"
|
mkdir -p "$INSTALLDIR"
|
||||||
echo -e "\r${OK} Creating missing basedir to $INSTALLDIR"
|
echo -e "\r${OK} Creating missing basedir to $INSTALLDIR"
|
||||||
fi
|
fi
|
||||||
@@ -328,6 +376,7 @@ function InstallXO {
|
|||||||
# Create missing xo-builds directory if doesn't exist already
|
# Create missing xo-builds directory if doesn't exist already
|
||||||
if [[ ! -d "$INSTALLDIR/xo-builds" ]]; then
|
if [[ ! -d "$INSTALLDIR/xo-builds" ]]; then
|
||||||
echo -ne "${PROGRESS} Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
echo -ne "${PROGRESS} Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
||||||
|
cmdlog "mkdir \"$INSTALLDIR/xo-builds\""
|
||||||
mkdir "$INSTALLDIR/xo-builds"
|
mkdir "$INSTALLDIR/xo-builds"
|
||||||
echo -e "\r${OK} Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
echo -e "\r${OK} Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
||||||
fi
|
fi
|
||||||
@@ -336,54 +385,75 @@ function InstallXO {
|
|||||||
echo -e "${INFO} Fetching Xen Orchestra source code"
|
echo -e "${INFO} Fetching Xen Orchestra source code"
|
||||||
echo
|
echo
|
||||||
if [[ ! -d "$XO_SRC_DIR" ]]; then
|
if [[ ! -d "$XO_SRC_DIR" ]]; then
|
||||||
|
cmdlog "mkdir -p \"$XO_SRC_DIR\""
|
||||||
mkdir -p "$XO_SRC_DIR"
|
mkdir -p "$XO_SRC_DIR"
|
||||||
git clone https://github.com/vatesfr/xen-orchestra "$XO_SRC_DIR"
|
cmdlog "git clone https://github.com/vatesfr/xen-orchestra \"$XO_SRC_DIR\""
|
||||||
|
git clone https://github.com/vatesfr/xen-orchestra "$XO_SRC_DIR" >>$LOGFILE 2>&1
|
||||||
else
|
else
|
||||||
cd "$XO_SRC_DIR"
|
cmdlog "cd \"$XO_SRC_DIR\""
|
||||||
git pull
|
cd "$XO_SRC_DIR" >>$LOGFILE 2>&1
|
||||||
cd $(dirname $0)
|
cmdlog "git pull"
|
||||||
|
git pull >>$LOGFILE 2>&1
|
||||||
|
cd $(dirname $0) >>$LOGFILE 2>&1
|
||||||
|
cmdlog "cd $(dirname $0)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deploy the latest xen-orchestra source to the new install directory.
|
# Deploy the latest xen-orchestra source to the new install directory.
|
||||||
echo
|
echo
|
||||||
echo -ne "${INFO} Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
echo -ne "${INFO} Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
cmdlog "rm -rf \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME\""
|
||||||
cp -r "$XO_SRC_DIR" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>$LOGFILE 2>&1
|
||||||
|
cmdlog "cp -r \"$XO_SRC_DIR" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME\""
|
||||||
|
cp -r "$XO_SRC_DIR" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>$LOGFILE 2>&1
|
||||||
|
|
||||||
if [[ "$BRANCH" == "release" ]]; then
|
if [[ "$BRANCH" == "release" ]]; then
|
||||||
|
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
||||||
TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Checking out latest tagged release '$TAG'"
|
echo -e "${INFO} Checking out latest tagged release '$TAG'"
|
||||||
|
|
||||||
git checkout $TAG 2> /dev/null # Suppress the detached-head message.
|
cmdlog "git checkout $TAG"
|
||||||
|
git checkout $TAG >>$LOGFILE 2>&1
|
||||||
|
cmdlog "cd $(dirname $0)"
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
elif [[ "$BRANCH" != "master" ]]; then
|
elif [[ "$BRANCH" != "master" ]]; then
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Checking out source code from branch '$BRANCH'"
|
echo -e "${INFO} Checking out source code from branch '$BRANCH'"
|
||||||
|
|
||||||
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
git checkout $BRANCH
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME >>$LOGFILE 2>&1
|
||||||
cd $(dirname $0)
|
cmdlog "git checkout $BRANCH"
|
||||||
|
git checkout $BRANCH >>$LOGFILE 2>&1
|
||||||
|
cmdlog "cd $(dirname $0)"
|
||||||
|
cd $(dirname $0) >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the new repo is any different from the currently-installed
|
# Check if the new repo is any different from the currently-installed
|
||||||
# one. If not, then skip the build and delete the repo we just cloned.
|
# one. If not, then skip the build and delete the repo we just cloned.
|
||||||
|
|
||||||
# Get the commit ID of the to-be-installed xen-orchestra.
|
# Get the commit ID of the to-be-installed xen-orchestra.
|
||||||
|
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
||||||
NEW_REPO_HASH=$(git rev-parse HEAD)
|
cmdlog "git rev-parse HEAD"
|
||||||
NEW_REPO_HASH_SHORT=$(git rev-parse --short HEAD)
|
NEW_REPO_HASH=$(git rev-parse HEAD 2>>$LOGFILE)
|
||||||
cd $(dirname $0)
|
cmdlog "git rev-parse --short HEAD"
|
||||||
|
NEW_REPO_HASH_SHORT=$(git rev-parse --short HEAD 2>>$LOGFILE)
|
||||||
|
cmdlog "cd $(dirname $0)"
|
||||||
|
cd $(dirname $0) >>$LOGFILE 2>&1
|
||||||
|
|
||||||
# Get the commit ID of the currently-installed xen-orchestra (if one
|
# Get the commit ID of the currently-installed xen-orchestra (if one
|
||||||
# exists).
|
# exists).
|
||||||
if [[ -L $INSTALLDIR/xo-server ]] && [[ -n $(readlink -e $INSTALLDIR/xo-server) ]]; then
|
if [[ -L $INSTALLDIR/xo-server ]] && [[ -n $(readlink -e $INSTALLDIR/xo-server) ]]; then
|
||||||
cd $INSTALLDIR/xo-server
|
cmdlog "cd $INSTALLDIR/xo-server"
|
||||||
OLD_REPO_HASH=$(git rev-parse HEAD)
|
cd $INSTALLDIR/xo-server >>$LOGFILE 2>&1
|
||||||
OLD_REPO_HASH_SHORT=$(git rev-parse --short HEAD)
|
cmdlog "git rev-parse HEAD"
|
||||||
cd $(dirname $0)
|
OLD_REPO_HASH=$(git rev-parse HEAD 2>>$LOGFILE)
|
||||||
|
cmdlog "git rev-parse --short HEAD"
|
||||||
|
OLD_REPO_HASH_SHORT=$(git rev-parse --short HEAD 2>>$LOGFILE)
|
||||||
|
cmdlog "cd $(dirname $0)"
|
||||||
|
cd $(dirname $0) >>$LOGFILE 2>&1
|
||||||
else
|
else
|
||||||
# If there's no existing installation, then we definitely want
|
# If there's no existing installation, then we definitely want
|
||||||
# to proceed with the bulid.
|
# to proceed with the bulid.
|
||||||
@@ -397,7 +467,8 @@ function InstallXO {
|
|||||||
echo
|
echo
|
||||||
echo -e "${INFO} No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build."
|
echo -e "${INFO} No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build."
|
||||||
echo -e "${INFO} Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
echo -e "${INFO} Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cmdlog "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
|
rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME >>$LOGFILE 2>&1
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -406,6 +477,7 @@ function InstallXO {
|
|||||||
if [[ $(pgrep -f xo-server) ]]; then
|
if [[ $(pgrep -f xo-server) ]]; then
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Shutting down xo-server"
|
echo -ne "${PROGRESS} Shutting down xo-server"
|
||||||
|
cmdlog "/bin/systemctl stop xo-server"
|
||||||
/bin/systemctl stop xo-server || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; }
|
/bin/systemctl stop xo-server || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; }
|
||||||
echo -e "\r${OK} Shutting down xo-server"
|
echo -e "\r${OK} Shutting down xo-server"
|
||||||
fi
|
fi
|
||||||
@@ -420,7 +492,8 @@ function InstallXO {
|
|||||||
echo -e "${INFO} xo-server and xo-web build quite a while. Grab a cup of coffee and lay back"
|
echo -e "${INFO} xo-server and xo-web build quite a while. Grab a cup of coffee and lay back"
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Running installation"
|
echo -ne "${PROGRESS} Running installation"
|
||||||
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build >/dev/null
|
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn && yarn build"
|
||||||
|
cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME >>$LOGFILE 2>&1 && yarn >>$LOGFILE 2>&1 && yarn build >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Running installation"
|
echo -e "\r${OK} Running installation"
|
||||||
|
|
||||||
# Install plugins
|
# Install plugins
|
||||||
@@ -428,14 +501,17 @@ function InstallXO {
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Fixing binary path in systemd service configuration file"
|
echo -e "${INFO} Fixing binary path in systemd service configuration file"
|
||||||
|
cmdlog "sed -i \"s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/bin\/xo-server#\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/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
|
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 -e "${INFO} Adding WorkingDirectory parameter to systemd service configuration file"
|
echo -e "${INFO} Adding WorkingDirectory parameter to systemd service configuration file"
|
||||||
sed -i "/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service
|
cmdlog "sed -i \"/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
||||||
|
sed -i "/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service >>$LOGFILE 2>&1
|
||||||
|
|
||||||
if [[ "$XOUSER" != "root" ]]; then
|
if [[ "$XOUSER" != "root" ]]; then
|
||||||
echo -e "${INFO} Adding user to systemd config"
|
echo -e "${INFO} Adding user to systemd config"
|
||||||
sed -i "/SyslogIdentifier=.*/a User=$XOUSER" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service
|
cmdlog "sed -i \"/SyslogIdentifier=.*/a User=$XOUSER\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
||||||
|
sed -i "/SyslogIdentifier=.*/a User=$XOUSER" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service >>$LOGFILE 2>&1
|
||||||
|
|
||||||
if [ "$PORT" -le "1024" ]; then
|
if [ "$PORT" -le "1024" ]; then
|
||||||
NODEBINARY="$(which node)"
|
NODEBINARY="$(which node)"
|
||||||
@@ -445,7 +521,8 @@ function InstallXO {
|
|||||||
|
|
||||||
if [[ -n $NODEBINARY ]]; then
|
if [[ -n $NODEBINARY ]]; then
|
||||||
echo -ne "${PROGRESS} Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
echo -ne "${PROGRESS} Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
||||||
setcap 'cap_net_bind_service=+ep' $NODEBINARY >/dev/null \
|
cmdlog "setcap 'cap_net_bind_service=+ep' $NODEBINARY"
|
||||||
|
setcap 'cap_net_bind_service=+ep' $NODEBINARY >>$LOGFILE 2>&1 \
|
||||||
&& echo -e "\r${OK} Attempting to set cap_net_bind_service permission for $NODEBINARY" || { echo -e "\r${FAIL} Attempting to set cap_net_bind_service permission for $NODEBINARY" ; echo " Non-privileged user might not be able to bind to <1024 port. xo-server won't start most likely" ; }
|
&& echo -e "\r${OK} Attempting to set cap_net_bind_service permission for $NODEBINARY" || { echo -e "\r${FAIL} Attempting to set cap_net_bind_service permission for $NODEBINARY" ; echo " Non-privileged user might not be able to bind to <1024 port. xo-server won't start most likely" ; }
|
||||||
else
|
else
|
||||||
echo -e "${FAIL} Can't find node executable, or it's a symlink to non existing file. Not trying to setcap. xo-server won't start most likely"
|
echo -e "${FAIL} Can't find node executable, or it's a symlink to non existing file. Not trying to setcap. xo-server won't start most likely"
|
||||||
@@ -458,25 +535,32 @@ function InstallXO {
|
|||||||
echo -e ${INFO} "Fixing relative path to xo-web installation in xo-server configuration file"
|
echo -e ${INFO} "Fixing relative path to xo-web installation in xo-server configuration file"
|
||||||
|
|
||||||
INSTALLDIRESC=$(echo $INSTALLDIR | sed 's/\//\\\//g')
|
INSTALLDIRESC=$(echo $INSTALLDIR | sed 's/\//\\\//g')
|
||||||
sed -i "s/#'\/any\/url' = '\/path\/to\/directory'/'\/' = '$INSTALLDIRESC\/xo-web\/dist\/'/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml
|
cmdlog "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/#'\/any\/url' = '\/path\/to\/directory'/'\/' = '$INSTALLDIRESC\/xo-web\/dist\/'/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml >>$LOGFILE 2>&1
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
if [[ $PORT != "80" ]]; then
|
if [[ $PORT != "80" ]]; then
|
||||||
echo -e "${INFO} Changing port 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.toml
|
cmdlog "sed -i \"s/port = 80/port = $PORT/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
|
sed -i "s/port = 80/port = $PORT/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml >>$LOGFILE 2>&1
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $HTTPS ; then
|
if [[ "$HTTPS" == "true" ]] ; then
|
||||||
echo -e "${INFO} Enabling HTTPS in xo-server configuration file"
|
echo -e "${INFO} Enabling HTTPS in xo-server configuration file"
|
||||||
sed -i "s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml
|
cmdlog "sed -i \"s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
sed -i "s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%" $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.toml >>$LOGFILE 2>&1
|
||||||
sed -i "s/# redirectToHttps/redirectToHttps/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml
|
cmdlog \"sed -i "s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
sleep 2
|
sed -i "s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml >>$LOGFILE 2>&1
|
||||||
fi
|
cmdlog "sed -i \"s/# redirectToHttps/redirectToHttps/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
|
sed -i "s/# redirectToHttps/redirectToHttps/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml >>$LOGFILE 2>&1
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "${INFO} Activating modified configuration file"
|
echo -e "${INFO} Activating modified configuration file"
|
||||||
|
cmdlog "mkdir -p $CONFIGPATH/.config/xo-server"
|
||||||
mkdir -p $CONFIGPATH/.config/xo-server
|
mkdir -p $CONFIGPATH/.config/xo-server
|
||||||
|
cmdlog "mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml"
|
||||||
mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml
|
mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml
|
||||||
|
|
||||||
|
|
||||||
@@ -484,41 +568,51 @@ function InstallXO {
|
|||||||
|
|
||||||
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"
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server
|
cmdlog "ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server"
|
||||||
|
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server >>$LOGFILE 2>&1
|
||||||
sleep 2
|
sleep 2
|
||||||
echo -e "${INFO} Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
echo -e "${INFO} Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
||||||
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web
|
cmdlog "ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web"
|
||||||
|
ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web >>$LOGFILE 2>&1
|
||||||
|
|
||||||
if [[ "$XOUSER" != "root" ]]; then
|
if [[ "$XOUSER" != "root" ]]; then
|
||||||
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xen-orchestra-$TIME
|
cmdlog "chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
|
chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xen-orchestra-$TIME >>$LOGFILE 2>&1
|
||||||
|
|
||||||
if [ ! -d /var/lib/xo-server ]; then
|
if [ ! -d /var/lib/xo-server ]; then
|
||||||
mkdir /var/lib/xo-server 2>/dev/null
|
cmdlog "mkdir /var/lib/xo-server"
|
||||||
|
mkdir /var/lib/xo-server >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $XOUSER:$XOUSER /var/lib/xo-server
|
cmdlog "chown -R $XOUSER:$XOUSER /var/lib/xo-server"
|
||||||
|
chown -R $XOUSER:$XOUSER /var/lib/xo-server >>$LOGFILE 2>&1
|
||||||
|
|
||||||
chown -R $XOUSER:$XOUSER $CONFIGPATH/.config/xo-server
|
ccmdlog "chown -R $XOUSER:$XOUSER $CONFIGPATH/.config/xo-server"
|
||||||
|
chown -R $XOUSER:$XOUSER $CONFIGPATH/.config/xo-server >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fix to prevent older installations to not update because systemd service is not symlinked anymore
|
# fix to prevent older installations to not update because systemd service is not symlinked anymore
|
||||||
if [[ $(find /etc/systemd/system -maxdepth 1 -type l -name "xo-server.service") ]]; then
|
if [[ $(find /etc/systemd/system -maxdepth 1 -type l -name "xo-server.service") ]]; then
|
||||||
rm -f /etc/systemd/system/xo-server.service
|
cmdlog "rm -f /etc/systemd/system/xo-server.service"
|
||||||
|
rm -f /etc/systemd/system/xo-server.service >>$LOGFILE 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Replacing systemd service configuration file"
|
echo -e "${INFO} Replacing systemd service configuration file"
|
||||||
|
|
||||||
/bin/cp -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
cmdlog "/bin/cp -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service"
|
||||||
|
/bin/cp -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service >>$LOGFILE 2>&1
|
||||||
sleep 2
|
sleep 2
|
||||||
echo -e "${INFO} Reloading systemd configuration"
|
echo -e "${INFO} Reloading systemd configuration"
|
||||||
echo
|
echo
|
||||||
/bin/systemctl daemon-reload
|
cmdlog "/bin/systemctl daemon-reload"
|
||||||
|
/bin/systemctl daemon-reload >>$LOGFILE 2>&1
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Starting xo-server..."
|
echo -e "${INFO} Starting xo-server..."
|
||||||
/bin/systemctl start xo-server >/dev/null
|
cmdlog "/bin/systemctl start xo-server"
|
||||||
|
/bin/systemctl start xo-server >>$LOGFILE 2>&1
|
||||||
|
|
||||||
# no need to exit/trap on errors anymore
|
# no need to exit/trap on errors anymore
|
||||||
set +e
|
set +e
|
||||||
@@ -537,7 +631,8 @@ function InstallXO {
|
|||||||
echo -e " ${COLOR_GREEN}Default username: admin@admin.net password: admin${COLOR_N}"
|
echo -e " ${COLOR_GREEN}Default username: admin@admin.net password: admin${COLOR_N}"
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Installation successful. Enabling xo-server to start on reboot"
|
echo -e "${INFO} Installation successful. Enabling xo-server to start on reboot"
|
||||||
/bin/systemctl enable xo-server > /dev/null
|
cmdlog "/bin/systemctl enable xo-server"
|
||||||
|
/bin/systemctl enable xo-server >>$LOGFILE 2>&1
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo -e "${FAIL} Looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
echo -e "${FAIL} Looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
||||||
@@ -545,7 +640,7 @@ function InstallXO {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
|
|
||||||
function UpdateXO {
|
function UpdateXO {
|
||||||
@@ -557,13 +652,14 @@ function UpdateXO {
|
|||||||
# remove old builds. leave as many as defined in PRESERVE variable
|
# remove old builds. leave as many as defined in PRESERVE variable
|
||||||
echo
|
echo
|
||||||
echo -ne "${PROGRESS} Removing old installations. Leaving $PRESERVE latest"
|
echo -ne "${PROGRESS} Removing old installations. Leaving $PRESERVE latest"
|
||||||
find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xen-orchestra*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -$PRESERVE | xargs -r rm -r
|
cmdlog "find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name \"xen-orchestra*\" -printf \"%T@ %p\\n\" | sort -n | cut -d' ' -f2- | head -n -$PRESERVE | 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 -$PRESERVE | xargs -r rm -r >>$LOGFILE 2>&1
|
||||||
echo -e "\r${OK} Removing old installations. Leaving $PRESERVE latest"
|
echo -e "\r${OK} Removing old installations. Leaving $PRESERVE latest"
|
||||||
else
|
else
|
||||||
echo -e "${INFO} PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup"
|
echo -e "${INFO} PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function HandleArgs {
|
function HandleArgs {
|
||||||
|
|
||||||
@@ -615,16 +711,21 @@ function RollBackInstallation {
|
|||||||
*xen-orchestra*)
|
*xen-orchestra*)
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server"
|
echo -e "${INFO} Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server"
|
||||||
ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server
|
cmdlog "ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server"
|
||||||
|
ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server >>$LOGFILE 2>&1
|
||||||
echo -e "${INFO} Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web"
|
echo -e "${INFO} Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web"
|
||||||
ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web
|
cmdlog "ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web"
|
||||||
|
ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web >>$LOGFILE 2>&1
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Replacing xo.server.service systemd configuration file"
|
echo -e "${INFO} Replacing xo.server.service systemd configuration file"
|
||||||
/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service
|
cmdlog "/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service"
|
||||||
/bin/systemctl daemon-reload
|
/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service >>$LOGFILE 2>&1
|
||||||
|
cmdlog "/bin/systemctl daemon-reload"
|
||||||
|
/bin/systemctl daemon-reload >>$LOGFILE 2>&1
|
||||||
echo
|
echo
|
||||||
echo -e "${INFO} Restarting xo-server..."
|
echo -e "${INFO} Restarting xo-server..."
|
||||||
/bin/systemctl restart xo-server
|
cmdlog "/bin/systemctl restart xo-server"
|
||||||
|
/bin/systemctl restart xo-server >>$LOGFILE 2>&1
|
||||||
echo
|
echo
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@@ -660,7 +761,7 @@ function CheckOS {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function CheckSystemd {
|
function CheckSystemd {
|
||||||
|
|
||||||
@@ -682,7 +783,6 @@ function CheckDocker {
|
|||||||
|
|
||||||
function CheckCertificate {
|
function CheckCertificate {
|
||||||
if [[ "$HTTPS" == "true" ]]; then
|
if [[ "$HTTPS" == "true" ]]; then
|
||||||
|
|
||||||
local CERT="$(openssl x509 -modulus -noout -in "$PATH_TO_HTTPS_CERT" | openssl md5)"
|
local CERT="$(openssl x509 -modulus -noout -in "$PATH_TO_HTTPS_CERT" | openssl md5)"
|
||||||
local KEY="$(openssl rsa -modulus -noout -in "$PATH_TO_HTTPS_KEY" | openssl md5)"
|
local KEY="$(openssl rsa -modulus -noout -in "$PATH_TO_HTTPS_KEY" | openssl md5)"
|
||||||
if [[ "$CERT" != "$KEY" ]]; then
|
if [[ "$CERT" != "$KEY" ]]; then
|
||||||
@@ -697,7 +797,7 @@ function CheckCertificate {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function CheckMemory {
|
function CheckMemory {
|
||||||
SYSMEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
SYSMEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||||
@@ -722,7 +822,7 @@ function PullDockerImage {
|
|||||||
echo -e "${INFO} If you want to persist xen-orchestra and redis data, use volume flags like:"
|
echo -e "${INFO} 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"
|
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"
|
||||||
|
|
||||||
} 2>$LOGFILE
|
}
|
||||||
|
|
||||||
function StartUpScreen {
|
function StartUpScreen {
|
||||||
|
|
||||||
@@ -742,7 +842,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Port: ${COLOR_WHITE}$PORT${COLOR_N}"
|
echo -e "Port: ${COLOR_WHITE}$PORT${COLOR_N}"
|
||||||
echo -e "HTTPS: ${COLOR_WHITE}${HTTPS}${COLOR_N} ${COLOR_RED}${HTTPSFAIL}${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}"
|
||||||
echo -e "Number of previous installations to preserve: ${COLOR_WHITE}$PRESERVE${COLOR_N}"
|
echo -e "Number of previous installations to preserve: ${COLOR_WHITE}$PRESERVE${COLOR_N}"
|
||||||
@@ -769,7 +868,8 @@ read -p ": " option
|
|||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
echo "Stopping xo-server..."
|
echo "Stopping xo-server..."
|
||||||
/bin/systemctl stop xo-server || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; }
|
cmdlog "/bin/systemctl stop xo-server"
|
||||||
|
/bin/systemctl stop xo-server >>$LOGFILE 2>&1 || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; }
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user