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 7cad78a..e1d9345 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -79,3 +79,10 @@ 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 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 1ed4dda..bdbd694 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,18 +231,28 @@ 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 # 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" - 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" - printok "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" + runcmd "yum --enablerepo=forensics install -y libvhdi-tools" + else + runcmd "yum install -y libvhdi-tools" + fi + printok "Installing libvhdi-tools" fi echo @@ -259,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" @@ -310,7 +327,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 +343,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" @@ -357,10 +384,14 @@ 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" + 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" @@ -378,10 +409,12 @@ 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" + 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