generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from joshuanianji/support-zsh
Support ZSH
- Loading branch information
Showing
56 changed files
with
678 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,47 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "Activating feature 'aws-cli-persistence'" | ||
FEATURE_ID="aws-cli-persistence" | ||
|
||
echo "Activating feature '$FEATURE_ID'" | ||
echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" | ||
|
||
if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then | ||
echo "***********************************************************************************" | ||
echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" | ||
echo "***********************************************************************************" | ||
exit 1 | ||
if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then | ||
echo "***********************************************************************************" | ||
echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" | ||
echo "***********************************************************************************" | ||
exit 1 | ||
fi | ||
|
||
# make /dc/aws-cli folder if doesn't exist | ||
mkdir -p "/dc/aws-cli" | ||
|
||
# as to why we move around the folder, check `github-cli-persistence/install.sh` | ||
if [ -e "$_REMOTE_USER_HOME/.aws" ]; then | ||
echo "Moving existing .aws folder to .aws-old" | ||
mv "$_REMOTE_USER_HOME/.aws" "$_REMOTE_USER_HOME/.aws-old" | ||
echo "Moving existing .aws folder to .aws-old" | ||
mv "$_REMOTE_USER_HOME/.aws" "$_REMOTE_USER_HOME/.aws-old" | ||
fi | ||
|
||
ln -s /dc/aws-cli "$_REMOTE_USER_HOME/.aws" | ||
# chown .aws folder | ||
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.aws" | ||
|
||
# chown mount (only attached on startup) | ||
cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" | ||
sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/aws-cli | ||
# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook | ||
# Looks like this is the best way to run a script in lifecycle hooks | ||
# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 | ||
POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" | ||
|
||
tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ | ||
<<'EOF' | ||
#!/bin/sh | ||
set -e | ||
# if the user is not root, chown /dc/aws-cli to the user | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "Running post-start.sh for user $USER" | ||
sudo chown -R "$USER:$USER" /dc/aws-cli | ||
fi | ||
EOF | ||
chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc | ||
|
||
chmod 755 "$POST_CREATE_SCRIPT_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,50 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "Activating feature 'github-cli-persistence'" | ||
FEATURE_ID="github-cli-persistence" | ||
|
||
echo "Activating feature '$FEATURE_ID'" | ||
echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" | ||
|
||
if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then | ||
echo "***********************************************************************************" | ||
echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" | ||
echo "***********************************************************************************" | ||
exit 1 | ||
if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then | ||
echo "***********************************************************************************" | ||
echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" | ||
echo "***********************************************************************************" | ||
exit 1 | ||
fi | ||
|
||
# make ~/.config folder if doesn't exist | ||
mkdir -p "$_REMOTE_USER_HOME/.config" | ||
mkdir -p "/dc/github-cli" | ||
|
||
# if `.config/gh` already exists, the `ln -s` command will create an extra | ||
# if `.config/gh` already exists, the `ln -s` command will create an extra | ||
# folder *inside* `.config/gh` that symlinks to `github-cli` | ||
# Thus, we want to make sure the folder does NOT exist so the symlink will actually be to ~/.config/gh | ||
if [ -e "$_REMOTE_USER_HOME/.config/gh" ]; then | ||
echo "Moving existing gh folder to gh-old" | ||
mv "$_REMOTE_USER_HOME/.config/gh" "$_REMOTE_USER_HOME/.config/gh-old" | ||
echo "Moving existing gh folder to gh-old" | ||
mv "$_REMOTE_USER_HOME/.config/gh" "$_REMOTE_USER_HOME/.config/gh-old" | ||
fi | ||
|
||
ln -s /dc/github-cli "$_REMOTE_USER_HOME/.config/gh" | ||
# chown the entire `.config` folder because devcontainers creates | ||
# a `~/.config/vscode-dev-containers` folder later on | ||
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" | ||
# chown the entire `.config` folder because devcontainers creates | ||
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config/gh" | ||
|
||
# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook | ||
# Looks like this is the best way to run a script in lifecycle hooks | ||
# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 | ||
POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" | ||
|
||
tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ | ||
<<'EOF' | ||
#!/bin/sh | ||
# chown mount (only attached on startup) | ||
cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" | ||
sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/github-cli | ||
set -e | ||
# if the user is not root, chown /dc/aws-cli to the user | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "Running post-start.sh for user $USER" | ||
sudo chown -R "$USER:$USER" /dc/github-cli | ||
fi | ||
EOF | ||
chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc | ||
|
||
chmod 755 "$POST_CREATE_SCRIPT_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.