Skip to content

Commit

Permalink
remove /etc/profile.d/00-restore-env.sh (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt authored Jul 12, 2023
1 parent 98fbb2d commit 9949e14
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 94 deletions.
5 changes: 0 additions & 5 deletions features/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
5 changes: 0 additions & 5 deletions features/src/cmake/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/cmake/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CMake",
"id": "cmake",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install CMake",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/cuda/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/cuda/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CUDA Toolkit",
"id": "cuda",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install the NVIDIA CUDA Toolkit",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/gcc/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/gcc/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "GCC",
"id": "gcc",
"version": "23.8.1",
"version": "23.8.2",
"description": "A feature to install gcc",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/gitlab-cli/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/gitlab-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "gitlab-cli",
"version": "23.8.0",
"version": "23.8.1",
"name": "GitLab CLI",
"documentationURL": "https://github.com/rapidsai/devcontainers/features/tree/main/src/gitlab-cli",
"description": "Installs the GitLab CLI. Auto-detects latest version and installs needed dependencies.",
Expand Down
5 changes: 0 additions & 5 deletions features/src/llvm/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/llvm/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "LLVM compilers and tools",
"id": "llvm",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install LLVM compilers and tools",
"options": {
"version": {
Expand Down
2 changes: 1 addition & 1 deletion features/src/mambaforge/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export MAMBA_NO_BANNER="${MAMBA_NO_BANNER:-1}";

for default_conda_env_name in ${DEFAULT_CONDA_ENV:-} ${CONDA_DEFAULT_ENV:-} base; do
if [ -z "${default_conda_env_name:-}" ]; then continue; fi
if echo "${CONDA_PROMPT_MODIFIER:-}" | grep -qF "($default_conda_env_name)"; then
if grep -qF "(${default_conda_env_name})" <<< "${CONDA_PROMPT_MODIFIER:-}"; then
break;
fi
conda activate "$default_conda_env_name" 2>/dev/null && break || continue;
Expand Down
5 changes: 0 additions & 5 deletions features/src/mambaforge/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/mambaforge/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Mambaforge",
"id": "mambaforge",
"version": "23.8.3",
"version": "23.8.4",
"description": "A feature to install mambaforge",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/ninja/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/ninja/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Ninja build",
"id": "ninja",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install ninja-build",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/nvhpc/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/nvhpc/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "NVHPC SDK",
"id": "nvhpc",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install the NVHPC SDK",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/oneapi/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/oneapi/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Intel oneapi toolchain",
"id": "oneapi",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install the Intel oneapi toolchain",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/python-lit/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/python-lit/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "python-lit testing framework",
"id": "python-lit",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install python-lit",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/rapids-build-utils/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/rapids-build-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "NVIDIA RAPIDS devcontainer build utilities",
"id": "rapids-build-utils",
"version": "23.8.2",
"version": "23.8.3",
"description": "A feature to install the RAPIDS devcontainer build utilities",
"containerEnv": {
"BASH_ENV": "/etc/bash.bash_env"
Expand Down
5 changes: 0 additions & 5 deletions features/src/rust/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/rust/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "rust",
"version": "23.8.0",
"version": "23.8.1",
"name": "Rust",
"documentationURL": "https://github.com/rapidsai/devcontainers/features/tree/main/src/rust",
"description": "Installs Rust, common Rust utilities, and their required dependencies",
Expand Down
5 changes: 0 additions & 5 deletions features/src/sccache/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/sccache/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sccache",
"id": "sccache",
"version": "23.8.0",
"version": "23.8.1",
"description": "A feature to install sccache",
"options": {
"version": {
Expand Down
5 changes: 0 additions & 5 deletions features/src/utils/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export BASH_ENV=/etc/bash.bash_env;
EOF
)";

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

if ! grep -qE '^BASH_ENV=/etc/bash.bash_env$' /etc/environment; then
echo "BASH_ENV=/etc/bash.bash_env" >> /etc/environment;
fi
Expand Down
2 changes: 1 addition & 1 deletion features/src/utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "devcontainer-utils",
"id": "utils",
"version": "23.8.4",
"version": "23.8.5",
"description": "A feature to install RAPIDS devcontainer utility scripts",
"containerEnv": {
"BASH_ENV": "/etc/bash.bash_env"
Expand Down
20 changes: 16 additions & 4 deletions features/src/utils/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ for dir in $(for_each_user_bashrc 'echo "$(dirname "$(realpath -m "$0")")"'); do
# Create ~/.cache, i.e. $XDG_CONFIG_HOME
mkdir -p -m 0755 "${dir}"/.config/{clangd,pip};
# Create ~/.local/state, i.e. $XDG_STATE_HOME
mkdir -p -m 0755 "${dir}"/.local/{bin,state};
mkdir -p -m 0755 "${dir}"/.local/state;
# Create or update ~/.ssh/known_hosts
mkdir -p -m 0700 "${dir}"/.ssh;
touch "${dir}"/.ssh/known_hosts;
Expand All @@ -111,14 +111,26 @@ ${known_hosts}
____EOF
done

rm -rf /root/.cache;
rm -rf /root/.local/{bin,state};
rm -rf /root/.config/{clangd,pip};

# Find the non-root user
find_non_root_user;

USERHOME="$(bash -c "echo ~${USERNAME}")";

# Add user to the crontab group
usermod -aG crontab ${USERNAME};
usermod -aG crontab "${USERNAME}";

# Allow user to edit the crontab
echo ${USERNAME} >> /etc/cron.allow;
echo "${USERNAME}" >> /etc/cron.allow;

# Create ~/.cache, i.e. $XDG_CONFIG_HOME
mkdir -p -m 0755 "${USERHOME}"/.local/bin;

# Ensure the user owns their homedir
chown -R ${USERNAME}:${USERNAME} "$(bash -c "echo ~${USERNAME}")";
chown -R "${USERNAME}:${USERNAME}" "${USERHOME}";

# Generate bash completions
if dpkg -s bash-completion >/dev/null 2>&1; then
Expand Down

0 comments on commit 9949e14

Please sign in to comment.