CommonUtils - ensure home directory exists. (#398)

* CommonUtils - ensure home directory exists.

* Only create non-root home directory

Root directory will always exist.

* Bump version
This commit is contained in:
Stephen A. Imhoff 2023-01-13 11:05:53 -08:00 committed by GitHub
parent 74dd2710dc
commit 1726222515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{ {
"id": "common-utils", "id": "common-utils",
"version": "2.0.6", "version": "2.0.7",
"name": "Common Utilities", "name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",

View file

@ -383,6 +383,10 @@ if [ "${USERNAME}" = "root" ]; then
user_rc_path="/root" user_rc_path="/root"
else else
user_rc_path="/home/${USERNAME}" user_rc_path="/home/${USERNAME}"
if [ ! -d "${user_rc_path}" ]; then
mkdir -p "${user_rc_path}"
chown ${USERNAME}:${group_name} "${user_rc_path}"
fi
fi fi
# Restore user .bashrc / .profile / .zshrc defaults from skeleton file if it doesn't exist or is empty # Restore user .bashrc / .profile / .zshrc defaults from skeleton file if it doesn't exist or is empty