Skip to content

Commit af58adb

Browse files
authored
Update entrypoint to always run a login shell
Previously, when no EXECAPP neither DARGS were defined a non-login shell was used. That was causing an inconsistent behaviour, specially regarding the init (bashrc _vs_ profile) scripts. Now, every run mode is using a login shell (`su -l`). Also, removed error message "`id: ' ': no such user`" when NOUSER was in use.
1 parent b17e69a commit af58adb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

entrypoint.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function config_user()
5454
USERNAME=$(config_user)
5555

5656
# If no user created, use the current one (root by default)
57-
id "$USERNAME" || USERNAME="$USER"
57+
id "$USERNAME" 2> /dev/null || USERNAME="$USER"
5858

5959
# Garantee the user will run on a proper place.
6060
# WORKDIR is the dir where the user will run from.
@@ -73,18 +73,20 @@ GROUPID=$(id -g $USERNAME)
7373

7474
echo ""
7575
echo "#====================================================#"
76-
echo " This container is running: '$EXECAPP',"
77-
echo " with arguments: '$DARGS',"
78-
echo " at directory: '$WORKDIR',"
76+
echo " This container is running: $EXECAPP"
77+
echo " with arguments: $DARGS"
78+
echo ""
7979
echo " by user: '${USERNAME} (uid:$USERID,gid:$GROUPID)'."
8080
echo "#====================================================#"
8181
echo ""
82+
8283
if [ "$EXECAPP" != "$_SHELL" ]; then
83-
cd $WORKDIR && su $USERNAME -c "$EXECAPP $DARGS"
84+
su -l $USERNAME -c "cd $WORKDIR && $EXECAPP $DARGS"
8485
else
8586
if [ -z "$DARGS" ]; then
86-
cd $WORKDIR && su $USERNAME
87+
#cd $WORKDIR && su $USERNAME
88+
su -l $USERNAME
8789
else
88-
cd $WORKDIR && su $USERNAME -c "$DARGS"
90+
su -l $USERNAME -c "cd $WORKDIR && $DARGS"
8991
fi
9092
fi

0 commit comments

Comments
 (0)