-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76d048b
commit 192e4f0
Showing
3 changed files
with
46 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Source the environment variables from env.sh | ||
if [ -f /tmp/env.sh ]; then | ||
. /tmp/env.sh | ||
else | ||
echo "env.sh not found!" | ||
fi | ||
|
||
if [ "${ALLOW_SHELL_HISTORY}" = "true" ]; then | ||
echo "Activating feature 'shell-history'" | ||
echo "User: ${USERNAME} User home: ${user_home}" | ||
|
||
# Create the shell history directory in the mounted volume | ||
HISTORY_DIR="/devcontainers/${DEVCONTAINER_ID}/shellHistory" | ||
USER_HISTORY_FILE="${user_home}/.bash_history" | ||
VOLUME_HISTORY_FILE="${HISTORY_DIR}/.bash_history" | ||
|
||
# Create the history directory in the volume, if it doesn’t already exist | ||
sudo mkdir -p "${HISTORY_DIR}" | ||
sudo chown -R "${USERNAME}" "${HISTORY_DIR}" | ||
sudo chmod -R u+rwx "${HISTORY_DIR}" | ||
|
||
# Ensure the volume's history file exists and set permissions | ||
sudo touch "${VOLUME_HISTORY_FILE}" | ||
sudo chown -R "${USERNAME}" "${VOLUME_HISTORY_FILE}" | ||
sudo chmod -R u+rwx "${VOLUME_HISTORY_FILE}" | ||
|
||
# Symlink for Bash history | ||
sudo ln -sf ${USER_HISTORY_FILE} ${VOLUME_HISTORY_FILE} | ||
|
||
# Configure immediate history saving to the volume | ||
echo 'PROMPT_COMMAND="history -a; history -r;"' >> "${user_home}/.bashrc" | ||
|
||
echo "Shell history setup for persistent appending is complete." | ||
fi |