File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
89INTERP=" ${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
5153USERNAME=$( 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.
5859if [ ! -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
6965else
7066 # If WORKDIR is not defined, use its HOME
7167 WORKDIR=$( getent passwd $USERNAME | awk -F: ' {print $(NF-1)}' )
7268fi
7369
7470su -l $USERNAME -c " cd $WORKDIR && $INTERP $DARGS "
7571
76- #! /bin/bash -e
77-
You can’t perform that action at this time.
0 commit comments