From b73373c1e67152f5d0f5e443f8b631adcbf81fa1 Mon Sep 17 00:00:00 2001 From: Ben Erickson Date: Wed, 30 Mar 2022 10:47:29 -0700 Subject: [PATCH 1/3] Adding option to disable repos installation --- sample.xo-install.cfg | 5 +++++ xo-install.sh | 51 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/sample.xo-install.cfg b/sample.xo-install.cfg index 7cad78a..6fbbf4a 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -79,3 +79,8 @@ PRESERVE="3" # If set to true together with cert/key paths, defined pem key/certificate will be created if neither exists. # options: true/false #AUTOCERT="false" + +# If set to true, this will install the rpm/deb respoitories necessary for the Xen Orchestra intall. If set to false, these repositories will not be installed. +# options: true/false +# default: true +#INSTALL_REPOS="true" diff --git a/xo-install.sh b/xo-install.sh index 1ed4dda..d800429 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -41,6 +41,7 @@ PATH_TO_HTTPS_KEY="${PATH_TO_HTTPS_KEY:-""}" AUTOCERT="${AUTOCERT:-"false"}" USESUDO="${USESUDO:-"false"}" GENSUDO="${GENSUDO:-"false"}" +INSTALL_REPOS="${INSTALL_REPOS:-"true"}" # set variables not changeable in configfile TIME=$(date +%Y%m%d%H%M) @@ -196,8 +197,8 @@ function InstallDependenciesRPM { # Install necessary dependencies for XO build - # only install epel-release if doesn't exist - if [[ -z $(runcmd_stdout "rpm -qa epel-release") ]]; then + # only install epel-release if doesn't exist and user allows it to be installed + if [[ -z $(runcmd_stdout "rpm -qa epel-release") ]] && [[ "$INSTALL_REPOS" == "true" ]]; then echo printprog "Installing epel-repo" runcmd "yum -y install epel-release" @@ -214,7 +215,13 @@ function InstallDependenciesRPM { if [[ -z $(runcmd_stdout "command -v node") ]]; then echo printprog "Installing node.js" - runcmd "curl -s -L https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" + + # 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 -" + fi + + runcmd "yum install -y nodejs" printok "Installing node.js" else UpdateNodeYarn @@ -224,7 +231,13 @@ function InstallDependenciesRPM { if [[ -z $(runcmd_stdout "command -v yarn") ]]; then echo printprog "Installing yarn" - runcmd "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn" + + # only install yarn repo if user allows it to be installed + if [[ "$INSTALL_REPOS" == "true" ]]; then + runcmd "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo" + fi + + runcmd "yum -y install yarn" printok "Installing yarn" fi @@ -310,7 +323,12 @@ function InstallDependenciesDeb { if [[ -z $(runcmd_stdout "command -v node") ]] || [[ -z $(runcmd_stdout "command -v npm") ]]; then echo printprog "Installing node.js" - runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -" + + # 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 -" + fi + runcmd "apt-get install -y nodejs" printok "Installing node.js" else @@ -321,8 +339,13 @@ function InstallDependenciesDeb { if [[ -z $(runcmd_stdout "command -v yarn") ]]; then echo printprog "Installing yarn" - runcmd "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -" - runcmd "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list" + + # only install yarn repo if user allows it to be installed + if [[ "$INSTALL_REPOS" == "true" ]]; then + runcmd "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -" + runcmd "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list" + fi + runcmd "apt-get update" runcmd "apt-get install -y yarn" printok "Installing yarn" @@ -360,7 +383,12 @@ function UpdateNodeYarn { if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then echo printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" - runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" + + # only install nodejs repo if user allows it to be installed + if [[ "$INSTALL_REPOS" == "true" ]]; then + runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" + fi + runcmd "yum clean all" runcmd "yum install -y nodejs" printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" @@ -381,7 +409,12 @@ function UpdateNodeYarn { if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then echo printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" - runcmd "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -" + + # 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 -" + fi + runcmd "apt-get install -y nodejs" printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" else From 1963605fa6af3085bdaa744e8cfb406c46444c4e Mon Sep 17 00:00:00 2001 From: Ben Erickson Date: Wed, 30 Mar 2022 10:47:29 -0700 Subject: [PATCH 2/3] Adding option to disable repos installation --- xo-install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xo-install.sh b/xo-install.sh index d800429..a08211d 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -245,9 +245,13 @@ function InstallDependenciesRPM { if [[ -z $(runcmd_stdout "command -v vhdimount") ]]; then echo printprog "Installing libvhdi-tools from forensics repository" - runcmd "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm" - runcmd "sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo" - runcmd "yum --enablerepo=forensics install -y libvhdi-tools" + if [[ "$INSTALL_REPOS" == "true" ]]; then + runcmd "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm" + runcmd "sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo" + runcmd "yum --enablerepo=forensics install -y libvhdi-tools" + else + runcmd "yum install -y libvhdi-tools" + fi printok "Installing libvhdi-tools from forensics repository" fi @@ -272,7 +276,7 @@ function InstallDependenciesDeb { # Install necessary dependencies for XO build - if [[ "$OSNAME" == "Ubuntu" ]]; then + if [[ "$OSNAME" == "Ubuntu" ]] && [[ "$INSTALL_REPOS" == "true" ]]; then echo printprog "OS Ubuntu so making sure universe repository is enabled" runcmd "apt-get install -y software-properties-common" From 9d0e1e388a61387a6fb6620590ed67c885cd7bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roni=20V=C3=A4yrynen?= Date: Fri, 1 Apr 2022 13:31:29 +0300 Subject: [PATCH 3/3] skip nodejs upgrade if repo installation is disabled. update xo-install.cfg and readme --- README.md | 16 ++++++++++++++++ sample.xo-install.cfg | 4 +++- xo-install.sh | 20 ++++++++------------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8481e05..c12fe91 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,22 @@ deb: - sudo (if set in xo-install.cfg) ``` +Following repositories will be installed if needed and repository install is enabled in xo-install.cfg + +``` +rpm: +- forensics repository +- epel repository +- nodesource repository +- yarn repository + +deb: +- universe repository (ubuntu) +- nodesource repository +- yarn repository +``` + + #### Backup proxy **Proxy installation method is experimental, use at your own risk. Proxy installation from sources is not documented by Xen Orchestra team. Method used here is the outcome of trial and error.** diff --git a/sample.xo-install.cfg b/sample.xo-install.cfg index 6fbbf4a..e1d9345 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -80,7 +80,9 @@ PRESERVE="3" # options: true/false #AUTOCERT="false" -# If set to true, this will install the rpm/deb respoitories necessary for the Xen Orchestra intall. If set to false, these repositories will not be installed. +# If set to true, this will install the rpm/deb repositories necessary for the Xen Orchestra install. +# If set to false, these repositories will not be installed. Also automatic nodejs upgrade will be disabled. +# Note that installation will fail if all needed packages aren't available from configured repositories. See README for list of packages. # options: true/false # default: true #INSTALL_REPOS="true" diff --git a/xo-install.sh b/xo-install.sh index a08211d..bdbd694 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -244,7 +244,7 @@ function InstallDependenciesRPM { # only install libvhdi-tools if vhdimount is not present if [[ -z $(runcmd_stdout "command -v vhdimount") ]]; then echo - printprog "Installing libvhdi-tools from forensics repository" + printprog "Installing libvhdi-tools" if [[ "$INSTALL_REPOS" == "true" ]]; then runcmd "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm" runcmd "sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo" @@ -252,7 +252,7 @@ function InstallDependenciesRPM { else runcmd "yum install -y libvhdi-tools" fi - printok "Installing libvhdi-tools from forensics repository" + printok "Installing libvhdi-tools" fi echo @@ -384,14 +384,13 @@ function UpdateNodeYarn { local NODEV=$(runcmd_stdout "node -v 2>/dev/null| grep -Eo '[0-9.]+' | cut -d'.' -f1") if [ "$PKG_FORMAT" == "rpm" ]; then - if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then + # update node version if needed. + # skip update if repository install is disabled as we can't quarantee this actually updates anything + if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]] && [[ "$INSTALL_REPOS" == "true" ]]; then echo printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" - # only install nodejs repo if user allows it to be installed - if [[ "$INSTALL_REPOS" == "true" ]]; then - runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" - fi + runcmd "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" runcmd "yum clean all" runcmd "yum install -y nodejs" @@ -410,14 +409,11 @@ function UpdateNodeYarn { fi if [ "$PKG_FORMAT" == "deb" ]; then - if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]]; then + if [[ -n "$NODEV" ]] && [[ "$NODEV" -lt "${NODEVERSION}" ]] && [[ "$INSTALL_REPOS" == "true" ]]; then echo printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" - # 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 -" - fi + 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"