Skip to content

Commit 01f7a9c

Browse files
committed
Modified the definition of WORKDIR
1 parent 5c665e8 commit 01f7a9c

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

entrypoint.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@ USERNAME=$(config_user)
5757

5858
# Garantee the user will run on a proper place.
5959
# WORKDIR is the dir where the user will run from.
60-
if [ ! -z "$WORKDIR" ]; then
61-
# If WORKDIR is defined, verify the permissions
62-
if [ ! -d "$WORKDIR" ]; then
63-
mkdir -p $WORKDIR
64-
fi
65-
chown -R ${USERNAME}: $WORKDIR
66-
else
67-
# If WORKDIR is not defined, use its HOME
68-
WORKDIR=$(getent passwd $USERNAME | awk -F: '{print $(NF-1)}')
69-
fi
60+
[[ -z "$WORKDIR" ]] && export WORKDIR='/work'
7061

71-
su -l $USERNAME -c "cd $WORKDIR && $EXECAPP $DARGS"
62+
# Verify WORKDIR existence
63+
[[ ! -d "$WORKDIR" ]] && mkdir -p $WORKDIR
64+
65+
# And grant permissions
66+
# To simplify the permissions now, I'll give ownership.
67+
#TODO: give 'w/r/x' permissions instead of changing ownership;
68+
# this is important 'cause WORKDIR could already exist.
69+
chown ${USERNAME}: $WORKDIR && chmod u+w $WORKDIR
7270

71+
echo ""
72+
echo "#==========================================#"
73+
echo " This container is running: \'$EXECAPP\',"
74+
echo " with arguments: \'$DARGS\',"
75+
echo " at directory: \'$WORKDIR\',"
76+
echo " by user: \'$USERNAME\'."
77+
echo "#==========================================#"
78+
echo ""
79+
su -l $USERNAME -c "cd $WORKDIR && $EXECAPP $DARGS"

0 commit comments

Comments
 (0)