init
This commit is contained in:
commit
c5feb3196d
26
user/README.md
Normal file
26
user/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
# user (user)
|
||||||
|
|
||||||
|
Create a user and group with the same id.
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```json
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/davzucky/devcontainers-features-wolfi/user:1": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
| Options Id | Description | Type | Default Value |
|
||||||
|
|-----|-----|-----|-----|
|
||||||
|
| username | Enter name of a non-root user to configure or none to skip | string | automatic |
|
||||||
|
| userUid | Enter UID for non-root user | string | automatic |
|
||||||
|
| userGid | Enter GID for non-root user | string | automatic |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/davzucky/devcontainers-features-wolfi/blob/main/src/user/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
|
39
user/devcontainer-feature.json
Normal file
39
user/devcontainer-feature.json
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "user",
|
||||||
|
"id": "user",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "Create a user and group with the same id.",
|
||||||
|
"documentationURL": "https://github.com/davzucky/devcontainers-features-wolfi/tree/main/src/user",
|
||||||
|
"options": {
|
||||||
|
"username": {
|
||||||
|
"type": "string",
|
||||||
|
"proposals": [
|
||||||
|
"devcontainer",
|
||||||
|
"vscode",
|
||||||
|
"codespace",
|
||||||
|
"none",
|
||||||
|
"automatic"
|
||||||
|
],
|
||||||
|
"default": "automatic",
|
||||||
|
"description": "Enter name of a non-root user to configure or none to skip"
|
||||||
|
},
|
||||||
|
"userUid": {
|
||||||
|
"type": "string",
|
||||||
|
"proposals": [
|
||||||
|
"1001",
|
||||||
|
"automatic"
|
||||||
|
],
|
||||||
|
"default": "automatic",
|
||||||
|
"description": "Enter UID for non-root user"
|
||||||
|
},
|
||||||
|
"userGid": {
|
||||||
|
"type": "string",
|
||||||
|
"proposals": [
|
||||||
|
"1001",
|
||||||
|
"automatic"
|
||||||
|
],
|
||||||
|
"default": "automatic",
|
||||||
|
"description": "Enter GID for non-root user"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
user/install.sh
Normal file
29
user/install.sh
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
USERNAME="${_BUILD_ARG_USERNAME:-"automatic"}"
|
||||||
|
USER_UID="${_BUILD_ARG_UID:-"automatic"}"
|
||||||
|
USER_GID="${_BUILD_ARG_GID:-"automatic"}"
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y sudo passwd
|
||||||
|
|
||||||
|
if [ "$USERNAME" = "auto" ] || [ "$USERNAME" = "automatic" ]; then
|
||||||
|
for name in devcontainer vscode node codespace; do
|
||||||
|
if id -u "$name" >/dev/null 2>&1; then
|
||||||
|
USERNAME="$name"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ -z "$USERNAME" ] && USERNAME="vscode"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if id -u "$USERNAME" >/dev/null 2>&1; then
|
||||||
|
[ "$USER_GID" != "automatic" ] && groupmod -g "$USER_GID" "$(id -gn "$USERNAME")"
|
||||||
|
[ "$USER_UID" != "automatic" ] && usermod -u "$USER_UID" "$USERNAME"
|
||||||
|
else
|
||||||
|
[ "$USER_GID" = "automatic" ] && groupadd "$USERNAME" || groupadd -g "$USER_GID" "$USERNAME"
|
||||||
|
[ "$USER_UID" = "automatic" ] && useradd -m -s /bin/bash -g "$USERNAME" "$USERNAME" || useradd -m -s /bin/bash -u "$USER_UID" -g "$USERNAME" "$USERNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$USERNAME" != "root" ] && echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && chmod 0440 /etc/sudoers.d/$USERNAME
|
Loading…
x
Reference in New Issue
Block a user