Skip to content

Commit

Permalink
refactor!: remove the feature to change the default non-root user nam…
Browse files Browse the repository at this point in the history
…e via `USER` env var (#891)

Fix #489
Close #889
  • Loading branch information
eitsupi authored Dec 19, 2024
1 parent bc7a8ee commit b7509ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
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

0 comments on commit b7509ce

Please sign in to comment.