Skip to content

Commit

Permalink
Merge branch 'ronivay:master' into add_patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ixs authored Jan 23, 2024
2 parents aff8362 + 98eebc8 commit 75da652
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![](https://img.shields.io/endpoint?url=https://xo-image.yawn.fi/downloads/status.json)](https://xo-image.yawn.fi/downloads/image.txt)

[![](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions?query=workflow%3Axo-install) [![](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions?query=workflow%3Alint)
[![](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions/workflows/main.yml/badge.svg)](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions?query=workflow%3Axo-install) [![](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions/workflows/lint.yml/badge.svg)](https://github.com/ronivay/XenOrchestraInstallerUpdater/actions?query=workflow%3Alint)

Script to install/update [Xen Orchestra](https://xen-orchestra.com/#!/) and all of it's dependencies on multiple different Linux distributions. Separate script to be used on XenServer/XCP-ng host that installs a readymade VM image that has Xen Orchestra installed utilizing the same installer script.

Expand Down Expand Up @@ -42,11 +42,11 @@ Supported Linux distributions and versions:
- AlmaLinux 8
- Rocky Linux 9
- Rocky Linux 8
- Debian 12
- Debian 11
- Debian 10
- Ubuntu 22.04
- Ubuntu 20.04
- Ubuntu 18.04

Only x86_64 architecture is supported. For all those raspberry pi users out there, check [container](https://hub.docker.com/r/ronivay/xen-orchestra) instead.

Expand Down Expand Up @@ -217,7 +217,7 @@ xo user has full sudo access. Xen Orchestra updates etc should be ran with sudo.

This image is updated weekly. Latest build date and MD5/SHA256 checksum can be checked from [here](https://xo-image.yawn.fi/downloads/image.txt)

Built and tested on XCP-ng 7.x
Built and tested on XCP-ng 8.x

### Tests and VM image

Expand All @@ -228,3 +228,9 @@ VM image is also built totally by me and distributed from webservers i maintain.
### Contributing

Pull requests and issues (either real issues or just suggestions) are more than welcome. Note that i do not wish to make any modifications to Xen Orchestra source code as part of this script.

### Support

If you find this project useful and want to support the development by covering some of the hosting costs that come from maintaining an XCP-ng server in a data center, use paypal donation link below.

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?business=LCX7UV7LUGNY6&no_recurring=0&currency_code=EUR)
9 changes: 9 additions & 0 deletions sample.xo-install.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ PLUGINS="all"
# options: true/false
AUTOUPDATE="true"

# yarn cache can consume a lot of disk space over time. Setting this to true will clear cache after update.
# this can have a negative impact on how long update will take with slower internet connections
# options: true/false
#YARN_CACHE_CLEANUP="false"

# enable/disable OS check. Installation refuses to run on any other than supported OS versions if this is enabled. Can be disabled for experimental purposes.
# options: true/false
OS_CHECK="true"
Expand Down Expand Up @@ -115,3 +120,7 @@ PRESERVE="3"
# supported protocols are udp and tcp
# example: tcp://syslog.company.lan:514
#SYSLOG_TARGET=""

# Configurable network-timeout setting for yarn, in ms.
# default: 300000 = 300sec
#YARN_NETWORK_TIMEOUT="300000"
60 changes: 45 additions & 15 deletions xo-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ USESUDO="${USESUDO:-"false"}"
GENSUDO="${GENSUDO:-"false"}"
INSTALL_REPOS="${INSTALL_REPOS:-"true"}"
SYSLOG_TARGET="${SYSLOG_TARGET:-""}"
YARN_CACHE_CLEANUP="${YARN_CACHE_CLEANUP:-"false"}"
YARN_NETWORK_TIMEOUT="${YARN_NETWORK_TIMEOUT:-"300000"}"

# set variables not changeable in configfile
TIME=$(date +%Y%m%d%H%M)
Expand Down Expand Up @@ -217,6 +219,9 @@ function InstallDependenciesRPM {
# only install nodejs repo if user allows it to be installed
if [[ "$INSTALL_REPOS" == "true" ]]; then
runcmd "curl -s -L https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
# enable these once https://github.com/ronivay/XenOrchestraInstallerUpdater/issues/200 is resolved
#runcmd "yum install https://rpm.nodesource.com/pub_${NODEVERSION}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y"
#runcmd "yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1"
fi

runcmd "yum install -y nodejs"
Expand Down Expand Up @@ -299,11 +304,11 @@ function InstallDependenciesDeb {
runcmd "apt-get install -y apt-transport-https ca-certificates"
printok "Installing apt-transport-https and ca-certificates packages to support https repos"

if [[ "$OSNAME" == "Debian" ]] && [[ "$OSVERSION" =~ ^(10|11)$ ]]; then
if [[ "$OSNAME" == "Debian" ]] && [[ "$OSVERSION" =~ ^(10|11|12)$ ]]; then
echo
printprog "Debian 10/11, so installing gnupg also"
printprog "Debian 10/11/12, so installing gnupg also"
runcmd "apt-get install gnupg -y"
printok "Debian 10/11, so installing gnupg also"
printok "Debian 10/11/12, so installing gnupg also"
fi

# install setcap for non-root port binding if missing
Expand All @@ -321,7 +326,10 @@ function InstallDependenciesDeb {

# only install nodejs repo if user allows it to be installed
if [[ "$INSTALL_REPOS" == "true" ]]; then
runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
runcmd "mkdir -p /usr/share/keyrings"
runcmd "curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --batch --yes --dearmor -o /usr/share/keyrings/nodesource.gpg"
runcmd "echo \"deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODEVERSION}.x nodistro main\" > /etc/apt/sources.list.d/nodesource.list"
runcmd "apt-get update"
fi

runcmd "apt-get install -y nodejs"
Expand Down Expand Up @@ -370,6 +378,21 @@ function UpdateNodeYarn {
return 0
fi

if [[ "$INSTALL_REPOS" == "true" ]]; then
printinfo "Installing nodesource repository"
# enable these once https://github.com/ronivay/XenOrchestraInstallerUpdater/issues/200 is resolved
#if [ "$PKG_FORMAT" == "rpm" ]; then
# runcmd "yum install https://rpm.nodesource.com/pub_${NODEVERSION}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y"
# runcmd "yum clean all"
#fi
if [ "$PKG_FORMAT" == "deb" ]; then
runcmd "mkdir -p /usr/share/keyrings"
runcmd "curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --batch --yes --dearmor -o /usr/share/keyrings/nodesource.gpg"
runcmd "echo \"deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODEVERSION}.x nodistro main\" > /etc/apt/sources.list.d/nodesource.list"
runcmd "apt-get update"
fi
fi

echo
printinfo "Checking current node.js version"
local NODEV=$(runcmd_stdout "node -v 2>/dev/null| grep -Eo '[0-9.]+' | cut -d'.' -f1")
Expand All @@ -381,9 +404,10 @@ function UpdateNodeYarn {
echo
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"

# remove following two lines once https://github.com/ronivay/XenOrchestraInstallerUpdater/issues/200 is resolved
runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"

runcmd "yum clean all"

runcmd "yum install -y nodejs"
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
else
Expand All @@ -404,8 +428,6 @@ function UpdateNodeYarn {
echo
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"

runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"

runcmd "apt-get install -y nodejs"
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
else
Expand Down Expand Up @@ -523,7 +545,7 @@ function InstallSudo {
echo
printinfo "Generating sudoers configuration to $SUDOERSFILE"
TMPSUDOERS="$(mktemp /tmp/xo-sudoers.XXXXXX)"
runcmd "echo '$XOUSER ALL=(root) NOPASSWD: /bin/mount, /bin/umount' > '$TMPSUDOERS'"
runcmd "echo '$XOUSER ALL=(root) NOPASSWD: /bin/mount, /bin/umount, /bin/findmnt' > '$TMPSUDOERS'"
if runcmd "visudo -cf $TMPSUDOERS"; then
runcmd "mv $TMPSUDOERS $SUDOERSFILE"
else
Expand Down Expand Up @@ -709,7 +731,7 @@ function InstallXO {
printinfo "xo-server and xo-web build takes quite a while. Grab a cup of coffee and lay back"
echo
printprog "Running installation"
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn && yarn build"
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn --network-timeout ${YARN_NETWORK_TIMEOUT} && yarn --network-timeout ${YARN_NETWORK_TIMEOUT} build"
printok "Running installation"

# Install plugins (takes care of 3rd party plugins as well)
Expand Down Expand Up @@ -823,7 +845,7 @@ function InstallXO {
printinfo "Changing default mountsDir in xo-server configuration file"
runcmd "sed -i \"s%#mountsDir.*%mountsDir = '$INSTALLDIR/mounts'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
runcmd "mkdir -p $INSTALLDIR/mounts"
runcmd "chown -R $XOUSER:$XOUSER $INSTALLDIR/mounts"
runcmd "chown $XOUSER:$XOUSER $INSTALLDIR/mounts"
fi

if [[ -n "$SYSLOG_TARGET" ]]; then
Expand Down Expand Up @@ -972,6 +994,14 @@ function UpdateXO {
done
printok "Removing old inactive installations after update. Leaving $PRESERVE latest"
echo

# clear yarn cache if defined in configuration
if [[ "$YARN_CACHE_CLEANUP" == "true" ]]; then
printprog "Cleaning yarn cache"
runcmd "yarn cache clean"
printok "Cleaning yarn cache"
echo
fi
}

function InstallXOProxy {
Expand All @@ -984,7 +1014,7 @@ function InstallXOProxy {
printinfo "xo-proxy build takes quite a while. Grab a cup of coffee and lay back"
echo
printprog "Running installation"
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn && yarn build"
runcmd "cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn --network-timeout ${YARN_NETWORK_TIMEOUT} && yarn --network-timeout ${YARN_NETWORK_TIMEOUT} build"
printok "Running installation"

# shutdown possibly running xo-server
Expand Down Expand Up @@ -1307,13 +1337,13 @@ function CheckOS {
exit 1
fi

if [[ "$OSNAME" == "Debian" ]] && [[ ! "$OSVERSION" =~ ^(10|11)$ ]]; then
printfail "Only Debian 10/11 supported"
if [[ "$OSNAME" == "Debian" ]] && [[ ! "$OSVERSION" =~ ^(10|11|12)$ ]]; then
printfail "Only Debian 10/11/12 supported"
exit 1
fi

if [[ "$OSNAME" == "Ubuntu" ]] && [[ ! "$OSVERSION" =~ ^(18|20|22)$ ]]; then
printfail "Only Ubuntu 18/20/22 supported"
if [[ "$OSNAME" == "Ubuntu" ]] && [[ ! "$OSVERSION" =~ ^(20|22)$ ]]; then
printfail "Only Ubuntu 20/22 supported"
exit 1
fi

Expand Down

0 comments on commit 75da652

Please sign in to comment.