Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /projects to a trusted paths configuration #83

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions static/config/options/colors.scheme.xml

This file was deleted.

7 changes: 0 additions & 7 deletions static/config/options/ide.general.xml

This file was deleted.

5 changes: 0 additions & 5 deletions static/config/options/laf.xml

This file was deleted.

7 changes: 0 additions & 7 deletions static/config/options/other.xml

This file was deleted.

6 changes: 0 additions & 6 deletions static/config/options/path.macros.xml

This file was deleted.

5 changes: 0 additions & 5 deletions static/config/options/ui.lnf.xml

This file was deleted.

5 changes: 0 additions & 5 deletions static/config/options/updates.xml

This file was deleted.

137 changes: 137 additions & 0 deletions static/default-configuration-provider.sh
Original file line number Diff line number Diff line change
@@ -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
<application>
<component name="EditorColorsManagerImpl">
<global_color_scheme name="Darcula"/>
</component>
</application>
EOM

IDE_GENERAL_XML_PATH="$CONFIG_OPTIONS_DIR/ide.general.xml"
read -r -d '' IDE_GENERAL_XML <<-EOM
<application>
<component name="GeneralSettings">
<option name="defaultProjectDirectory" value="$PROJECTS_ROOT" />
<option name="autoSaveIfInactive" value="true" />
<option name="inactiveTimeout" value="5" />
</component>
</application>
EOM

LAF_XML_PATH="$CONFIG_OPTIONS_DIR/laf.xml"
read -r -d '' LAF_XML <<-EOM
<application>
<component name="LafManager">
<laf class-name="com.intellij.ide.ui.laf.darcula.DarculaLaf"/>
</component>
</application>
EOM

OTHER_XML_PATH="$CONFIG_OPTIONS_DIR/other.xml"
read -r -d '' OTHER_XML <<-EOM
<application>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECTS_ROOT" />
<property name="terminalCustomCommandExecutionTurnOff" value="false" />
<property name="ide.memory.adjusted" value="true"/>
</component>
</application>
EOM

PATH_MACROS_XML_PATH="$CONFIG_OPTIONS_DIR/path.macros.xml"
read -r -d '' PATH_MACROS_XML <<-EOM
<application>
<component name="PathMacrosImpl">
<macro name="KOTLIN_BUNDLED" value="$PROJECTOR_ASSEMBLY_DIR/ide/plugins/Kotlin/kotlinc"/>
<macro name="MAVEN_REPOSITORY" value="$PROJECTOR_CONFIG_DIR/.m2/repository"/>
</component>
</application>
EOM

TRUSTED_PATHS_XML_PATH="$CONFIG_OPTIONS_DIR/trusted-paths.xml"
read -r -d '' TRUSTED_PATHS_XML <<-EOM
<application>
<component name="Trusted.Paths.Settings">
<option name="TRUSTED_PATHS">
<list>
<option value="$PROJECTS_ROOT" />
</list>
</option>
</component>
</application>
EOM

UI_INF_XML_PATH="$CONFIG_OPTIONS_DIR/ui.lnf.xml"
read -r -d '' UI_INF_XML <<-EOM
<application>
<component name="UISettings">
<option name="smoothScrolling" value="false"/>
</component>
</application>
EOM

UPDATES_XML_PATH="$CONFIG_OPTIONS_DIR/updates.xml"
read -r -d '' UPDATES_XML <<-EOM
<application>
<component name="UpdatesConfigurable">
<option name="CHECK_NEEDED" value="false" />
</component>
</application>
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 <<EOT >> "$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
19 changes: 1 addition & 18 deletions static/ide-projector-launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOT >> "$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
Expand Down