Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove the feature to change the default non-root user name via USER env var #891

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# News

## 2024-12

### Changes in pre-built images

- The feature to change the name of the default non-root user via the `USER` environment variable has been removed.
([#891](https://github.com/rocker-org/rocker-versioned2/pull/891))\
If you want to change the default user name, you should creat a new user.
For example, something like this:

```dockerfile
FROM rocker/rstudio:4
ENV DEFAULT_USER=new_user
RUN <<EOF
if grep -q "1000" /etc/passwd; then
userdel --remove "$(id -un 1000)";
fi
/rocker_scripts/default_user.sh
EOF
```

## 2024-04

The repository has been completely reorganized.
Expand Down
20 changes: 1 addition & 19 deletions scripts/init_userconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Set defaults for environmental variables in case they are undefined
DEFAULT_USER=${DEFAULT_USER:-rstudio}
USER=${USER:=${DEFAULT_USER}}
USER=${DEFAULT_USER}
USERID=${USERID:=1000}
GROUPID=${GROUPID:=1000}
ROOT=${ROOT:=FALSE}
Expand Down Expand Up @@ -144,15 +144,6 @@ elif [ "$USERID" -lt 1000 ]; then # Probably a macOS user, https://github.com/ro
fi
fi

if [ "${RUNROOTLESS}" != "true" ] && [ "$USER" != "$DEFAULT_USER" ]; then
printf "\n\n"
tput bold
printf "Settings by \e[31m\`-e USER=<new username>\`\e[39m is now deprecated and will be removed in the future.\n"
printf "Please do not use the USER environment variable.\n"
tput sgr0
printf "\n\n"
fi

if [ "${RUNROOTLESS}" = "true" ]; then
echo "deleting the default user ($DEFAULT_USER) since it is not needed."
userdel "$DEFAULT_USER"
Expand All @@ -164,15 +155,6 @@ elif [ "$USERID" -ne 1000 ]; then ## Configure user with a different USERID if r
mkdir -p "${USERHOME}"
chown -R "$USER" "${USERHOME}"
usermod -a -G staff "$USER"
elif [ "$USER" != "$DEFAULT_USER" ]; then
## cannot move home folder when it's a shared volume, have to copy and change permissions instead
cp -r /home/"$DEFAULT_USER" "${USERHOME}"
## RENAME the user
usermod -l "$USER" -d /home/"$USER" "$DEFAULT_USER"
groupmod -n "$USER" "$DEFAULT_USER"
usermod -a -G staff "$USER"
chown -R "$USER":"$USER" "${USERHOME}"
echo "USER is now $USER"
fi

if [ "${RUNROOTLESS}" != "true" ] && [ "$GROUPID" -ne 1000 ]; then ## Configure the primary GID (whether rstudio or $USER) with a different GROUPID if requested.
Expand Down