Skip to content

Commit b82d8e6

Browse files
committed
Fixed user config function return value
1 parent e4a4f55 commit b82d8e6

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

entrypoint.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Script to support the initialization process #
44
# in a docker container. #
55
#==============================================#
6+
set -xv
67

78
# Executable to which cl arguments should fit
89
INTERP="${ENTRYPOINT-'echo'}"
@@ -41,37 +42,30 @@ function config_user()
4142
-g "$DGID" \
4243
-d "/home/$DUSER" -m \
4344
-s /bin/bash \
44-
"$DUSER"
45+
"$DUSER" || return 1
4546

4647
echo $DUSER
48+
return 0
4749
}
4850

4951

5052
# Add a user here
5153
USERNAME=$(config_user)
52-
5354
# If no user created, define the current one (root)
54-
[[ `id $USERNAME` ]] || USERNAME="$USER"
55+
USERNAME=${USERNAME:-$USER}
5556

5657
# Garantee the user will run on a proper place.
5758
# WORKDIR is the dir where the user will run from.
5859
if [ ! -z "$WORKDIR" ]; then
5960
# If WORKDIR is defined, verify the permissions
60-
if [ -d "$WORKDIR" ]; then
61-
if [ ! -w "$WORKDIR" ]; then
62-
chown -R ${USERNAME}: $WORKDIR
63-
chmod 755 $WORKDIR
64-
fi
65-
else
61+
if [ ! -d "$WORKDIR" ]; then
6662
mkdir -p $WORKDIR
67-
chown ${USERNAME}: $WORKDIR
6863
fi
64+
chown -R ${USERNAME}: $WORKDIR
6965
else
7066
# If WORKDIR is not defined, use its HOME
7167
WORKDIR=$(getent passwd $USERNAME | awk -F: '{print $(NF-1)}')
7268
fi
7369

7470
su -l $USERNAME -c "cd $WORKDIR && $INTERP $DARGS"
7571

76-
#!/bin/bash -e
77-

0 commit comments

Comments
 (0)