blob: 758b4cdc180ed7629410fe540d166b7a99cb72cb (
plain) (
blame)
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
|
#!/usr/bin/env bash
# Support 'v1' dev container feature installation
# that require a root 'install.sh' script.
set -e
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Verify we're on a supported OS
. /etc/os-release
if [ "${ID}" != "debian" ] && [ "${ID_LIKE}" != "debian" ]; then
cat << EOF
*********** Unsupported operating system "${ID}" detected ***********
Features support currently requires a Debian/Ubuntu-based image. Update your
image or Dockerfile FROM statement to start with a supported OS. For example:
mcr.microsoft.com/vscode/devcontainers/base:ubuntu
Aborting build...
EOF
exit 2
fi
set -a
. ./devcontainer-features.env
set +a
chmod +x *.sh
# Execute option scripts if correct environment variable is set to "true"
feature_marker_path="/usr/local/etc/vscode-dev-containers/features"
mkdir -p "${feature_marker_path}"
while IFS= read -r feature_line; do
# Extract the env var part of the line
feature_var_name="${feature_line%%=*}"
if [ ! -z "${!feature_var_name}" ]; then
# If a value is set for the env var, execute the script
feature_script_and_args="${feature_line##*=}"
feature_script_and_args="${feature_script_and_args%\"}"
script_command="$(eval echo "${feature_script_and_args#\"}")"
echo "(*) Script: ${script_command}"
# Check if script with same args has already been run
feature_marker="${feature_marker_path}/${feature_var_name}";
if [ -e "${feature_marker}" ] && [ "${script_command}" = "$(cat ${feature_marker})" ]; then
echo "(*) Skipping. Script already run with same arguments."
else
# Execute script and create a marker with the script args
./${script_command}
echo "${script_command}" > "${feature_marker}"
fi
fi
done < ./feature-scripts.env
# Clean up
apt-get autoremove -y
apt-get clean -y
rm -rf /var/lib/apt/lists/*
|