Common: Handle meta.env for devcontainer-info cmd (#46)

Handle meta.env
This commit is contained in:
Samruddhi Khandale 2022-06-13 14:29:50 -07:00 committed by GitHub
parent fa07406f4d
commit 78ef2ccef9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,8 +17,9 @@ USER_UID=${USER_UID:-"automatic"}
USER_GID=${USER_GID:-"automatic"}
ADD_NON_FREE_PACKAGES=${ADD_NON_FREE_PACKAGES:-"false"}
SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
DEV_CONTAINERS_DIR="/usr/local/etc/vscode-dev-containers"
MARKER_FILE="${DEV_CONTAINERS_DIR}/common"
if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
@ -237,8 +238,8 @@ if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.loc
# Display optional first run image specific notice if configured and terminal is interactive
if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then
if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then
cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt"
if [ -f "${DEV_CONTAINERS_DIR}/first-run-notice.txt" ]; then
cat "${DEV_CONTAINERS_DIR}/first-run-notice.txt"
elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
cat "/workspaces/.codespaces/shared/first-run-notice.txt"
fi
@ -435,15 +436,16 @@ if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; f
echo
EOF
)"
if [ -f "${SCRIPT_DIR}/meta.env" ]; then
mkdir -p /usr/local/etc/vscode-dev-containers/
cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env
if [ -f "${DEV_CONTAINERS_DIR}/meta.env" ]; then
echo "${meta_info_script}" > /usr/local/bin/devcontainer-info
chmod +x /usr/local/bin/devcontainer-info
fi
if [ ! -d "${DEV_CONTAINERS_DIR}" ]; then
mkdir -p "$(dirname "${MARKER_FILE}")"
fi
# Write marker file
mkdir -p "$(dirname "${MARKER_FILE}")"
echo -e "\
PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
@ -452,7 +454,7 @@ echo -e "\
ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
# Display a notice on conda when not running in GitHub Codespaces
cat << 'EOF' > /usr/local/etc/vscode-dev-containers/conda-notice.txt
cat << 'EOF' > ${DEV_CONTAINERS_DIR}/conda-notice.txt
When using "conda" from outside of GitHub Codespaces, note the Anaconda repository contains
restrictions on commercial use that may impact certain organizations. See https://aka.ms/ghcs-conda
@ -460,7 +462,7 @@ EOF
notice_script="$(cat << 'EOF'
if [ -t 1 ] && [ "${IGNORE_NOTICE}" != "true" ] && [ "${TERM_PROGRAM}" = "vscode" ] && [ "${CODESPACES}" != "true" ] && [ ! -f "$HOME/.config/vscode-dev-containers/conda-notice-already-displayed" ]; then
cat "/usr/local/etc/vscode-dev-containers/conda-notice.txt"
cat "${DEV_CONTAINERS_DIR}/conda-notice.txt"
mkdir -p "$HOME/.config/vscode-dev-containers"
((sleep 10s; touch "$HOME/.config/vscode-dev-containers/conda-notice-already-displayed") &)
fi