execute and log commands in single function instead of separate lines
This commit is contained in:
381
xo-install.sh
381
xo-install.sh
@@ -82,7 +82,7 @@ function CheckUser {
|
|||||||
|
|
||||||
function scriptInfo {
|
function scriptInfo {
|
||||||
|
|
||||||
SCRIPTVERSION=$(cd "$(dirname "$0")" 2>/dev/null && git rev-parse --short HEAD 2>/dev/null)
|
SCRIPTVERSION=$(runcmd_nolog "cd '$(dirname "$0")' 2>/dev/null && git rev-parse --short HEAD 2>/dev/null")
|
||||||
|
|
||||||
[ -z "$SCRIPTVERSION" ] && SCRIPTVERSION="undefined"
|
[ -z "$SCRIPTVERSION" ] && SCRIPTVERSION="undefined"
|
||||||
echo "Running script version $SCRIPTVERSION with config:" >> "$LOGFILE"
|
echo "Running script version $SCRIPTVERSION with config:" >> "$LOGFILE"
|
||||||
@@ -92,9 +92,16 @@ function scriptInfo {
|
|||||||
echo >> "$LOGFILE"
|
echo >> "$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmdlog {
|
function runcmd {
|
||||||
echo "=== CMD ===: $*" >> "$LOGFILE"
|
|
||||||
echo >> "$LOGFILE"
|
echo "+ $1" >>"$LOGFILE"
|
||||||
|
bash -c "$1" >>"$LOGFILE" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
function runcmd_nolog {
|
||||||
|
|
||||||
|
echo "+ $1" >>"$LOGFILE"
|
||||||
|
bash -c "$1" 2>>"$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function printprog {
|
function printprog {
|
||||||
@@ -124,8 +131,7 @@ function ErrorHandling {
|
|||||||
if [[ -d "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" ]]; then
|
if [[ -d "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" ]]; then
|
||||||
echo
|
echo
|
||||||
printfail "Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation."
|
printfail "Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation."
|
||||||
cmdlog "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
runcmd "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >> "$LOGFILE" 2>&1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
@@ -133,7 +139,7 @@ function ErrorHandling {
|
|||||||
|
|
||||||
function InstallDependenciesRPM {
|
function InstallDependenciesRPM {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
trap ErrorHandling ERR INT
|
trap ErrorHandling ERR INT
|
||||||
|
|
||||||
@@ -142,74 +148,60 @@ function InstallDependenciesRPM {
|
|||||||
# install packages
|
# install packages
|
||||||
echo
|
echo
|
||||||
printprog "Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
printprog "Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
||||||
cmdlog "yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python3 git nfs-utils cifs-utils lvm2"
|
runcmd "yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python3 git nfs-utils cifs-utils lvm2"
|
||||||
yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python3 git nfs-utils cifs-utils lvm2 >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing build dependencies, redis server, python, git, nfs-utils, cifs-utils"
|
printok "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
|
||||||
cmdlog "command -v node"
|
if [[ -z $(runcmd_nolog "command -v node") ]]; then
|
||||||
if [[ -z $(command -v node 2>>"$LOGFILE") ]]; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing node.js"
|
printprog "Installing node.js"
|
||||||
cmdlog "curl -s -L https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
runcmd "curl -s -L https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
||||||
curl -s -L "https://rpm.nodesource.com/setup_${NODEVERSION}.x" | bash - >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing node.js"
|
printok "Installing node.js"
|
||||||
else
|
else
|
||||||
UpdateNodeYarn
|
UpdateNodeYarn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
cmdlog "command -v yarn"
|
if [[ -z $(runcmd_nolog "command -v yarn") ]] ; then
|
||||||
if [[ -z $(command -v yarn 2>>"$LOGFILE") ]] ; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing yarn"
|
printprog "Installing yarn"
|
||||||
cmdlog "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn"
|
runcmd "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn"
|
||||||
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
|
|
||||||
printok "Installing yarn"
|
printok "Installing yarn"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install epel-release if doesn't exist
|
# only install epel-release if doesn't exist
|
||||||
cmdlog "rpm -q epel-release"
|
if [[ -z $(runcmd_nolog "rpm -q epel-release") ]] ; then
|
||||||
if [[ -z $(rpm -q epel-release 2>>"$LOGFILE") ]] ; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing epel-repo"
|
printprog "Installing epel-repo"
|
||||||
cmdlog "yum -y install epel-release"
|
runcmd "yum -y install epel-release"
|
||||||
yum -y install epel-release >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing epel-repo"
|
printok "Installing epel-repo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install libvhdi-tools if vhdimount is not present
|
# only install libvhdi-tools if vhdimount is not present
|
||||||
cmdlog "command -v vhdimount"
|
if [[ -z $(runcmd_nolog "command -v vhdimount") ]] ; then
|
||||||
if [[ -z $(command -v vhdimount 2>>"$LOGFILE") ]] ; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing libvhdi-tools from forensics repository"
|
printprog "Installing libvhdi-tools from forensics repository"
|
||||||
cmdlog "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm"
|
runcmd "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
|
runcmd "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"
|
runcmd "yum --enablerepo=forensics install -y libvhdi-tools"
|
||||||
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
|
|
||||||
printok "Installing libvhdi-tools from forensics repository"
|
printok "Installing libvhdi-tools from forensics repository"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printprog "Enabling and starting redis service"
|
printprog "Enabling and starting redis service"
|
||||||
cmdlog "/bin/systemctl enable redis && /bin/systemctl start redis"
|
runcmd "/bin/systemctl enable redis && /bin/systemctl start redis"
|
||||||
/bin/systemctl enable redis >>"$LOGFILE" 2>&1 && /bin/systemctl start redis >>"$LOGFILE" 2>&1 || false
|
|
||||||
printok "Enabling and starting redis service"
|
printok "Enabling and starting redis service"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printprog "Enabling and starting rpcbind service"
|
printprog "Enabling and starting rpcbind service"
|
||||||
cmdlog "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
runcmd "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
||||||
/bin/systemctl enable rpcbind >>"$LOGFILE" 2>&1 && /bin/systemctl start rpcbind >>"$LOGFILE" 2>&1 || false
|
|
||||||
printok "Enabling and starting rpcbind service"
|
printok "Enabling and starting rpcbind service"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallDependenciesDeb {
|
function InstallDependenciesDeb {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
trap ErrorHandling ERR INT
|
trap ErrorHandling ERR INT
|
||||||
|
|
||||||
@@ -218,15 +210,13 @@ function InstallDependenciesDeb {
|
|||||||
if [[ "$OSNAME" == "Ubuntu" ]]; then
|
if [[ "$OSNAME" == "Ubuntu" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "OS Ubuntu so making sure universe repository is enabled"
|
printprog "OS Ubuntu so making sure universe repository is enabled"
|
||||||
cmdlog "add-apt-repository -y universe"
|
runcmd "add-apt-repository -y universe"
|
||||||
add-apt-repository -y universe >>"$LOGFILE" 2>&1
|
|
||||||
printok "OS Ubuntu so making sure universe repository is enabled"
|
printok "OS Ubuntu so making sure universe repository is enabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printprog "Running apt-get update"
|
printprog "Running apt-get update"
|
||||||
cmdlog "apt-get update"
|
runcmd "apt-get update"
|
||||||
apt-get update >>"$LOGFILE" 2>&1
|
|
||||||
printok "Running apt-get update"
|
printok "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
|
||||||
@@ -239,77 +229,61 @@ function InstallDependenciesDeb {
|
|||||||
# install packages
|
# install packages
|
||||||
echo
|
echo
|
||||||
printprog "Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common, cifs-utils, curl"
|
printprog "Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common, cifs-utils, curl"
|
||||||
cmdlog "apt-get install -y build-essential redis-server libpng-dev git libvhdi-utils $PYTHON lvm2 nfs-common cifs-utils curl"
|
runcmd "apt-get install -y build-essential redis-server libpng-dev git libvhdi-utils $PYTHON 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
|
|
||||||
printok "Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common, cifs-utils, curl"
|
printok "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
|
||||||
printprog "Installing apt-transport-https and ca-certificates packages to support https repos"
|
printprog "Installing apt-transport-https and ca-certificates packages to support https repos"
|
||||||
cmdlog "apt-get install -y apt-transport-https ca-certificates"
|
runcmd "apt-get install -y apt-transport-https ca-certificates"
|
||||||
apt-get install -y apt-transport-https ca-certificates >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing apt-transport-https and ca-certificates packages to support https repos"
|
printok "Installing apt-transport-https and ca-certificates packages to support https repos"
|
||||||
|
|
||||||
if [[ "$OSNAME" == "Debian" ]] && [[ "$OSVERSION" == "10" ]]; then
|
if [[ "$OSNAME" == "Debian" ]] && [[ "$OSVERSION" == "10" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Debian 10, so installing gnupg also"
|
printprog "Debian 10, so installing gnupg also"
|
||||||
cmdlog "apt-get install gnupg -y"
|
runcmd "apt-get install gnupg -y"
|
||||||
apt-get install gnupg -y >>"$LOGFILE" 2>&1
|
|
||||||
printok "Debian 10, so installing gnupg also"
|
printok "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
|
||||||
cmdlog "command -v setcap"
|
if [[ -z $(runcmd_nolog "command -v setcap") ]]; then
|
||||||
if [[ -z $(command -v setcap 2>>"$LOGFILE") ]]; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing setcap"
|
printprog "Installing setcap"
|
||||||
cmdlog "apt-get install -y libcap2-bin"
|
runcmd "apt-get install -y libcap2-bin"
|
||||||
apt-get install -y libcap2-bin >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing setcap"
|
printok "Installing setcap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# only run automated node install if executable not found
|
# only run automated node install if executable not found
|
||||||
cmdlog "command -v node"
|
if [[ -z $(runcmd_nolog "command -v node") ]] || [[ -z $(runcmd_nolog "command -v npm") ]]; then
|
||||||
cmdlog "command -v npm"
|
|
||||||
if [[ -z $(command -v node 2>>"$LOGFILE") ]] || [[ -z $(command -v npm 2>>"$LOGFILE") ]]; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing node.js"
|
printprog "Installing node.js"
|
||||||
cmdlog "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
||||||
curl -sL "https://deb.nodesource.com/setup_${NODEVERSION}.x" | bash - >>"$LOGFILE" 2>&1
|
runcmd "apt-get install -y nodejs"
|
||||||
cmdlog "apt-get install -y nodejs"
|
|
||||||
apt-get install -y nodejs >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing node.js"
|
printok "Installing node.js"
|
||||||
else
|
else
|
||||||
UpdateNodeYarn
|
UpdateNodeYarn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
cmdlog "command -v yarn"
|
if [[ -z $(runcmd_nolog "command -v yarn") ]]; then
|
||||||
if [[ -z $(command -v yarn 2>>"$LOGFILE") ]]; then
|
|
||||||
echo
|
echo
|
||||||
printprog "Installing yarn"
|
printprog "Installing yarn"
|
||||||
cmdlog "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -"
|
runcmd "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -"
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >>"$LOGFILE" 2>&1
|
runcmd "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list"
|
||||||
cmdlog "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list"
|
runcmd "apt-get update"
|
||||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >>"$LOGFILE" 2>&1
|
runcmd "apt-get install -y yarn"
|
||||||
cmdlog "apt-get update"
|
|
||||||
apt-get update >>"$LOGFILE" 2>&1
|
|
||||||
cmdlog "apt-get install -y yarn"
|
|
||||||
apt-get install -y yarn >>"$LOGFILE" 2>&1
|
|
||||||
printok "Installing yarn"
|
printok "Installing yarn"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printprog "Enabling and starting redis service"
|
printprog "Enabling and starting redis service"
|
||||||
cmdlog "/bin/systemctl enable redis-server && /bin/systemctl start redis-server"
|
runcmd "/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 || false
|
|
||||||
printok "Enabling and starting redis service"
|
printok "Enabling and starting redis service"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printprog "Enabling and starting rpcbind service"
|
printprog "Enabling and starting rpcbind service"
|
||||||
cmdlog "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
runcmd "/bin/systemctl enable rpcbind && /bin/systemctl start rpcbind"
|
||||||
/bin/systemctl enable rpcbind >>"$LOGFILE" 2>&1 && /bin/systemctl start rpcbind >>"$LOGFILE" 2>&1 || false
|
|
||||||
printok "Enabling and starting rpcbind service"
|
printok "Enabling and starting rpcbind service"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -328,19 +302,15 @@ function UpdateNodeYarn {
|
|||||||
if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then
|
if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
||||||
cmdlog "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
||||||
curl -sL "https://rpm.nodesource.com/setup_${NODEVERSION}.x" | bash - >>"$LOGFILE" 2>&1
|
runcmd "yum clean all"
|
||||||
cmdlog "yum clean all"
|
runcmd "yum install -y nodejs"
|
||||||
yum clean all >> "$LOGFILE" 2>&1
|
|
||||||
cmdlog "yum install -y nodejs"
|
|
||||||
yum install -y nodejs >>LOGFILE 2>&1
|
|
||||||
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
||||||
else
|
else
|
||||||
if [[ "$TASK" == "Update" ]]; then
|
if [[ "$TASK" == "Update" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "node.js version already on $NODEV, checking updates"
|
printprog "node.js version already on $NODEV, checking updates"
|
||||||
cmdlog "yum update -y nodejs yarn"
|
runcmd "yum update -y nodejs yarn"
|
||||||
yum update -y nodejs yarn >>"$LOGFILE" 2>&1
|
|
||||||
printok "node.js version already on $NODEV, checking updates"
|
printok "node.js version already on $NODEV, checking updates"
|
||||||
elif [[ "$TASK" == "Installation" ]]; then
|
elif [[ "$TASK" == "Installation" ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -353,17 +323,14 @@ function UpdateNodeYarn {
|
|||||||
if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then
|
if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
||||||
cmdlog "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
|
||||||
curl -sL "https://deb.nodesource.com/setup_${NODEVERSION}.x" | bash - >>"$LOGFILE" 2>&1
|
runcmd "apt-get install -y nodejs"
|
||||||
cmdlog "apt-get install -y nodejs"
|
|
||||||
apt-get install -y nodejs >>"$LOGFILE" 2>&1
|
|
||||||
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
|
||||||
else
|
else
|
||||||
if [[ "$TASK" == "Update" ]]; then
|
if [[ "$TASK" == "Update" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "node.js version already on $NODEV, checking updates"
|
printprog "node.js version already on $NODEV, checking updates"
|
||||||
cmdlog "apt-get install -y --only-upgrade nodejs yarn"
|
runcmd "apt-get install -y --only-upgrade nodejs yarn"
|
||||||
apt-get install -y --only-upgrade nodejs yarn >>"$LOGFILE" 2>&1
|
|
||||||
printok "node.js version already on $NODEV, checking updates"
|
printok "node.js version already on $NODEV, checking updates"
|
||||||
elif [[ "$TASK" == "Installation" ]]; then
|
elif [[ "$TASK" == "Installation" ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -375,7 +342,7 @@ function UpdateNodeYarn {
|
|||||||
|
|
||||||
function InstallAdditionalXOPlugins {
|
function InstallAdditionalXOPlugins {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
trap ErrorHandling ERR INT
|
trap ErrorHandling ERR INT
|
||||||
|
|
||||||
@@ -390,32 +357,25 @@ function InstallAdditionalXOPlugins {
|
|||||||
|
|
||||||
local ADDITIONAL_PLUGINSARRAY=($(echo "$ADDITIONAL_PLUGINS" | tr ',' ' '))
|
local ADDITIONAL_PLUGINSARRAY=($(echo "$ADDITIONAL_PLUGINS" | tr ',' ' '))
|
||||||
for x in "${ADDITIONAL_PLUGINSARRAY[@]}"; do
|
for x in "${ADDITIONAL_PLUGINSARRAY[@]}"; do
|
||||||
local PLUGIN_NAME=$(basename "$x" | rev | cut -c 5- | rev)
|
local PLUGIN_NAME=$(runcmd_nolog "basename '$x' | rev | cut -c 5- | rev")
|
||||||
local PLUGIN_SRC_DIR=$(realpath -m "$XO_SRC_DIR/../$PLUGIN_NAME")
|
local PLUGIN_SRC_DIR=$(runcmd_nolog "realpath -m '$XO_SRC_DIR/../$PLUGIN_NAME'")
|
||||||
|
|
||||||
if [[ ! -d "$PLUGIN_SRC_DIR" ]]; then
|
if [[ ! -d "$PLUGIN_SRC_DIR" ]]; then
|
||||||
cmdlog "mkdir -p \"$PLUGIN_SRC_DIR\""
|
runcmd "mkdir -p \"$PLUGIN_SRC_DIR\""
|
||||||
mkdir -p "$PLUGIN_SRC_DIR"
|
runcmd "git clone \"${x}\" \"$PLUGIN_SRC_DIR\""
|
||||||
cmdlog "git clone \"${x}\" \"$PLUGIN_SRC_DIR\""
|
|
||||||
git clone "${x}" "$PLUGIN_SRC_DIR" >>"$LOGFILE" 2>&1
|
|
||||||
else
|
else
|
||||||
cmdlog "cd \"$PLUGIN_SRC_DIR\""
|
runcmd "cd \"$PLUGIN_SRC_DIR\" && git pull"
|
||||||
cd "$PLUGIN_SRC_DIR" >>"$LOGFILE" 2>&1
|
runcmd "cd $(dirname "$0")"
|
||||||
cmdlog "git pull"
|
|
||||||
git pull >>"$LOGFILE" 2>&1
|
|
||||||
cd "$(dirname "$0")" >>"$LOGFILE" 2>&1
|
|
||||||
cmdlog "cd $(dirname "$0")"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmdlog "cp -r $PLUGIN_SRC_DIR $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/"
|
runcmd "cp -r $PLUGIN_SRC_DIR $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/"
|
||||||
cp -r "$PLUGIN_SRC_DIR" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/" >>"$LOGFILE" 2>&1
|
|
||||||
done
|
done
|
||||||
printok "Fetching 3rd party plugin(s) source code"
|
printok "Fetching 3rd party plugin(s) source code"
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallXOPlugins {
|
function InstallXOPlugins {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
trap ErrorHandling ERR INT
|
trap ErrorHandling ERR INT
|
||||||
|
|
||||||
@@ -429,14 +389,13 @@ function InstallXOPlugins {
|
|||||||
printprog "Installing plugins"
|
printprog "Installing plugins"
|
||||||
|
|
||||||
if [[ "$PLUGINS" == "all" ]]; then
|
if [[ "$PLUGINS" == "all" ]]; then
|
||||||
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/\""
|
# shellcheck disable=SC1117
|
||||||
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/" \; >>"$LOGFILE" 2>&1
|
runcmd "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
|
||||||
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
|
||||||
cmdlog "ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/"
|
runcmd "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
|
||||||
@@ -447,7 +406,7 @@ function InstallXOPlugins {
|
|||||||
|
|
||||||
function InstallXO {
|
function InstallXO {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
trap ErrorHandling ERR INT
|
trap ErrorHandling ERR INT
|
||||||
|
|
||||||
@@ -457,8 +416,7 @@ function InstallXO {
|
|||||||
if [[ -z $(getent passwd "$XOUSER") ]]; then
|
if [[ -z $(getent passwd "$XOUSER") ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Creating missing $XOUSER user"
|
printprog "Creating missing $XOUSER user"
|
||||||
cmdlog "useradd -s /sbin/nologin $XOUSER"
|
runcmd "useradd -s /sbin/nologin $XOUSER -m"
|
||||||
useradd -s /sbin/nologin "$XOUSER" >>"$LOGFILE" 2>&1
|
|
||||||
printok "Creating missing $XOUSER user"
|
printok "Creating missing $XOUSER user"
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
@@ -468,8 +426,7 @@ function InstallXO {
|
|||||||
if [[ ! -d "$INSTALLDIR" ]] ; then
|
if [[ ! -d "$INSTALLDIR" ]] ; then
|
||||||
echo
|
echo
|
||||||
printprog "Creating missing basedir to $INSTALLDIR"
|
printprog "Creating missing basedir to $INSTALLDIR"
|
||||||
cmdlog "mkdir -p \"$INSTALLDIR\""
|
runcmd "mkdir -p \"$INSTALLDIR\""
|
||||||
mkdir -p "$INSTALLDIR"
|
|
||||||
printok "Creating missing basedir to $INSTALLDIR"
|
printok "Creating missing basedir to $INSTALLDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -477,83 +434,59 @@ function InstallXO {
|
|||||||
if [[ ! -d "$INSTALLDIR/xo-builds" ]]; then
|
if [[ ! -d "$INSTALLDIR/xo-builds" ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
printprog "Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
||||||
cmdlog "mkdir \"$INSTALLDIR/xo-builds\""
|
runcmd "mkdir \"$INSTALLDIR/xo-builds\""
|
||||||
mkdir "$INSTALLDIR/xo-builds"
|
|
||||||
printok "Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
printok "Creating missing xo-builds directory to $INSTALLDIR/xo-builds"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printinfo "Fetching Xen Orchestra source code"
|
printinfo "Fetching Xen Orchestra source code"
|
||||||
if [[ ! -d "$XO_SRC_DIR" ]]; then
|
if [[ ! -d "$XO_SRC_DIR" ]]; then
|
||||||
cmdlog "mkdir -p \"$XO_SRC_DIR\""
|
runcmd "mkdir -p \"$XO_SRC_DIR\""
|
||||||
mkdir -p "$XO_SRC_DIR"
|
runcmd "git clone \"${REPOSITORY}\" \"$XO_SRC_DIR\""
|
||||||
cmdlog "git clone \"${REPOSITORY}\" \"$XO_SRC_DIR\""
|
|
||||||
git clone "${REPOSITORY}" "$XO_SRC_DIR" >>"$LOGFILE" 2>&1
|
|
||||||
else
|
else
|
||||||
cmdlog "cd \"$XO_SRC_DIR\""
|
runcmd "cd \"$XO_SRC_DIR\" && git pull"
|
||||||
cd "$XO_SRC_DIR" >>"$LOGFILE" 2>&1
|
runcmd "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
|
||||||
printinfo "Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
printinfo "Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cmdlog "rm -rf \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME\""
|
runcmd "rm -rf \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME\""
|
||||||
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>"$LOGFILE" 2>&1
|
runcmd "cp -r \"$XO_SRC_DIR\" \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME\""
|
||||||
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"
|
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cd "$INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
TAG=$(runcmd_nolog "git describe --tags '$(git rev-list --tags --max-count=1)'")
|
||||||
TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printinfo "Checking out latest tagged release '$TAG'"
|
printinfo "Checking out latest tagged release '$TAG'"
|
||||||
|
|
||||||
cmdlog "git checkout $TAG"
|
runcmd "git checkout $TAG"
|
||||||
git checkout "$TAG" >>"$LOGFILE" 2>&1
|
runcmd "cd $(dirname "$0")"
|
||||||
cmdlog "cd $(dirname "$0")"
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
elif [[ "$BRANCH" != "master" ]]; then
|
elif [[ "$BRANCH" != "master" ]]; then
|
||||||
echo
|
echo
|
||||||
printinfo "Checking out source code from branch '$BRANCH'"
|
printinfo "Checking out source code from branch '$BRANCH'"
|
||||||
|
|
||||||
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cd "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>"$LOGFILE" 2>&1
|
runcmd "git checkout $BRANCH"
|
||||||
cmdlog "git checkout $BRANCH"
|
runcmd "cd $(dirname "$0")"
|
||||||
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"
|
# runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cd "$INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
NEW_REPO_HASH=$(runcmd_nolog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && git rev-parse HEAD")
|
||||||
cmdlog "git rev-parse HEAD"
|
NEW_REPO_HASH_SHORT=$(runcmd_nolog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && git rev-parse --short HEAD")
|
||||||
NEW_REPO_HASH=$(git rev-parse HEAD 2>>"$LOGFILE")
|
runcmd "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
|
||||||
cmdlog "cd $INSTALLDIR/xo-server"
|
OLD_REPO_HASH=$(runcmd_nolog "cd $INSTALLDIR/xo-server && git rev-parse HEAD")
|
||||||
cd "$INSTALLDIR/xo-server" >>"$LOGFILE" 2>&1
|
OLD_REPO_HASH_SHORT=$(runcmd_nolog "cd $INSTALLDIR/xo-server && git rev-parse --short HEAD")
|
||||||
cmdlog "git rev-parse HEAD"
|
runcmd "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.
|
||||||
@@ -575,16 +508,14 @@ function InstallXO {
|
|||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cmdlog "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
runcmd "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>"$LOGFILE" 2>&1
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
printinfo "No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build."
|
printinfo "No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build."
|
||||||
printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
cmdlog "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
runcmd "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
||||||
rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" >>"$LOGFILE" 2>&1
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -594,7 +525,6 @@ function InstallXO {
|
|||||||
if [[ $(pgrep -f xo-server) ]]; then
|
if [[ $(pgrep -f xo-server) ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Shutting down xo-server"
|
printprog "Shutting down xo-server"
|
||||||
cmdlog "/bin/systemctl stop xo-server"
|
|
||||||
/bin/systemctl stop xo-server || { printfail "failed to stop service, exiting..." ; exit 1; }
|
/bin/systemctl stop xo-server || { printfail "failed to stop service, exiting..." ; exit 1; }
|
||||||
printok "Shutting down xo-server"
|
printok "Shutting down xo-server"
|
||||||
fi
|
fi
|
||||||
@@ -622,8 +552,7 @@ function InstallXO {
|
|||||||
printinfo "xo-server and xo-web build takes quite a while. Grab a cup of coffee and lay back"
|
printinfo "xo-server and xo-web build takes quite a while. Grab a cup of coffee and lay back"
|
||||||
echo
|
echo
|
||||||
printprog "Running installation"
|
printprog "Running installation"
|
||||||
cmdlog "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn && yarn build"
|
runcmd "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 || false
|
|
||||||
printok "Running installation"
|
printok "Running installation"
|
||||||
|
|
||||||
# Install plugins
|
# Install plugins
|
||||||
@@ -632,33 +561,26 @@ function InstallXO {
|
|||||||
echo
|
echo
|
||||||
printinfo "Fixing binary path in systemd service configuration file"
|
printinfo "Fixing binary path in systemd service configuration file"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog "sed -i \"s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/dist\/cli.mjs#\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
runcmd "sed -i \"s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/dist\/cli.mjs#\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
sed -i "s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/dist\/cli.mjs#" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
|
||||||
printinfo "Adding WorkingDirectory parameter to systemd service configuration file"
|
printinfo "Adding WorkingDirectory parameter to systemd service configuration file"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog "sed -i \"/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
runcmd "sed -i \"/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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
|
||||||
printinfo "Adding user to systemd config"
|
printinfo "Adding user to systemd config"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog "sed -i \"/SyslogIdentifier=.*/a User=$XOUSER\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
runcmd "sed -i \"/SyslogIdentifier=.*/a User=$XOUSER\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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="$(command -v node)"
|
NODEBINARY=$(runcmd_nolog "command -v node")
|
||||||
if [[ -L "$NODEBINARY" ]]; then
|
if [[ -L "$NODEBINARY" ]]; then
|
||||||
NODEBINARY=$(readlink -e "$NODEBINARY")
|
NODEBINARY=$(runcmd_nolog "readlink -e $NODEBINARY")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$NODEBINARY" ]]; then
|
if [[ -n "$NODEBINARY" ]]; then
|
||||||
printprog "Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
printprog "Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
||||||
cmdlog "setcap 'cap_net_bind_service=+ep' $NODEBINARY"
|
runcmd "setcap 'cap_net_bind_service=+ep' $NODEBINARY" && printok "Attempting to set cap_net_bind_service permission for $NODEBINARY" \
|
||||||
setcap 'cap_net_bind_service=+ep' "$NODEBINARY" >>"$LOGFILE" 2>&1 \
|
|| { printfail "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" ; }
|
||||||
&& printok " Attempting to set cap_net_bind_service permission for $NODEBINARY" || { printfail "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
|
||||||
printfail "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"
|
printfail "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"
|
||||||
fi
|
fi
|
||||||
@@ -671,93 +593,71 @@ function InstallXO {
|
|||||||
|
|
||||||
INSTALLDIRESC=$(echo "$INSTALLDIR" | sed 's/\//\\\//g')
|
INSTALLDIRESC=$(echo "$INSTALLDIR" | sed 's/\//\\\//g')
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
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"
|
runcmd "sed -i \"s/#'\/any\/url' = '\/path\/to\/directory'/'\/' = '$INSTALLDIRESC\/xo-web\/dist\/'/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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
|
||||||
printinfo "Changing port in xo-server configuration file"
|
printinfo "Changing port in xo-server configuration file"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog "sed -i \"s/port = 80/port = $PORT/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
runcmd "sed -i \"s/port = 80/port = $PORT/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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" == "true" ]] ; then
|
if [[ "$HTTPS" == "true" ]] ; then
|
||||||
printinfo "Enabling HTTPS in xo-server configuration file"
|
printinfo "Enabling HTTPS in xo-server configuration file"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog "sed -i \"s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
runcmd "sed -i \"s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
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
|
runcmd "sed -i \"s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cmdlog \"sed -i "s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
runcmd "sed -i \"s/# redirectToHttps/redirectToHttps/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
cmdlog "sed -i \"s/# redirectToHttps/redirectToHttps/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
sed -i "s/# redirectToHttps/redirectToHttps/" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml" >>"$LOGFILE" 2>&1
|
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printinfo "Activating modified configuration file"
|
printinfo "Activating modified configuration file"
|
||||||
cmdlog "mkdir -p $CONFIGPATH/.config/xo-server"
|
runcmd "mkdir -p $CONFIGPATH/.config/xo-server"
|
||||||
mkdir -p "$CONFIGPATH/.config/xo-server"
|
runcmd "mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml"
|
||||||
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"
|
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printinfo "Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server"
|
printinfo "Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server"
|
||||||
cmdlog "ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server"
|
runcmd "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
|
||||||
printinfo "Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
printinfo "Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web"
|
||||||
cmdlog "ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web"
|
runcmd "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
|
||||||
cmdlog "chown -R $XOUSER:$XOUSER $INSTALLDIR/xo-builds/xen-orchestra-$TIME"
|
runcmd "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
|
||||||
cmdlog "mkdir /var/lib/xo-server"
|
runcmd "mkdir /var/lib/xo-server"
|
||||||
mkdir /var/lib/xo-server >>"$LOGFILE" 2>&1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmdlog "chown -R $XOUSER:$XOUSER /var/lib/xo-server"
|
runcmd "chown -R $XOUSER:$XOUSER /var/lib/xo-server"
|
||||||
chown -R "$XOUSER:$XOUSER" /var/lib/xo-server >>"$LOGFILE" 2>&1
|
|
||||||
|
|
||||||
cmdlog "chown -R $XOUSER:$XOUSER $CONFIGPATH/.config/xo-server"
|
runcmd "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
|
||||||
cmdlog "rm -f /etc/systemd/system/xo-server.service"
|
runcmd "rm -f /etc/systemd/system/xo-server.service"
|
||||||
rm -f /etc/systemd/system/xo-server.service >>"$LOGFILE" 2>&1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printinfo "Replacing systemd service configuration file"
|
printinfo "Replacing systemd service configuration file"
|
||||||
|
|
||||||
cmdlog "/bin/cp -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service"
|
runcmd "/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
|
||||||
printinfo "Reloading systemd configuration"
|
printinfo "Reloading systemd configuration"
|
||||||
echo
|
echo
|
||||||
cmdlog "/bin/systemctl daemon-reload"
|
runcmd "/bin/systemctl daemon-reload"
|
||||||
/bin/systemctl daemon-reload >>"$LOGFILE" 2>&1
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
echo
|
echo
|
||||||
printinfo "Starting xo-server..."
|
printinfo "Starting xo-server..."
|
||||||
cmdlog "/bin/systemctl start xo-server"
|
runcmd "/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 +eo pipefail
|
set +eo pipefail
|
||||||
@@ -766,12 +666,12 @@ function InstallXO {
|
|||||||
count=0
|
count=0
|
||||||
limit=6
|
limit=6
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | grep "https\{0,1\}:\/\/.*:$PORT")"
|
servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | grep "Web server listening on https\{0,1\}:\/\/.*:$PORT")"
|
||||||
while [[ -z "$servicestatus" ]] && [[ "$count" -lt "$limit" ]]; do
|
while [[ -z "$servicestatus" ]] && [[ "$count" -lt "$limit" ]]; do
|
||||||
echo " waiting for port to be open"
|
echo " waiting for port to be open"
|
||||||
sleep 10
|
sleep 10
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | grep "https\{0,1\}:\/\/.*:$PORT")"
|
servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | grep "Web server listening on https\{0,1\}:\/\/.*:$PORT")"
|
||||||
(( count++ ))
|
(( count++ ))
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -785,9 +685,8 @@ function InstallXO {
|
|||||||
printinfo "$TASK successful. Enabling xo-server service to start on reboot"
|
printinfo "$TASK successful. Enabling xo-server service to start on reboot"
|
||||||
echo "" >> "$LOGFILE"
|
echo "" >> "$LOGFILE"
|
||||||
echo "$TASK succesful" >> "$LOGFILE"
|
echo "$TASK succesful" >> "$LOGFILE"
|
||||||
cmdlog "/bin/systemctl enable xo-server"
|
runcmd "/bin/systemctl enable xo-server"
|
||||||
echo
|
echo
|
||||||
/bin/systemctl enable xo-server >>"$LOGFILE" 2>&1
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
printfail "$TASK completed, but looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
printfail "$TASK completed, but looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
||||||
@@ -809,7 +708,7 @@ function UpdateXO {
|
|||||||
|
|
||||||
InstallXO
|
InstallXO
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
if [[ "$PRESERVE" == "0" ]]; then
|
if [[ "$PRESERVE" == "0" ]]; then
|
||||||
printinfo "PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup"
|
printinfo "PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup"
|
||||||
@@ -819,9 +718,7 @@ 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
|
||||||
printprog "Removing old installations. Leaving $PRESERVE latest"
|
printprog "Removing old installations. Leaving $PRESERVE latest"
|
||||||
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"
|
runcmd "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"
|
||||||
# shellcheck disable=SC1117
|
|
||||||
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
|
|
||||||
printok "Removing old installations. Leaving $PRESERVE latest"
|
printok "Removing old installations. Leaving $PRESERVE latest"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -905,9 +802,9 @@ function HandleArgs {
|
|||||||
|
|
||||||
function RollBackInstallation {
|
function RollBackInstallation {
|
||||||
|
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
INSTALLATIONS=($(find "$INSTALLDIR/xo-builds/" -maxdepth 1 -type d -name "xen-orchestra-*" 2>/dev/null))
|
INSTALLATIONS=($(runcmd_nolog "find '$INSTALLDIR/xo-builds/' -maxdepth 1 -type d -name 'xen-orchestra-*'"))
|
||||||
|
|
||||||
if [[ ${#INSTALLATIONS[@]} -le 1 ]]; then
|
if [[ ${#INSTALLATIONS[@]} -le 1 ]]; then
|
||||||
printinfo "One or less installations exist, nothing to change"
|
printinfo "One or less installations exist, nothing to change"
|
||||||
@@ -922,21 +819,16 @@ function RollBackInstallation {
|
|||||||
*xen-orchestra*)
|
*xen-orchestra*)
|
||||||
echo
|
echo
|
||||||
printinfo "Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server"
|
printinfo "Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server"
|
||||||
cmdlog "ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server"
|
runcmd "ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server"
|
||||||
ln -sfn "$INSTALLATION/packages/xo-server" "$INSTALLDIR/xo-server" >>"$LOGFILE" 2>&1
|
|
||||||
printinfo "Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web"
|
printinfo "Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web"
|
||||||
cmdlog "ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web"
|
runcmd "ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web"
|
||||||
ln -sfn "$INSTALLATION/packages/xo-web" "$INSTALLDIR/xo-web" >>"$LOGFILE" 2>&1
|
|
||||||
echo
|
echo
|
||||||
printinfo "Replacing xo.server.service systemd configuration file"
|
printinfo "Replacing xo.server.service systemd configuration file"
|
||||||
cmdlog "/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service"
|
runcmd "/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service"
|
||||||
/bin/cp -f "$INSTALLATION/packages/xo-server/xo-server.service" /etc/systemd/system/xo-server.service >>"$LOGFILE" 2>&1
|
runcmd "/bin/systemctl daemon-reload"
|
||||||
cmdlog "/bin/systemctl daemon-reload"
|
|
||||||
/bin/systemctl daemon-reload >>"$LOGFILE" 2>&1
|
|
||||||
echo
|
echo
|
||||||
printinfo "Restarting xo-server..."
|
printinfo "Restarting xo-server..."
|
||||||
cmdlog "/bin/systemctl restart xo-server"
|
runcmd "/bin/systemctl restart xo-server"
|
||||||
/bin/systemctl restart xo-server >>"$LOGFILE" 2>&1
|
|
||||||
echo
|
echo
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@@ -950,16 +842,14 @@ function RollBackInstallation {
|
|||||||
|
|
||||||
function CheckOS {
|
function CheckOS {
|
||||||
|
|
||||||
OSVERSION=$(grep ^VERSION_ID /etc/os-release | cut -d'=' -f2 | grep -Eo "[0-9]{1,2}" | head -1)
|
OSVERSION=$(runcmd_nolog "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=$(runcmd_nolog "grep ^NAME /etc/os-release | cut -d'=' -f2 | sed 's/\"//g' | awk '{print \$1}'")
|
||||||
|
|
||||||
cmdlog "command -v yum"
|
if [[ $(runcmd_nolog "command -v yum") ]]; then
|
||||||
if [[ $(command -v yum 2>>"$LOGFILE") ]]; then
|
|
||||||
PKG_FORMAT="rpm"
|
PKG_FORMAT="rpm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmdlog "command -v apt-get"
|
if [[ $(runcmd_nolog "command -v apt-get") ]]; then
|
||||||
if [[ $(command -v apt-get 2>>"$LOGFILE") ]]; then
|
|
||||||
PKG_FORMAT="deb"
|
PKG_FORMAT="deb"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1007,8 +897,7 @@ function CheckOS {
|
|||||||
|
|
||||||
function CheckXE {
|
function CheckXE {
|
||||||
|
|
||||||
cmdlog "command -v xe"
|
if [[ $(runcmd_nolog "command -v xe") ]]; then
|
||||||
if [[ $(command -v xe 2>>"$LOGFILE") ]]; then
|
|
||||||
printfail "xe binary found, don't try to run install on xcp-ng/xenserver host. use xo-appliance.sh instead"
|
printfail "xe binary found, don't try to run install on xcp-ng/xenserver host. use xo-appliance.sh instead"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -1053,7 +942,7 @@ function CheckCertificate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CheckMemory {
|
function CheckMemory {
|
||||||
SYSMEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
SYSMEM=$(runcmd_nolog "grep MemTotal /proc/meminfo | awk '{print \$2}'")
|
||||||
|
|
||||||
if [[ "$SYSMEM" -lt 3000000 ]]; then
|
if [[ "$SYSMEM" -lt 3000000 ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -1076,7 +965,7 @@ function CheckMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CheckDiskFree {
|
function CheckDiskFree {
|
||||||
FREEDISK="$(df -P -k "${INSTALLDIR%/*}" | tail -1 | awk '{print $4}')"
|
FREEDISK=$(runcmd_nolog "df -P -k '${INSTALLDIR%/*}' | tail -1 | awk '{print \$4}'")
|
||||||
|
|
||||||
if [[ "$FREEDISK" -lt 1048576 ]]; then
|
if [[ "$FREEDISK" -lt 1048576 ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -1142,8 +1031,8 @@ read -r -p ": " option
|
|||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
echo "Stopping xo-server..."
|
echo "Stopping xo-server..."
|
||||||
cmdlog "/bin/systemctl stop xo-server"
|
runcmd "/bin/systemctl stop xo-server" \
|
||||||
/bin/systemctl stop xo-server >>"$LOGFILE" 2>&1 || { printfail "failed to stop service, exiting..." ; exit 1; }
|
|| { printfail "failed to stop service, exiting..." ; exit 1; }
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user