Skip to content

Commit 1449f41

Browse files
authored
Remove duplicate env var sourcing for codespaces (#481)
* Remove duplicate env var sourcing for codespaces
1 parent adf7240 commit 1449f41

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

src/sshd/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "sshd",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"name": "SSH server",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/sshd",
66
"description": "Adds a SSH server into a container so that you can use an external terminal, sftp, or SSHFS to interact with it.",

src/sshd/install.sh

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ SSHD_PORT="${SSHD_PORT:-"2222"}"
1313
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
1414
START_SSHD="${START_SSHD:-"false"}"
1515
NEW_PASSWORD="${NEW_PASSWORD:-"skip"}"
16-
FIX_ENVIRONMENT="${FIX_ENVIRONMENT:-"true"}"
1716

1817
set -e
1918

@@ -93,35 +92,6 @@ sed -i -E "s/#*\s*Port\s+.+/Port ${SSHD_PORT}/g" /etc/ssh/sshd_config
9392
# Need to UsePAM so /etc/environment is processed
9493
sed -i -E "s/#?\s*UsePAM\s+.+/UsePAM yes/g" /etc/ssh/sshd_config
9594

96-
# Script to store variables that exist at the time the ENTRYPOINT is fired
97-
store_env_script="$(cat << 'EOF'
98-
# Wire in codespaces secret processing to zsh if present (since may have been added to image after script was run)
99-
if [ -f /etc/zsh/zlogin ] && ! grep '/etc/profile.d/00-restore-secrets.sh' /etc/zsh/zlogin > /dev/null 2>&1; then
100-
echo -e "if [ -f /etc/profile.d/00-restore-secrets.sh ]; then . /etc/profile.d/00-restore-secrets.sh; fi\n$(cat /etc/zsh/zlogin 2>/dev/null || echo '')" | sudoIf tee /etc/zsh/zlogin > /dev/null
101-
fi
102-
EOF
103-
)"
104-
105-
# Script to ensure login shells get the latest Codespaces secrets
106-
restore_secrets_script="$(cat << 'EOF'
107-
#!/bin/sh
108-
if [ "${CODESPACES}" != "true" ] || [ "${VSCDC_FIXED_SECRETS}" = "true" ] || [ ! -z "${GITHUB_CODESPACES_TOKEN}" ]; then
109-
# Not codespaces, already run, or secrets already in environment, so return
110-
return
111-
fi
112-
if [ -f /workspaces/.codespaces/shared/.env-secrets ]; then
113-
while read line
114-
do
115-
key=$(echo $line | sed "s/=.*//")
116-
value=$(echo $line | sed "s/$key=//1")
117-
decodedValue=$(echo $value | base64 -d)
118-
export $key="$decodedValue"
119-
done < /workspaces/.codespaces/shared/.env-secrets
120-
fi
121-
export VSCDC_FIXED_SECRETS=true
122-
EOF
123-
)"
124-
12595
# Write out a scripts that can be referenced as an ENTRYPOINT to auto-start sshd and fix login environments
12696
tee /usr/local/share/ssh-init.sh > /dev/null \
12797
<< 'EOF'
@@ -141,15 +111,6 @@ sudoIf()
141111
}
142112
143113
EOF
144-
if [ "${FIX_ENVIRONMENT}" = "true" ]; then
145-
echo "${store_env_script}" >> /usr/local/share/ssh-init.sh
146-
echo "${restore_secrets_script}" > /etc/profile.d/00-restore-secrets.sh
147-
chmod +x /etc/profile.d/00-restore-secrets.sh
148-
# Wire in zsh if present
149-
if type zsh > /dev/null 2>&1; then
150-
echo -e "if [ -f /etc/profile.d/00-restore-secrets.sh ]; then . /etc/profile.d/00-restore-secrets.sh; fi\n$(cat /etc/zsh/zlogin 2>/dev/null || echo '')" > /etc/zsh/zlogin
151-
fi
152-
fi
153114
tee -a /usr/local/share/ssh-init.sh > /dev/null \
154115
<< 'EOF'
155116

0 commit comments

Comments
 (0)