Compare commits

...

4 Commits

3 changed files with 75 additions and 13 deletions

View File

@ -1,11 +1,47 @@
#!/bin/bash #!/bin/bash
if [[ -z "${HOME_USER}" ]]; then #if [[ -z "${HOME_USER}" ]]; then
HOME_USER="vscode" #HOME_USER="vscode"
#fi
set -e
# use specified user name or use `vscode` if not specified
HOME_USER="${HOME_USER:-vscode}"
# use specified group name or use the same user name also as the group name
MY_GROUP="${MY_GROUP:-${HOME_USER}}"
# use the specified UID for the user
MY_UID="${MY_UID:-1000}"
# use the specified GID for the user
MY_GID="${MY_GID:-${MY_UID}}"
# check to see if group exists; if not, create it
if grep -q -E "^${MY_GROUP}:" /etc/group > /dev/null 2>&1
then
echo "INFO: Group exists; skipping creation"
else
echo "INFO: Group doesn't exist; creating..."
# create the group
sudo addgroup -g "${MY_GID}" "${MY_GROUP}" || (echo "INFO: Group exists but with a different name; renaming..."; sudo groupmod -g "${MY_GID}" -n "${MY_GROUP}" "$(awk -F ':' '{print $1":"$3}' < /etc/group | grep ":${MY_GID}$" | awk -F ":" '{print $1}')")
fi fi
addgroup nonroot
adduser --disabled-password --gecos "" ${HOME_USER} # check to see if user exists; if not, create it
echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers if id -u "${HOME_USER}" > /dev/null 2>&1
then
echo "INFO: User exists; skipping creation"
else
echo "INFO: User doesn't exist; creating..."
# create the user
sudo adduser -u "${MY_UID}" -G "${MY_GROUP}" -h "/home/${HOME_USER}" -s /bin/sh -D "${HOME_USER}"
fi
# addgroup nonroot
#adduser --disabled-password --gecos "" ${HOME_USER}
# echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
#Creating extensions folder #Creating extensions folder
sudo mkdir /home/${HOME_USER}/.config/Code sudo mkdir /home/${HOME_USER}/.config/Code
@ -20,8 +56,8 @@ if [ -f "/home/extensions.json" ]; then
# Read the JSON file into a variable # Read the JSON file into a variable
jsonExtensions=$(cat /home/extensions.json) jsonExtensions=$(cat /home/extensions.json)
# Use jq to extract the array elements # Use jq to extract the extension parameter from the JSON array
extensions=$(echo $jsonExtensions | jq -r '.[]') extensions=$(echo $jsonExtensions | jq -r '.[].extensionsGroup.extensions[].uniqueIdentifier')
# Loop through the extensions and process each element # Loop through the extensions and process each element
for extension in $extensions; do for extension in $extensions; do

View File

@ -19,12 +19,38 @@ The following environment variables can be set when running the Docker container
### Adding VSCode Extensions ### Adding VSCode Extensions
To add VSCode extensions to the container, create a JSON file with an array of strings containing the extension identifier of each extension you want to install. For example: To add VSCode extensions to the container, create a JSON file with an array of objects containing the extension details you want to install, the only Mandatory field is uniqueIdentifier and follow this structure. For example:
``` ```
[ [
"ms-python.python", {
"ms-vscode.cpptools", "extensionsGroup": {
"ms-azuretools.vscode-docker" "description": "Extensions of Spanish Language Pack",
"extensions": [
{
"name": "Spanish Language Pack for Visual Studio Code",
"notes": "Extension of Spanish Language Pack for Visual Studio Code",
"uniqueIdentifier": "ms-ceintl.vscode-language-pack-es"
}
]
}
},
{
"extensionsGroup": {
"description": "Extensions of Github Copilot",
"extensions": [
{
"name": "GitHub Copilot",
"notes": "Extension of GitHub Copilot",
"uniqueIdentifier": "github.copilot"
},
{
"name": "GitHub Copilot Chat",
"notes": "Extension of GitHub Copilot Chat",
"uniqueIdentifier": "github.copilot-chat"
}
]
}
}
] ]
``` ```

View File

@ -1 +1 @@
1.0.25 1.1.3