-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathprepare-and-install-dynamic-plugins.sh
More file actions
executable file
·70 lines (58 loc) · 2.83 KB
/
prepare-and-install-dynamic-plugins.sh
File metadata and controls
executable file
·70 lines (58 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -euo pipefail
# Workaround for various issues
# Fix for https://issues.redhat.com/browse/RHIDP-3939
# needed for < 1.4
# if there is no config than the files in dynamic-plugins-root are from the image, and we need to remove them
# Entrypoint for the install-dynamic-plugins container.
# Prepares the dynamic-plugins config, applies compatibility fixes,
# and runs install-dynamic-plugins.sh to generate app-config.dynamic-plugins.yaml.
if [ -d "dynamic-plugins-root" ]; then
echo "dynamic-plugins-root exists"
if [ ! -f "dynamic-plugins-root/app-config.dynamic-plugins.yaml" ]; then
echo "app-config.dynamic-plugins.yaml does not exist"
echo "Removing dynamic-plugins-root to fix RHIDP-3939"
rm -rf ./dynamic-plugins-root
fi
fi
# Fix for https://issues.redhat.com/browse/RHIDP-4410
# needed for < 1.3.0
echo "Removing ~/.npmrc to fix RHIDP-4410"
rm -rf ~/.npmrc
# handle dynamic-plugins config override
DYNAMIC_PLUGINS_DEFAULT="/opt/app-root/src/configs/dynamic-plugins/dynamic-plugins.yaml"
DYNAMIC_PLUGINS_OVERRIDE="/opt/app-root/src/configs/dynamic-plugins/dynamic-plugins.override.yaml"
LINK_TARGET="/opt/app-root/src/dynamic-plugins.yaml"
NPMRC_PATH="/opt/app-root/src/configs/.npmrc"
if [ -f "$DYNAMIC_PLUGINS_OVERRIDE" ]; then
echo "Using dynamic-plugins.override.yaml"
ln -sf "$DYNAMIC_PLUGINS_OVERRIDE" "$LINK_TARGET"
elif [ -f "/opt/app-root/src/configs/dynamic-plugins.yaml" ]; then
echo "[warn] Using legacy dynamic-plugins.yaml. This method is deprecated. You can override the dynamic plugins configuration by renaming your file into configs/dynamic-plugins/dynamic-plugins.override.yaml"
ln -sf "/opt/app-root/src/configs/dynamic-plugins.yaml" "$LINK_TARGET"
else
echo "Using default dynamic-plugins.yaml"
ln -sf "$DYNAMIC_PLUGINS_DEFAULT" "$LINK_TARGET"
fi
# If a .npmrc was mounted, set the NPM_CONFIG_USERCONFIG env var
if [ -f "$NPMRC_PATH" ]; then
echo "Found .npmrc, setting NPM_CONFIG_USERCONFIG"
export NPM_CONFIG_USERCONFIG="$NPMRC_PATH"
else
echo "No .npmrc found, skipping NPM_CONFIG_USERCONFIG"
fi
DYNAMIC_PLUGINS_EXTENSIONS_FILE="/dynamic-plugins-root/dynamic-plugins.extensions.yaml"
if [ ! -f "$DYNAMIC_PLUGINS_EXTENSIONS_FILE" ]; then
echo "$DYNAMIC_PLUGINS_EXTENSIONS_FILE does not exist - creating it to enable dynamic plugins installation by using Extensions..."
cat <<EOF > "$DYNAMIC_PLUGINS_EXTENSIONS_FILE"
includes:
- dynamic-plugins.default.yaml
plugins: []
EOF
# The file needs to be writable by the main RHDH container user.
# Otherwise, the extensions backend plugin will not be able to save the dynamic plugins configuration
chown 1001 "$DYNAMIC_PLUGINS_EXTENSIONS_FILE"
echo '... file '$DYNAMIC_PLUGINS_EXTENSIONS_FILE' created!'
fi
echo "Running install-dynamic-plugins.sh"
./install-dynamic-plugins.sh /dynamic-plugins-root