From 58508eaddf0f9911d0d1a5fb8c7796b4ee3fb3eb Mon Sep 17 00:00:00 2001 From: Vladyslav Zhukovskyi Date: Sun, 6 Feb 2022 14:35:59 +0200 Subject: [PATCH] Add script for configuration provision Signed-off-by: Vladyslav Zhukovskyi --- Dockerfile | 3 +- static/config/options/colors.scheme.xml | 5 - static/config/options/ide.general.xml | 7 -- static/config/options/laf.xml | 5 - static/config/options/other.xml | 7 -- static/config/options/path.macros.xml | 6 - static/config/options/ui.lnf.xml | 5 - static/config/options/updates.xml | 5 - static/default-configuration-provider.sh | 137 +++++++++++++++++++++++ static/ide-projector-launcher.sh | 19 +--- 10 files changed, 139 insertions(+), 60 deletions(-) delete mode 100644 static/config/options/colors.scheme.xml delete mode 100644 static/config/options/ide.general.xml delete mode 100644 static/config/options/laf.xml delete mode 100644 static/config/options/other.xml delete mode 100644 static/config/options/path.macros.xml delete mode 100644 static/config/options/ui.lnf.xml delete mode 100644 static/config/options/updates.xml create mode 100755 static/default-configuration-provider.sh diff --git a/Dockerfile b/Dockerfile index d664f444..b41a9286 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,8 +77,7 @@ RUN tar -xf asset-static-assembly.tar.gz && rm asset-static-assembly.tar.gz && \ chown -R 0:0 static && \ mv static/* . && rm -rf static && \ chmod +x *.sh && \ - mv ide-projector-launcher.sh ide/bin && \ - mv config ide/ + mv ide-projector-launcher.sh ide/bin COPY --from=devfile-plugin-builder --chown=0:0 /devfile-plugin /mnt/rootfs/projector/ide/plugins/devfile-plugin diff --git a/static/config/options/colors.scheme.xml b/static/config/options/colors.scheme.xml deleted file mode 100644 index 2c1b02e2..00000000 --- a/static/config/options/colors.scheme.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/static/config/options/ide.general.xml b/static/config/options/ide.general.xml deleted file mode 100644 index 44f88b62..00000000 --- a/static/config/options/ide.general.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/static/config/options/laf.xml b/static/config/options/laf.xml deleted file mode 100644 index 3f865093..00000000 --- a/static/config/options/laf.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/static/config/options/other.xml b/static/config/options/other.xml deleted file mode 100644 index 4c0494e0..00000000 --- a/static/config/options/other.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/static/config/options/path.macros.xml b/static/config/options/path.macros.xml deleted file mode 100644 index d28c8d47..00000000 --- a/static/config/options/path.macros.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/static/config/options/ui.lnf.xml b/static/config/options/ui.lnf.xml deleted file mode 100644 index 327b7fba..00000000 --- a/static/config/options/ui.lnf.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/static/config/options/updates.xml b/static/config/options/updates.xml deleted file mode 100644 index 5b284407..00000000 --- a/static/config/options/updates.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/static/default-configuration-provider.sh b/static/default-configuration-provider.sh new file mode 100755 index 00000000..1d280758 --- /dev/null +++ b/static/default-configuration-provider.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# + +CONFIG_OPTIONS_DIR="$PROJECTOR_CONFIG_DIR/config/options" + +COLORS_SCHEME_XML_PATH="$CONFIG_OPTIONS_DIR/colors.scheme.xml" +read -r -d '' COLORS_SCHEME_XML <<-EOM + + + + + +EOM + +IDE_GENERAL_XML_PATH="$CONFIG_OPTIONS_DIR/ide.general.xml" +read -r -d '' IDE_GENERAL_XML <<-EOM + + + + +EOM + +LAF_XML_PATH="$CONFIG_OPTIONS_DIR/laf.xml" +read -r -d '' LAF_XML <<-EOM + + + + + +EOM + +OTHER_XML_PATH="$CONFIG_OPTIONS_DIR/other.xml" +read -r -d '' OTHER_XML <<-EOM + + + + + + + +EOM + +PATH_MACROS_XML_PATH="$CONFIG_OPTIONS_DIR/path.macros.xml" +read -r -d '' PATH_MACROS_XML <<-EOM + + + + + + +EOM + +TRUSTED_PATHS_XML_PATH="$CONFIG_OPTIONS_DIR/trusted-paths.xml" +read -r -d '' TRUSTED_PATHS_XML <<-EOM + + + + + +EOM + +UI_INF_XML_PATH="$CONFIG_OPTIONS_DIR/ui.lnf.xml" +read -r -d '' UI_INF_XML <<-EOM + + + + +EOM + +UPDATES_XML_PATH="$CONFIG_OPTIONS_DIR/updates.xml" +read -r -d '' UPDATES_XML <<-EOM + + + + +EOM + +createConfigFiles() { + mkdir -p "$CONFIG_OPTIONS_DIR" + + echo "Creating '$COLORS_SCHEME_XML_PATH'" + echo "$COLORS_SCHEME_XML" > "$COLORS_SCHEME_XML_PATH" + + echo "Creating '$IDE_GENERAL_XML_PATH'" + echo "$IDE_GENERAL_XML" > "$IDE_GENERAL_XML_PATH" + + echo "Creating '$LAF_XML_PATH'" + echo "$LAF_XML" > "$LAF_XML_PATH" + + echo "Creating '$OTHER_XML_PATH'" + echo "$OTHER_XML" > "$OTHER_XML_PATH" + + echo "Creating '$PATH_MACROS_XML_PATH'" + echo "$PATH_MACROS_XML" > "$PATH_MACROS_XML_PATH" + + echo "Creating '$TRUSTED_PATHS_XML_PATH'" + echo "$TRUSTED_PATHS_XML" > "$TRUSTED_PATHS_XML_PATH" + + echo "Creating '$UI_INF_XML_PATH'" + echo "$UI_INF_XML" > "$UI_INF_XML_PATH" + + echo "Creating '$UPDATES_XML_PATH'" + echo "$UPDATES_XML" > "$UPDATES_XML_PATH" +} + +# copy default configuration if it doesn't exist +if [ ! -d "$PROJECTOR_CONFIG_DIR" ]; then + mkdir -p "$PROJECTOR_CONFIG_DIR" + createConfigFiles +elif [ -z "$(ls -A -- "$PROJECTOR_CONFIG_DIR")" ]; then + echo "Configuration directory '$PROJECTOR_CONFIG_DIR' is empty." + createConfigFiles +fi + +# overwrite default configuration paths for IDE +cat <> "$PROJECTOR_ASSEMBLY_DIR"/ide/bin/idea.properties +idea.config.path=$PROJECTOR_CONFIG_DIR/config +idea.system.path=$PROJECTOR_CONFIG_DIR/caches +idea.plugins.path=$PROJECTOR_CONFIG_DIR/plugins +idea.log.path=$PROJECTOR_CONFIG_DIR/logs +EOT diff --git a/static/ide-projector-launcher.sh b/static/ide-projector-launcher.sh index 9853ed5b..d7b6e317 100755 --- a/static/ide-projector-launcher.sh +++ b/static/ide-projector-launcher.sh @@ -24,24 +24,7 @@ # limitations under the License. # -# copy default configuration if it doesn't exist -if [ ! -d "$PROJECTOR_CONFIG_DIR" ]; then - echo "Copying default configuration '$PROJECTOR_ASSEMBLY_DIR/ide/config' to '$PROJECTOR_CONFIG_DIR'." - mkdir -p "$PROJECTOR_CONFIG_DIR" - cp -rp "$PROJECTOR_ASSEMBLY_DIR"/ide/config "$PROJECTOR_CONFIG_DIR"/ -elif [ -z "$(ls -A -- "$PROJECTOR_CONFIG_DIR")" ]; then - echo "Configuration directory '$PROJECTOR_CONFIG_DIR' is empty." - echo "Copying default configuration '$PROJECTOR_ASSEMBLY_DIR/ide/config' to '$PROJECTOR_CONFIG_DIR'." - cp -rp "$PROJECTOR_ASSEMBLY_DIR"/ide/config "$PROJECTOR_CONFIG_DIR"/ -fi - -# overwrite default configuration paths for IDE -cat <> "$PROJECTOR_ASSEMBLY_DIR"/ide/bin/idea.properties -idea.config.path=$PROJECTOR_CONFIG_DIR/config -idea.system.path=$PROJECTOR_CONFIG_DIR/caches -idea.plugins.path=$PROJECTOR_CONFIG_DIR/plugins -idea.log.path=$PROJECTOR_CONFIG_DIR/logs -EOT +bash "$PROJECTOR_ASSEMBLY_DIR"/default-configuration-provider.sh # provide necessary environment variables echo "export JAVA_HOME=/usr/lib/jvm/java-11" >> "${HOME}"/.bashrc