Add SSH, Oh My Bash! to codespaces-linux (#566)
This commit is contained in:
Родитель
cc524406c4
Коммит
e1c56beb90
29
NOTICE.txt
29
NOTICE.txt
|
@ -8385,4 +8385,33 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
|
||||
---------------------------------------------------------
|
||||
|
||||
---------------------------------------------------------
|
||||
|
||||
Oh My Bash! - MIT
|
||||
https://github.com/ohmybash/oh-my-bash/
|
||||
|
||||
|
||||
Copyright 2017-2020 Toan Nguyen and contributors (https://github.com/ohmybash/oh-my-bash/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
---------------------------------------------------------
|
||||
|
|
|
@ -15,7 +15,7 @@ USER_GID=${4:-1000}
|
|||
UPGRADE_PACKAGES=${5:-"true"}
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo 'Script must be run a root. Use sudo or set "USER root" before running the script.'
|
||||
echo 'Script must be run as root. Use sudo or set "USER root" before running the script.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ USER_GID=${4:-1000}
|
|||
UPGRADE_PACKAGES=${5:-"true"}
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo 'Script must be run a root. Use sudo or set "USER root" before running the script.'
|
||||
echo 'Script must be run as root. Use sudo or set "USER root" before running the script.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USER_GID=${4:-1000}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ if [ -z "$1" ]; then
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ ENV PATH="${NVM_DIR}/current/bin:${DOTNET_ROOT}/tools:${SDKMAN_DIR}/bin:${SDKMAN
|
|||
|
||||
# Install needed utilities and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
COPY library-scripts/azcli-debian.sh library-scripts/common-debian.sh library-scripts/git-lfs-debian.sh library-scripts/github-debian.sh \
|
||||
library-scripts/kubectl-helm-debian.sh setup-user.sh /tmp/scripts/
|
||||
library-scripts/kubectl-helm-debian.sh library-scripts/sshd-debian.sh setup-user.sh /tmp/scripts/
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# Remove buster list to avoid unexpected errors given base image is stretch
|
||||
&& rm /etc/apt/sources.list.d/buster.list \
|
||||
# Run common script and setup user
|
||||
&& bash /tmp/scripts/common-debian.sh "true" "${USERNAME}" "${USER_UID}" "${USER_GID}" "false" \
|
||||
&& bash /tmp/scripts/common-debian.sh "true" "${USERNAME}" "${USER_UID}" "${USER_GID}" "false" "true" \
|
||||
&& bash /tmp/scripts/setup-user.sh "${USERNAME}" "${PATH}" \
|
||||
# Upgrade git to avoid security issue
|
||||
&& apt-get upgrade -yq git \
|
||||
|
@ -40,8 +40,9 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|||
&& apt-get purge -y imagemagick imagemagick-6-common \
|
||||
# Install tools and shells not in common script
|
||||
&& apt-get install -yq vim xtail software-properties-common \
|
||||
&& bash /tmp/scripts/sshd-debian.sh \
|
||||
&& bash /tmp/scripts/git-lfs-debian.sh \
|
||||
&& bash /tmp/scripts/github-debian.sh ${GITHUB_CLI_VERSION}\
|
||||
&& bash /tmp/scripts/github-debian.sh \
|
||||
&& bash /tmp/scripts/azcli-debian.sh \
|
||||
&& bash /tmp/scripts/kubectl-helm-debian.sh \
|
||||
# Clean up
|
||||
|
@ -126,7 +127,7 @@ RUN if [ "${INSTALL_DOCKER}" = "true" ]; then \
|
|||
&& rm -rf /tmp/scripts && apt-get clean -y
|
||||
|
||||
# Fire Docker script if needed along with Oryx's benv
|
||||
ENTRYPOINT [ "/usr/local/share/docker-init.sh", "benv" ]
|
||||
ENTRYPOINT [ "/usr/local/share/docker-init.sh", "/usr/local/share/ssh-init.sh" ,"benv" ]
|
||||
CMD [ "sleep", "infinity" ]
|
||||
|
||||
# [Optional] Install debugger for development of Codespaces - Not in resulting image by default
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -4,18 +4,33 @@
|
|||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag]
|
||||
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My *! flag]
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# 1. Add this file to .devcontainer/library-scripts
|
||||
#
|
||||
# 2. Add the following to .devcontainer/Dockerfile:
|
||||
#
|
||||
# COPY library-scripts/*.sh /tmp/library-scripts/
|
||||
# RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
||||
# && bash /tmp/library-scripts/common-debian.sh \
|
||||
# && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
#
|
||||
# You can optionally pass in arguments described above to common-debian.sh. Flags are a value of "true" or "false.
|
||||
# Pass in "none" for the username to skip the creation or modification of a non-root user while setting other arguments.
|
||||
|
||||
INSTALL_ZSH=${1:-"true"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
USER_UID=${3:-1000}
|
||||
USER_GID=${4:-1000}
|
||||
UPGRADE_PACKAGES=${5:-"true"}
|
||||
INSTALL_OH_MYS=${6:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -119,7 +134,7 @@ fi
|
|||
|
||||
# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
|
||||
# Common need for both applications and things like the agnoster ZSH theme.
|
||||
if [ "${LOCALE_ALREADY_SET}" != "true" ]; then
|
||||
if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
||||
locale-gen
|
||||
LOCALE_ALREADY_SET="true"
|
||||
|
@ -148,6 +163,13 @@ if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}"
|
|||
EXISTING_NON_ROOT_USER="${USERNAME}"
|
||||
fi
|
||||
|
||||
# ** Shell customization section **
|
||||
if [ "${USERNAME}" = "root" ]; then
|
||||
USER_RC_PATH="/root"
|
||||
else
|
||||
USER_RC_PATH="/home/${USERNAME}"
|
||||
fi
|
||||
|
||||
# .bashrc/.zshrc snippet
|
||||
RC_SNIPPET="$(cat << EOF
|
||||
export USER=\$(whoami)
|
||||
|
@ -160,27 +182,111 @@ fi
|
|||
EOF
|
||||
)"
|
||||
|
||||
# Ensure ~/.local/bin is in the PATH for root and non-root users for bash. (zsh is later)
|
||||
# Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
|
||||
CODESPACES_BASH="$(cat \
|
||||
<<EOF
|
||||
#!/usr/bin/env bash
|
||||
prompt() {
|
||||
if [ ! -z "\${GITHUB_USER}" ]; then
|
||||
local USERNAME="gh:@\${GITHUB_USER}"
|
||||
else
|
||||
local USERNAME="\$(whoami)"
|
||||
fi
|
||||
local cwd="\$(pwd | sed "s|^\${HOME}|~|")"
|
||||
if [ "\$?" != "0" ]; then
|
||||
local arrow_color=\${bold_red}
|
||||
else
|
||||
local arrow_color=\${reset_color}
|
||||
fi
|
||||
PS1="\${green}\${USERNAME} \${arrow_color}➜ \${blue}\${cwd}\${reset_color} \$(scm_prompt_info)$ "
|
||||
}
|
||||
SCM_THEME_PROMPT_PREFIX="\${cyan}(\${bold_red}"
|
||||
SCM_THEME_PROMPT_SUFFIX="\${reset_color} "
|
||||
SCM_THEME_PROMPT_DIRTY=" \${yellow}✗\${cyan})"
|
||||
SCM_THEME_PROMPT_CLEAN="\${cyan})"
|
||||
SCM_GIT_SHOW_MINIMAL_INFO="true"
|
||||
safe_append_prompt_command prompt
|
||||
EOF
|
||||
)"
|
||||
CODESPACES_ZSH="$(cat \
|
||||
<<EOF
|
||||
prompt() {
|
||||
if [ ! -z "\${GITHUB_USER}" ]; then
|
||||
local USERNAME="gh:@\${GITHUB_USER}"
|
||||
else
|
||||
local USERNAME="\$(whoami)"
|
||||
fi
|
||||
PROMPT="%{\$fg[green]%}\${USERNAME} %(?:%{\$reset_color%}➜ :%{\$fg_bold[red]%}➜ )"
|
||||
PROMPT+='%{\$fg[blue]%}%~%{\$reset_color%} \$(git_prompt_info)$ '
|
||||
}
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{\$fg[cyan]%}(%{\$fg_bold[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{\$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{\$fg[yellow]%}✗%{\$fg[cyan]%})"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{\$fg[cyan]%})"
|
||||
prompt
|
||||
EOF
|
||||
)"
|
||||
|
||||
# Adapted Oh My Zsh! install step to work with both "Oh Mys" rather than relying on an installer script
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for offical script.
|
||||
install-oh-my()
|
||||
{
|
||||
local OH_MY=$1
|
||||
local OH_MY_INSTALL_DIR="${USER_RC_PATH}/.oh-my-${OH_MY}"
|
||||
local TEMPLATE="${OH_MY_INSTALL_DIR}/templates/$2"
|
||||
local OH_MY_GIT_URL=$3
|
||||
local USER_RC_FILE="${USER_RC_PATH}/.${OH_MY}rc"
|
||||
|
||||
if [ -d "${OH_MY_INSTALL_DIR}" ] || [ "${INSTALL_OH_MYS}" != "true" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
umask g-w,o-w
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}
|
||||
git clone --depth=1 \
|
||||
-c core.eol=lf \
|
||||
-c core.autocrlf=false \
|
||||
-c fsck.zeroPaddedFilemode=ignore \
|
||||
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
||||
-c receive.fsck.zeroPaddedFilemode=ignore \
|
||||
${OH_MY_GIT_URL} ${OH_MY_INSTALL_DIR} 2>&1
|
||||
echo -e "$(cat "${TEMPLATE}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE}
|
||||
if [ "${OH_MY}" = "bash" ]; then
|
||||
sed -i -e 's/OSH_THEME=.*/OSH_THEME="codespaces"/g' ${USER_RC_FILE}
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes/codespaces
|
||||
echo "${CODESPACES_BASH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces/codespaces.theme.sh
|
||||
else
|
||||
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE}
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes
|
||||
echo "${CODESPACES_ZSH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme
|
||||
fi
|
||||
# Shrink git while still enabling updates
|
||||
cd ${OH_MY_INSTALL_DIR}
|
||||
git repack -a -d -f --depth=1 --window=1
|
||||
|
||||
if [ "${USERNAME}" != "root" ]; then
|
||||
cp -rf ${USER_RC_FILE} ${OH_MY_INSTALL_DIR} /root
|
||||
chown -R ${USERNAME}:${USERNAME} ${USER_RC_PATH}
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
|
||||
echo "${RC_SNIPPET}" >> /etc/bash.bashrc
|
||||
RC_SNIPPET_ALREADY_ADDED="true"
|
||||
fi
|
||||
install-oh-my bash bashrc.osh-template https://github.com/ohmybash/oh-my-bash
|
||||
|
||||
# Optionally install and configure zsh
|
||||
if [ "${INSTALL_ZSH}" = "true" ] && [ ! -d "/root/.oh-my-zsh" ] && [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
|
||||
# Optionally install and configure zsh and Oh My Zsh!
|
||||
if [ "${INSTALL_ZSH}" = "true" ]; then
|
||||
if ! type zsh > /dev/null 2>&1; then
|
||||
apt-get-update-if-needed
|
||||
apt-get install -y zsh
|
||||
curl -fsSLo- https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash 2>&1
|
||||
echo "${RC_SNIPPET}" >> /etc/zsh/zshrc
|
||||
echo -e "DEFAULT_USER=\$USER\nprompt_context(){}" >> /root/.zshrc
|
||||
cp -fR /root/.oh-my-zsh /etc/skel
|
||||
cp -f /root/.zshrc /etc/skel
|
||||
sed -i -e "s/\/root\/.oh-my-zsh/\/home\/\$(whoami)\/.oh-my-zsh/g" /etc/skel/.zshrc
|
||||
if [ "${USERNAME}" != "root" ]; then
|
||||
cp -fR /etc/skel/.oh-my-zsh /etc/skel/.zshrc /home/$USERNAME
|
||||
chown -R $USER_UID:$USER_GID /home/$USERNAME/.oh-my-zsh /home/$USERNAME/.zshrc
|
||||
fi
|
||||
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
|
||||
echo "${RC_SNIPPET}" >> /etc/zsh/zshrc
|
||||
ZSH_ALREADY_INSTALLED="true"
|
||||
fi
|
||||
install-oh-my zsh zshrc.zsh-template https://github.com/ohmyzsh/ohmyzsh
|
||||
fi
|
||||
|
||||
# Write marker file
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ GIT_VERSION=${1:-"2.27.0"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CLI_VERSION=${1:-"latest"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_GO_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${GRADLE_VERSION}" = "lts" ] || [ "${GRADLE_VERSION}" = "latest" ] || [ "$
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${JAVA_VERSION}" = "lts" ]; then
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${MAVEN_VERSION}" = "lts" ] || [ "${MAVEN_VERSION}" = "current" ] || [ "${
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_PYTHON_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ INSTALL_RUBY_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPDATE_RUST=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/env bash
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Syntax: ./sshd-debian.sh [SSH Port (don't use 22)] [non-root user] [start sshd now flag] [new password for user]
|
||||
|
||||
# Note: You can change your user's password with "sudo passwd $(whoami)" (or just "passwd" if running as root).
|
||||
|
||||
SSHD_PORT=${1:-"2222"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
START_SSHD=${3:-"false"}
|
||||
NEW_PASSWORD=${4:-"skip"}
|
||||
|
||||
set -e
|
||||
|
||||
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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Treat a user name of "none" or non-existant user as root
|
||||
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
# Function to run apt-get if needed
|
||||
apt-get-update-if-needed()
|
||||
{
|
||||
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
|
||||
echo "Running apt-get update..."
|
||||
apt-get update
|
||||
else
|
||||
echo "Skipping apt-get update."
|
||||
fi
|
||||
}
|
||||
|
||||
# Ensure apt is in non-interactive to avoid prompts
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install openssh-server openssh-client
|
||||
if ! dpkg -s openssh-server openssh-client > /dev/null 2>&1; then
|
||||
apt-get-update-if-needed
|
||||
apt-get -y install --no-install-recommends openssh-server openssh-client
|
||||
fi
|
||||
|
||||
# Generate password if new password set to the word "random"
|
||||
if [ "${NEW_PASSWORD}" = "random" ]; then
|
||||
NEW_PASSWORD="$(openssl rand -hex 16)"
|
||||
EMIT_PASSWORD="true"
|
||||
fi
|
||||
|
||||
# If new password not set to skip, set it for the specified user
|
||||
if [ "${NEW_PASSWORD}" != "skip" ]; then
|
||||
echo "${USERNAME}:${NEW_PASSWORD}" | chpasswd
|
||||
if [ "${NEW_PASSWORD}" != "root" ]; then
|
||||
usermod -aG ssh ${USERNAME}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup sshd
|
||||
mkdir -p /var/run/sshd
|
||||
sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
|
||||
sed -i 's/#*PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||
sed -i -E "s/#*\s*Port\s+.+/Port ${SSHD_PORT}/g" /etc/ssh/sshd_config
|
||||
|
||||
# Write out a script that can be referenced as an ENTRYPOINT to auto-start sshd
|
||||
tee /usr/local/share/ssh-init.sh > /dev/null \
|
||||
<< EOF
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "\$(id -u)" -ne 0 ]; then
|
||||
sudo /etc/init.d/ssh restart
|
||||
else
|
||||
/etc/init.d/ssh restart
|
||||
fi
|
||||
|
||||
set +e
|
||||
exec "\$@"
|
||||
EOF
|
||||
chmod +x /usr/local/share/ssh-init.sh
|
||||
chown ${USERNAME}:ssh /usr/local/share/ssh-init.sh
|
||||
|
||||
# If we should start sshd now, do so
|
||||
if [ "${START_SSHD}" = "true" ]; then
|
||||
/usr/local/share/ssh-init.sh
|
||||
fi
|
||||
|
||||
# Write out result
|
||||
echo -e "Done!\n\n- Port: ${SSHD_PORT}\n- User: ${USERNAME}"
|
||||
if [ "${EMIT_PASSWORD}" = "true" ]; then
|
||||
echo "- Password: ${NEW_PASSWORD}"
|
||||
fi
|
||||
echo -e "\nForward port ${SSHD_PORT} to your local machine and run:\n\n ssh -p ${SSHD_PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${USERNAME}@localhost\n"
|
|
@ -15,6 +15,7 @@ definition-manifest.json
|
|||
.devcontainer/library-scripts/python-debian.sh
|
||||
.devcontainer/library-scripts/ruby-debian.sh
|
||||
.devcontainer/library-scripts/rust-debian.sh
|
||||
.devcontainer/library-scripts/sshd-debian.sh
|
||||
.devcontainer/library-scripts/README.md
|
||||
setup-user.sh
|
||||
symlinkDotNetCore.sh
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Summary
|
||||
|
||||
*Use or extend the default large, multi-language universal container for GitHub Codespaces.*
|
||||
*Use or extend the default, large, multi-language universal container for GitHub Codespaces.*
|
||||
|
||||
| Metadata | Value |
|
||||
|----------|-------|
|
||||
|
@ -20,7 +20,35 @@ While language specific development containers can be useful, in some cases you
|
|||
|
||||
If you use GitHub Codespaces, this is the "universal" image that is used by default if no custom Dockerfile or image is specified. If you like what you see but want to make a few additions or changes, you can use a custom Dockerfile to extend it and add whatever you need.
|
||||
|
||||
The container includes the `zsh` (and Oh My Zsh!) and `fish` shells that you can opt into using instead of the default `bash`. It also includes [nvm](https://github.com/nvm-sh/nvm) and [nvs](https://github.com/jasongin/nvs) if you need to install a different version of Node.js than those that are in the container by default.
|
||||
The container includes the `zsh` (and Oh My Zsh!) and `fish` shells that you can opt into using instead of the default `bash`. It also includes [nvm](https://github.com/nvm-sh/nvm), [rvm](https://rvm.io/), and [SDKMAN!](https://sdkman.io/) if you need to install a different version Node, Ruby, or Java tools than the container defaults. You can also set things up to access the container [via SSH](#accessing-the-container-using-ssh-scp-or-sshfs).
|
||||
|
||||
## Accessing the container using SSH, SCP, or SSHFS
|
||||
|
||||
This container also includes a running SSH server that you can use to access the contents if needed. To use it:
|
||||
|
||||
1. Create a codespace in [GitHub Codespaces](https://github.com/features/codespaces) (this is the default image) or open this container in Remote - Containers.
|
||||
|
||||
2. If you created a codespace using a web browser in GitHub Codespaces, setup the [VS Code extension and connect to it from your local VS Code](https://docs.github.com/en/github/developing-online-with-codespaces/connecting-to-your-codespace-from-visual-studio-code).
|
||||
|
||||
3. When connected to the codespace, use a terminal in VS Code to set a password when connecting:
|
||||
|
||||
```bash
|
||||
sudo passwd $(whoami)
|
||||
```
|
||||
|
||||
4. Press <kbd>F1</kbd> and select **Forward a Port...** and enter port `2222`.
|
||||
|
||||
5. You're all set! You can connect using SSH as follows:
|
||||
|
||||
```bash
|
||||
ssh -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null codespace@localhost
|
||||
```
|
||||
|
||||
The `-o` arguments are not required, but will avoid errors about the "known host" signature changing when doing this from multiple codespaces.
|
||||
|
||||
6. Enter the password you set in step 3.
|
||||
|
||||
That's it! Use similar arguments to those in step 5 when executing `scp` or configuring SSHFS.
|
||||
|
||||
## Using this definition with an existing folder
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"definitionVersion": "0.16.1",
|
||||
"definitionVersion": "0.17.0",
|
||||
"build": {
|
||||
"latest": true,
|
||||
"rootDistro": "debian",
|
||||
|
@ -48,7 +48,6 @@
|
|||
"ncdu",
|
||||
"man-db",
|
||||
"zsh",
|
||||
"yarn",
|
||||
"vim",
|
||||
"xtail",
|
||||
"fish",
|
||||
|
@ -72,6 +71,7 @@
|
|||
],
|
||||
"git": {
|
||||
"Oh My Zsh!": "/home/codespace/.oh-my-zsh",
|
||||
"Oh My Bash!": "/home/codespace/.oh-my-bash",
|
||||
"nvm": "/home/codespace/.nvm",
|
||||
"nvs": "/home/codespace/.nvs"
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_GO_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${GRADLE_VERSION}" = "lts" ] || [ "${GRADLE_VERSION}" = "latest" ] || [ "$
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${JAVA_VERSION}" = "lts" ]; then
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${MAVEN_VERSION}" = "lts" ] || [ "${MAVEN_VERSION}" = "current" ] || [ "${
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_PYTHON_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_PYTHON_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ INSTALL_RUBY_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPDATE_RUST=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USER_GID=${4:-1000}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -4,18 +4,33 @@
|
|||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag]
|
||||
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My *! flag]
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# 1. Add this file to .devcontainer/library-scripts
|
||||
#
|
||||
# 2. Add the following to .devcontainer/Dockerfile:
|
||||
#
|
||||
# COPY library-scripts/*.sh /tmp/library-scripts/
|
||||
# RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
||||
# && bash /tmp/library-scripts/common-debian.sh \
|
||||
# && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
#
|
||||
# You can optionally pass in arguments described above to common-debian.sh. Flags are a value of "true" or "false.
|
||||
# Pass in "none" for the username to skip the creation or modification of a non-root user while setting other arguments.
|
||||
|
||||
INSTALL_ZSH=${1:-"true"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
USER_UID=${3:-1000}
|
||||
USER_GID=${4:-1000}
|
||||
UPGRADE_PACKAGES=${5:-"true"}
|
||||
INSTALL_OH_MYS=${6:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -119,7 +134,7 @@ fi
|
|||
|
||||
# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
|
||||
# Common need for both applications and things like the agnoster ZSH theme.
|
||||
if [ "${LOCALE_ALREADY_SET}" != "true" ]; then
|
||||
if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
||||
locale-gen
|
||||
LOCALE_ALREADY_SET="true"
|
||||
|
@ -148,6 +163,13 @@ if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}"
|
|||
EXISTING_NON_ROOT_USER="${USERNAME}"
|
||||
fi
|
||||
|
||||
# ** Shell customization section **
|
||||
if [ "${USERNAME}" = "root" ]; then
|
||||
USER_RC_PATH="/root"
|
||||
else
|
||||
USER_RC_PATH="/home/${USERNAME}"
|
||||
fi
|
||||
|
||||
# .bashrc/.zshrc snippet
|
||||
RC_SNIPPET="$(cat << EOF
|
||||
export USER=\$(whoami)
|
||||
|
@ -160,27 +182,111 @@ fi
|
|||
EOF
|
||||
)"
|
||||
|
||||
# Ensure ~/.local/bin is in the PATH for root and non-root users for bash. (zsh is later)
|
||||
# Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
|
||||
CODESPACES_BASH="$(cat \
|
||||
<<EOF
|
||||
#!/usr/bin/env bash
|
||||
prompt() {
|
||||
if [ ! -z "\${GITHUB_USER}" ]; then
|
||||
local USERNAME="gh:@\${GITHUB_USER}"
|
||||
else
|
||||
local USERNAME="\$(whoami)"
|
||||
fi
|
||||
local cwd="\$(pwd | sed "s|^\${HOME}|~|")"
|
||||
if [ "\$?" != "0" ]; then
|
||||
local arrow_color=\${bold_red}
|
||||
else
|
||||
local arrow_color=\${reset_color}
|
||||
fi
|
||||
PS1="\${green}\${USERNAME} \${arrow_color}➜ \${blue}\${cwd}\${reset_color} \$(scm_prompt_info)$ "
|
||||
}
|
||||
SCM_THEME_PROMPT_PREFIX="\${cyan}(\${bold_red}"
|
||||
SCM_THEME_PROMPT_SUFFIX="\${reset_color} "
|
||||
SCM_THEME_PROMPT_DIRTY=" \${yellow}✗\${cyan})"
|
||||
SCM_THEME_PROMPT_CLEAN="\${cyan})"
|
||||
SCM_GIT_SHOW_MINIMAL_INFO="true"
|
||||
safe_append_prompt_command prompt
|
||||
EOF
|
||||
)"
|
||||
CODESPACES_ZSH="$(cat \
|
||||
<<EOF
|
||||
prompt() {
|
||||
if [ ! -z "\${GITHUB_USER}" ]; then
|
||||
local USERNAME="gh:@\${GITHUB_USER}"
|
||||
else
|
||||
local USERNAME="\$(whoami)"
|
||||
fi
|
||||
PROMPT="%{\$fg[green]%}\${USERNAME} %(?:%{\$reset_color%}➜ :%{\$fg_bold[red]%}➜ )"
|
||||
PROMPT+='%{\$fg[blue]%}%~%{\$reset_color%} \$(git_prompt_info)$ '
|
||||
}
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{\$fg[cyan]%}(%{\$fg_bold[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{\$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{\$fg[yellow]%}✗%{\$fg[cyan]%})"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{\$fg[cyan]%})"
|
||||
prompt
|
||||
EOF
|
||||
)"
|
||||
|
||||
# Adapted Oh My Zsh! install step to work with both "Oh Mys" rather than relying on an installer script
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for offical script.
|
||||
install-oh-my()
|
||||
{
|
||||
local OH_MY=$1
|
||||
local OH_MY_INSTALL_DIR="${USER_RC_PATH}/.oh-my-${OH_MY}"
|
||||
local TEMPLATE="${OH_MY_INSTALL_DIR}/templates/$2"
|
||||
local OH_MY_GIT_URL=$3
|
||||
local USER_RC_FILE="${USER_RC_PATH}/.${OH_MY}rc"
|
||||
|
||||
if [ -d "${OH_MY_INSTALL_DIR}" ] || [ "${INSTALL_OH_MYS}" != "true" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
umask g-w,o-w
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}
|
||||
git clone --depth=1 \
|
||||
-c core.eol=lf \
|
||||
-c core.autocrlf=false \
|
||||
-c fsck.zeroPaddedFilemode=ignore \
|
||||
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
||||
-c receive.fsck.zeroPaddedFilemode=ignore \
|
||||
${OH_MY_GIT_URL} ${OH_MY_INSTALL_DIR} 2>&1
|
||||
echo -e "$(cat "${TEMPLATE}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE}
|
||||
if [ "${OH_MY}" = "bash" ]; then
|
||||
sed -i -e 's/OSH_THEME=.*/OSH_THEME="codespaces"/g' ${USER_RC_FILE}
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes/codespaces
|
||||
echo "${CODESPACES_BASH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces/codespaces.theme.sh
|
||||
else
|
||||
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE}
|
||||
mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes
|
||||
echo "${CODESPACES_ZSH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme
|
||||
fi
|
||||
# Shrink git while still enabling updates
|
||||
cd ${OH_MY_INSTALL_DIR}
|
||||
git repack -a -d -f --depth=1 --window=1
|
||||
|
||||
if [ "${USERNAME}" != "root" ]; then
|
||||
cp -rf ${USER_RC_FILE} ${OH_MY_INSTALL_DIR} /root
|
||||
chown -R ${USERNAME}:${USERNAME} ${USER_RC_PATH}
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
|
||||
echo "${RC_SNIPPET}" >> /etc/bash.bashrc
|
||||
RC_SNIPPET_ALREADY_ADDED="true"
|
||||
fi
|
||||
install-oh-my bash bashrc.osh-template https://github.com/ohmybash/oh-my-bash
|
||||
|
||||
# Optionally install and configure zsh
|
||||
if [ "${INSTALL_ZSH}" = "true" ] && [ ! -d "/root/.oh-my-zsh" ] && [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
|
||||
# Optionally install and configure zsh and Oh My Zsh!
|
||||
if [ "${INSTALL_ZSH}" = "true" ]; then
|
||||
if ! type zsh > /dev/null 2>&1; then
|
||||
apt-get-update-if-needed
|
||||
apt-get install -y zsh
|
||||
curl -fsSLo- https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash 2>&1
|
||||
echo "${RC_SNIPPET}" >> /etc/zsh/zshrc
|
||||
echo -e "DEFAULT_USER=\$USER\nprompt_context(){}" >> /root/.zshrc
|
||||
cp -fR /root/.oh-my-zsh /etc/skel
|
||||
cp -f /root/.zshrc /etc/skel
|
||||
sed -i -e "s/\/root\/.oh-my-zsh/\/home\/\$(whoami)\/.oh-my-zsh/g" /etc/skel/.zshrc
|
||||
if [ "${USERNAME}" != "root" ]; then
|
||||
cp -fR /etc/skel/.oh-my-zsh /etc/skel/.zshrc /home/$USERNAME
|
||||
chown -R $USER_UID:$USER_GID /home/$USERNAME/.oh-my-zsh /home/$USERNAME/.zshrc
|
||||
fi
|
||||
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
|
||||
echo "${RC_SNIPPET}" >> /etc/zsh/zshrc
|
||||
ZSH_ALREADY_INSTALLED="true"
|
||||
fi
|
||||
install-oh-my zsh zshrc.zsh-template https://github.com/ohmyzsh/ohmyzsh
|
||||
fi
|
||||
|
||||
# Write marker file
|
||||
|
|
|
@ -15,7 +15,7 @@ UPGRADE_PACKAGES=${5:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ PACKAGE_LIST="
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ USERNAME=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ NONROOT_USER=${4:-"vscode"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ GIT_VERSION=${1:-"2.27.0"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CLI_VERSION=${1:-"latest"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_GO_TOOLS=${6:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${GRADLE_VERSION}" = "lts" ] || [ "${GRADLE_VERSION}" = "latest" ] || [ "$
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${JAVA_VERSION}" = "lts" ]; then
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if [ "${MAVEN_VERSION}" = "lts" ] || [ "${MAVEN_VERSION}" = "current" ] || [ "${
|
|||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ UPDATE_RC=${4:-"true"}
|
|||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e 'Script must be run a 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.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче