Common: Handle meta.env for devcontainer-info cmd (#46)
Handle meta.env
This commit is contained in:
parent
fa07406f4d
commit
78ef2ccef9
1 changed files with 12 additions and 10 deletions
|
@ -17,8 +17,9 @@ USER_UID=${USER_UID:-"automatic"}
|
||||||
USER_GID=${USER_GID:-"automatic"}
|
USER_GID=${USER_GID:-"automatic"}
|
||||||
ADD_NON_FREE_PACKAGES=${ADD_NON_FREE_PACKAGES:-"false"}
|
ADD_NON_FREE_PACKAGES=${ADD_NON_FREE_PACKAGES:-"false"}
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
|
DEV_CONTAINERS_DIR="/usr/local/etc/vscode-dev-containers"
|
||||||
MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
|
MARKER_FILE="${DEV_CONTAINERS_DIR}/common"
|
||||||
|
|
||||||
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
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.'
|
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
|
# 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 [ -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
|
if [ -f "${DEV_CONTAINERS_DIR}/first-run-notice.txt" ]; then
|
||||||
cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt"
|
cat "${DEV_CONTAINERS_DIR}/first-run-notice.txt"
|
||||||
elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
|
elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
|
||||||
cat "/workspaces/.codespaces/shared/first-run-notice.txt"
|
cat "/workspaces/.codespaces/shared/first-run-notice.txt"
|
||||||
fi
|
fi
|
||||||
|
@ -435,15 +436,16 @@ if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; f
|
||||||
echo
|
echo
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
if [ -f "${SCRIPT_DIR}/meta.env" ]; then
|
if [ -f "${DEV_CONTAINERS_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
|
|
||||||
echo "${meta_info_script}" > /usr/local/bin/devcontainer-info
|
echo "${meta_info_script}" > /usr/local/bin/devcontainer-info
|
||||||
chmod +x /usr/local/bin/devcontainer-info
|
chmod +x /usr/local/bin/devcontainer-info
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "${DEV_CONTAINERS_DIR}" ]; then
|
||||||
|
mkdir -p "$(dirname "${MARKER_FILE}")"
|
||||||
|
fi
|
||||||
|
|
||||||
# Write marker file
|
# Write marker file
|
||||||
mkdir -p "$(dirname "${MARKER_FILE}")"
|
|
||||||
echo -e "\
|
echo -e "\
|
||||||
PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
|
PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
|
||||||
LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
|
LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
|
||||||
|
@ -452,7 +454,7 @@ echo -e "\
|
||||||
ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
|
ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
|
||||||
|
|
||||||
# Display a notice on conda when not running in GitHub Codespaces
|
# 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
|
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
|
restrictions on commercial use that may impact certain organizations. See https://aka.ms/ghcs-conda
|
||||||
|
|
||||||
|
@ -460,7 +462,7 @@ EOF
|
||||||
|
|
||||||
notice_script="$(cat << '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
|
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"
|
mkdir -p "$HOME/.config/vscode-dev-containers"
|
||||||
((sleep 10s; touch "$HOME/.config/vscode-dev-containers/conda-notice-already-displayed") &)
|
((sleep 10s; touch "$HOME/.config/vscode-dev-containers/conda-notice-already-displayed") &)
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue