common-debian.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. #!/usr/bin/env bash
  2. #-------------------------------------------------------------------------------------------------------------
  3. # Copyright (c) Microsoft Corporation. All rights reserved.
  4. # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
  5. #-------------------------------------------------------------------------------------------------------------
  6. #
  7. # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md
  8. # Maintainer: The VS Code and Codespaces Teams
  9. #
  10. # Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages]
  11. set -e
  12. INSTALL_ZSH=${1:-"true"}
  13. USERNAME=${2:-"automatic"}
  14. USER_UID=${3:-"automatic"}
  15. USER_GID=${4:-"automatic"}
  16. UPGRADE_PACKAGES=${5:-"true"}
  17. INSTALL_OH_MYS=${6:-"true"}
  18. ADD_NON_FREE_PACKAGES=${7:-"false"}
  19. SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
  20. MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
  21. if [ "$(id -u)" -ne 0 ]; then
  22. echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
  23. exit 1
  24. fi
  25. # Ensure that login shells get the correct path if the user updated the PATH using ENV.
  26. rm -f /etc/profile.d/00-restore-env.sh
  27. echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
  28. chmod +x /etc/profile.d/00-restore-env.sh
  29. # If in automatic mode, determine if a user already exists, if not use vscode
  30. if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
  31. USERNAME=""
  32. POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
  33. for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
  34. if id -u ${CURRENT_USER} > /dev/null 2>&1; then
  35. USERNAME=${CURRENT_USER}
  36. break
  37. fi
  38. done
  39. if [ "${USERNAME}" = "" ]; then
  40. USERNAME=vscode
  41. fi
  42. elif [ "${USERNAME}" = "none" ]; then
  43. USERNAME=root
  44. USER_UID=0
  45. USER_GID=0
  46. fi
  47. # Load markers to see which steps have already run
  48. if [ -f "${MARKER_FILE}" ]; then
  49. echo "Marker file found:"
  50. cat "${MARKER_FILE}"
  51. source "${MARKER_FILE}"
  52. fi
  53. # Ensure apt is in non-interactive to avoid prompts
  54. export DEBIAN_FRONTEND=noninteractive
  55. # Function to call apt-get if needed
  56. apt_get_update_if_needed()
  57. {
  58. if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
  59. echo "Running apt-get update..."
  60. apt-get update
  61. else
  62. echo "Skipping apt-get update."
  63. fi
  64. }
  65. # Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
  66. if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
  67. package_list="apt-utils \
  68. openssh-client \
  69. gnupg2 \
  70. dirmngr \
  71. iproute2 \
  72. procps \
  73. lsof \
  74. htop \
  75. net-tools \
  76. psmisc \
  77. curl \
  78. wget \
  79. rsync \
  80. ca-certificates \
  81. unzip \
  82. zip \
  83. nano \
  84. vim-tiny \
  85. less \
  86. jq \
  87. lsb-release \
  88. apt-transport-https \
  89. dialog \
  90. libc6 \
  91. libgcc1 \
  92. libkrb5-3 \
  93. libgssapi-krb5-2 \
  94. libicu[0-9][0-9] \
  95. liblttng-ust0 \
  96. libstdc++6 \
  97. zlib1g \
  98. locales \
  99. sudo \
  100. ncdu \
  101. man-db \
  102. strace \
  103. manpages \
  104. manpages-dev \
  105. init-system-helpers"
  106. # Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian
  107. if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then
  108. # Bring in variables from /etc/os-release like VERSION_CODENAME
  109. . /etc/os-release
  110. sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
  111. sed -i -E "s/deb-src http:\/\/(deb|httredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
  112. sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
  113. sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
  114. sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
  115. sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
  116. sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
  117. sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
  118. # Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html
  119. sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
  120. sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
  121. echo "Running apt-get update..."
  122. apt-get update
  123. package_list="${package_list} manpages-posix manpages-posix-dev"
  124. else
  125. apt_get_update_if_needed
  126. fi
  127. # Install libssl1.1 if available
  128. if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
  129. package_list="${package_list} libssl1.1"
  130. fi
  131. # Install appropriate version of libssl1.0.x if available
  132. libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
  133. if [ "$(echo "$LIlibssl_packageBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
  134. if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
  135. # Debian 9
  136. package_list="${package_list} libssl1.0.2"
  137. elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
  138. # Ubuntu 18.04, 16.04, earlier
  139. package_list="${package_list} libssl1.0.0"
  140. fi
  141. fi
  142. echo "Packages to verify are installed: ${package_list}"
  143. apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
  144. # Install git if not already installed (may be more recent than distro version)
  145. if ! type git > /dev/null 2>&1; then
  146. apt-get -y install --no-install-recommends git
  147. fi
  148. PACKAGES_ALREADY_INSTALLED="true"
  149. fi
  150. # Get to latest versions of all packages
  151. if [ "${UPGRADE_PACKAGES}" = "true" ]; then
  152. apt_get_update_if_needed
  153. apt-get -y upgrade --no-install-recommends
  154. apt-get autoremove -y
  155. fi
  156. # Ensure at least the en_US.UTF-8 UTF-8 locale is available.
  157. # Common need for both applications and things like the agnoster ZSH theme.
  158. if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
  159. echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
  160. locale-gen
  161. LOCALE_ALREADY_SET="true"
  162. fi
  163. # Create or update a non-root user to match UID/GID.
  164. group_name="${USERNAME}"
  165. if id -u ${USERNAME} > /dev/null 2>&1; then
  166. # User exists, update if needed
  167. if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
  168. group_name="$(id -gn $USERNAME)"
  169. groupmod --gid $USER_GID ${group_name}
  170. usermod --gid $USER_GID $USERNAME
  171. fi
  172. if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
  173. usermod --uid $USER_UID $USERNAME
  174. fi
  175. else
  176. # Create user
  177. if [ "${USER_GID}" = "automatic" ]; then
  178. groupadd $USERNAME
  179. else
  180. groupadd --gid $USER_GID $USERNAME
  181. fi
  182. if [ "${USER_UID}" = "automatic" ]; then
  183. useradd -s /bin/bash --gid $USERNAME -m $USERNAME
  184. else
  185. useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
  186. fi
  187. fi
  188. # Add add sudo support for non-root user
  189. if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then
  190. echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
  191. chmod 0440 /etc/sudoers.d/$USERNAME
  192. EXISTING_NON_ROOT_USER="${USERNAME}"
  193. fi
  194. # ** Shell customization section **
  195. if [ "${USERNAME}" = "root" ]; then
  196. user_rc_path="/root"
  197. else
  198. user_rc_path="/home/${USERNAME}"
  199. fi
  200. # Restore user .bashrc defaults from skeleton file if it doesn't exist or is empty
  201. if [ ! -f "${user_rc_path}/.bashrc" ] || [ ! -s "${user_rc_path}/.bashrc" ] ; then
  202. cp /etc/skel/.bashrc "${user_rc_path}/.bashrc"
  203. fi
  204. # Restore user .profile defaults from skeleton file if it doesn't exist or is empty
  205. if [ ! -f "${user_rc_path}/.profile" ] || [ ! -s "${user_rc_path}/.profile" ] ; then
  206. cp /etc/skel/.profile "${user_rc_path}/.profile"
  207. fi
  208. # .bashrc/.zshrc snippet
  209. rc_snippet="$(cat << 'EOF'
  210. if [ -z "${USER}" ]; then export USER=$(whoami); fi
  211. if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi
  212. # Display optional first run image specific notice if configured and terminal is interactive
  213. if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then
  214. if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then
  215. cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt"
  216. elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
  217. cat "/workspaces/.codespaces/shared/first-run-notice.txt"
  218. fi
  219. mkdir -p "$HOME/.config/vscode-dev-containers"
  220. # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it
  221. ((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &)
  222. fi
  223. # Set the default git editor if not already set
  224. if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then
  225. if [ "${TERM_PROGRAM}" = "vscode" ]; then
  226. if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
  227. export GIT_EDITOR="code-insiders --wait"
  228. else
  229. export GIT_EDITOR="code --wait"
  230. fi
  231. fi
  232. fi
  233. EOF
  234. )"
  235. # code shim, it fallbacks to code-insiders if code is not available
  236. cat << 'EOF' > /usr/local/bin/code
  237. #!/bin/sh
  238. get_in_path_except_current() {
  239. which -a "$1" | grep -A1 "$0" | grep -v "$0"
  240. }
  241. code="$(get_in_path_except_current code)"
  242. if [ -n "$code" ]; then
  243. exec "$code" "$@"
  244. elif [ "$(command -v code-insiders)" ]; then
  245. exec code-insiders "$@"
  246. else
  247. echo "code or code-insiders is not installed" >&2
  248. exit 127
  249. fi
  250. EOF
  251. chmod +x /usr/local/bin/code
  252. # systemctl shim - tells people to use 'service' if systemd is not running
  253. cat << 'EOF' > /usr/local/bin/systemctl
  254. #!/bin/sh
  255. set -e
  256. if [ -d "/run/systemd/system" ]; then
  257. exec /bin/systemctl/systemctl "$@"
  258. else
  259. echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services intead. e.g.: \n\nservice --status-all'
  260. fi
  261. EOF
  262. chmod +x /usr/local/bin/systemctl
  263. # Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
  264. codespaces_bash="$(cat \
  265. <<'EOF'
  266. # Codespaces bash prompt theme
  267. __bash_prompt() {
  268. local userpart='`export XIT=$? \
  269. && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
  270. && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
  271. local gitbranch='`\
  272. if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
  273. export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \
  274. if [ "${BRANCH}" != "" ]; then \
  275. echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
  276. && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
  277. echo -n " \[\033[1;33m\]✗"; \
  278. fi \
  279. && echo -n "\[\033[0;36m\]) "; \
  280. fi; \
  281. fi`'
  282. local lightblue='\[\033[1;34m\]'
  283. local removecolor='\[\033[0m\]'
  284. PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ "
  285. unset -f __bash_prompt
  286. }
  287. __bash_prompt
  288. EOF
  289. )"
  290. codespaces_zsh="$(cat \
  291. <<'EOF'
  292. # Codespaces zsh prompt theme
  293. __zsh_prompt() {
  294. local prompt_username
  295. if [ ! -z "${GITHUB_USER}" ]; then
  296. prompt_username="@${GITHUB_USER}"
  297. else
  298. prompt_username="%n"
  299. fi
  300. PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow
  301. PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd
  302. PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status
  303. PROMPT+='%{$fg[white]%}$ %{$reset_color%}'
  304. unset -f __zsh_prompt
  305. }
  306. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}"
  307. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  308. ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})"
  309. ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})"
  310. __zsh_prompt
  311. EOF
  312. )"
  313. # Add RC snippet and custom bash prompt
  314. if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
  315. echo "${rc_snippet}" >> /etc/bash.bashrc
  316. echo "${codespaces_bash}" >> "${user_rc_path}/.bashrc"
  317. echo 'export PROMPT_DIRTRIM=4' >> "${user_rc_path}/.bashrc"
  318. if [ "${USERNAME}" != "root" ]; then
  319. echo "${codespaces_bash}" >> "/root/.bashrc"
  320. echo 'export PROMPT_DIRTRIM=4' >> "/root/.bashrc"
  321. fi
  322. chown ${USERNAME}:${group_name} "${user_rc_path}/.bashrc"
  323. RC_SNIPPET_ALREADY_ADDED="true"
  324. fi
  325. # Optionally install and configure zsh and Oh My Zsh!
  326. if [ "${INSTALL_ZSH}" = "true" ]; then
  327. if ! type zsh > /dev/null 2>&1; then
  328. apt_get_update_if_needed
  329. apt-get install -y zsh
  330. fi
  331. if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
  332. echo "${rc_snippet}" >> /etc/zsh/zshrc
  333. ZSH_ALREADY_INSTALLED="true"
  334. fi
  335. # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme.
  336. # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script.
  337. oh_my_install_dir="${user_rc_path}/.oh-my-zsh"
  338. if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then
  339. template_path="${oh_my_install_dir}/templates/zshrc.zsh-template"
  340. user_rc_file="${user_rc_path}/.zshrc"
  341. umask g-w,o-w
  342. mkdir -p ${oh_my_install_dir}
  343. git clone --depth=1 \
  344. -c core.eol=lf \
  345. -c core.autocrlf=false \
  346. -c fsck.zeroPaddedFilemode=ignore \
  347. -c fetch.fsck.zeroPaddedFilemode=ignore \
  348. -c receive.fsck.zeroPaddedFilemode=ignore \
  349. "https://github.com/ohmyzsh/ohmyzsh" "${oh_my_install_dir}" 2>&1
  350. echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
  351. sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file}
  352. mkdir -p ${oh_my_install_dir}/custom/themes
  353. echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme"
  354. # Shrink git while still enabling updates
  355. cd "${oh_my_install_dir}"
  356. git repack -a -d -f --depth=1 --window=1
  357. # Copy to non-root user if one is specified
  358. if [ "${USERNAME}" != "root" ]; then
  359. cp -rf "${user_rc_file}" "${oh_my_install_dir}" /root
  360. chown -R ${USERNAME}:${group_name} "${user_rc_path}"
  361. fi
  362. fi
  363. fi
  364. # Persist image metadata info, script if meta.env found in same directory
  365. meta_info_script="$(cat << 'EOF'
  366. #!/bin/sh
  367. . /usr/local/etc/vscode-dev-containers/meta.env
  368. # Minimal output
  369. if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then
  370. echo "${VERSION}"
  371. exit 0
  372. elif [ "$1" = "release" ]; then
  373. echo "${GIT_REPOSITORY_RELEASE}"
  374. exit 0
  375. elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then
  376. echo "${CONTENTS_URL}"
  377. exit 0
  378. fi
  379. #Full output
  380. echo
  381. echo "Development container image information"
  382. echo
  383. if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi
  384. if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi
  385. if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi
  386. if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi
  387. if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi
  388. if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi
  389. if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi
  390. echo
  391. EOF
  392. )"
  393. if [ -f "${SCRIPT_DIR}/meta.env" ]; then
  394. mkdir -p /usr/local/etc/vscode-dev-containers/
  395. cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env
  396. echo "${meta_info_script}" > /usr/local/bin/devcontainer-info
  397. chmod +x /usr/local/bin/devcontainer-info
  398. fi
  399. # Write marker file
  400. mkdir -p "$(dirname "${MARKER_FILE}")"
  401. echo -e "\
  402. PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
  403. LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
  404. EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\
  405. RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\
  406. ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
  407. echo "Done!"