Unverified Commit 025cae18 authored by Nebula's avatar Nebula Committed by GitHub

Fix profile not downloading (#876)

* Fix profile not downloading

Since the powershell folder is owned by root, the profile download fails without becoming sudo first.
```
ls -l /opt/microsoft/powershell/
total 0
drwxr-xr-x. 1 root root 22 Feb 23 08:37 7
```

* Update install.sh

* Update install.sh

* Fix: Add missing quote

* Update install.sh

* Update src/powershell/install.sh
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>

* Update install.sh

* Update patch version in devcontainer-feature.json

---------
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>
parent 5ca92d26
{
"id": "powershell",
"version": "1.3.1",
"version": "1.3.2",
"name": "PowerShell",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell",
"description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
......
......@@ -12,6 +12,8 @@ set -e
# Clean up
rm -rf /var/lib/apt/lists/*
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
POWERSHELL_VERSION=${VERSION:-"latest"}
POWERSHELL_MODULES="${MODULES:-""}"
POWERSHELL_PROFILE_URL="${PROFILE_URL}"
......@@ -163,10 +165,26 @@ if [ ${#POWERSHELL_MODULES[@]} -gt 0 ]; then
done
fi
# Determine the appropriate non-root user
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
USERNAME=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
USERNAME=${CURRENT_USER}
break
fi
done
if [ "${USERNAME}" = "" ]; then
USERNAME=root
fi
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
# If URL for powershell profile is provided, download it to '/opt/microsoft/powershell/7/profile.ps1'
if [ -n "$POWERSHELL_PROFILE_URL" ]; then
echo "Downloading PowerShell Profile from: $POWERSHELL_PROFILE_URL"
curl -sSL -o "/opt/microsoft/powershell/7/profile.ps1" "$POWERSHELL_PROFILE_URL"
su ${USERNAME} -c "curl -sSL -o '/opt/microsoft/powershell/7/profile.ps1' '$POWERSHELL_PROFILE_URL'"
fi
# Clean up
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment