From c7a90a2de04e70f0e75f3f47a18c9464fd451918 Mon Sep 17 00:00:00 2001 From: Andreas Thienemann Date: Mon, 28 Jun 2021 22:28:41 +0200 Subject: [PATCH 1/2] Add ability to install 3rd party plugins Depending on the situation, a user might have third party plugins that are needed for their XO setup. We're using a mysql auth plugin, but github has a handful of other third party plugins. Added: config setting ADDITIONAL_PLUGINS to specify git repo URLs. Added: InstallAdditionalXOPlugins function to download/update these repos and add them to the XO source tree before building. --- sample.xo-install.cfg | 3 +++ xo-install.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/sample.xo-install.cfg b/sample.xo-install.cfg index d11acd8..42bc5fa 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -28,6 +28,9 @@ BRANCH="master" # (default) all plugins will be installed PLUGINS="all" +# Additional 3rd-party plugins to fetch +#ADDITIONAL_PLUGINS="https://github.com/user/repo.git,https://github.com/user/repo2.git" + # NodeJS and Yarn are automatically updated when running update/install. Can be disabled but not recommended (installation might fail because of too old node.js or yarn) # Note that if nodejs is updated when script's update feature is used, it might not be possible to use rollback option anymore without manually downgrading nodejs version to previous one AUTOUPDATE="true" diff --git a/xo-install.sh b/xo-install.sh index 7b1e561..6e7b060 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -368,6 +368,46 @@ function UpdateNodeYarn { fi } +function InstallAdditionalXOPlugins { + + set -euo pipefail + + trap ErrorHandling ERR INT + + if [[ -z "$ADDITIONAL_PLUGINS" ]] || [[ "$ADDITIONAL_PLUGINS" == "none" ]]; then + echo + printinfo "No additional plugins to install" + return 0 + fi + + echo + printprog "Installing additional plugins" + + local ADDITIONAL_PLUGINSARRAY=($(echo "$ADDITIONAL_PLUGINS" | tr ',' ' ')) + for x in "${ADDITIONAL_PLUGINSARRAY[@]}"; do + local PLUGIN_NAME=$(basename "$x" | rev | cut -c 5- | rev) + local PLUGIN_SRC_DIR=$(realpath -m "$XO_SRC_DIR/../$PLUGIN_NAME") + + if [[ ! -d "$PLUGIN_SRC_DIR" ]]; then + cmdlog "mkdir -p \"$PLUGIN_SRC_DIR\"" + mkdir -p "$PLUGIN_SRC_DIR" + cmdlog "git clone \"${x}\" \"$PLUGIN_SRC_DIR\"" + git clone "${x}" "$PLUGIN_SRC_DIR" >>$LOGFILE 2>&1 + else + cmdlog "cd \"$PLUGIN_SRC_DIR\"" + cd "$PLUGIN_SRC_DIR" >>$LOGFILE 2>&1 + cmdlog "git pull" + git pull >>$LOGFILE 2>&1 + cd $(dirname $0) >>$LOGFILE 2>&1 + cmdlog "cd $(dirname $0)" + fi + + cmdlog "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 + printok "Installing additional plugins" +} + function InstallXOPlugins { set -euo pipefail @@ -572,6 +612,9 @@ function InstallXO { TASK="Installation" fi + # Install additional plugins + InstallAdditionalXOPlugins + echo echo printinfo "xo-server and xo-web build takes quite a while. Grab a cup of coffee and lay back" From 9ffb104710756773bc50a1ec3b3ea7e88ed45a9b Mon Sep 17 00:00:00 2001 From: ronivay Date: Wed, 30 Jun 2021 15:55:31 +0300 Subject: [PATCH 2/2] set default value for ADDITIONAL_PLUGINS variable in xo-install.sh --- xo-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/xo-install.sh b/xo-install.sh index 6e7b060..0c0f5e4 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -27,6 +27,7 @@ PRESERVE=${PRESERVE:-"3"} XOUSER=${XOUSER:-"root"} CONFIGPATH="$(getent passwd $XOUSER | cut -d: -f6)" PLUGINS="${PLUGINS:-"none"}" +ADDITIONAL_PLUGINS="${ADDITIONAL_PLUGINS:-"none"}" REPOSITORY="${REPOSITORY:-"https://github.com/vatesfr/xen-orchestra"}" OS_CHECK="${OS_CHECK:-"true"}" ARCH_CHECK="${ARCH_CHECK:-"true"}"