File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash -e
2+ # ================================================#
3+ # Script to config a User for docker container. #
4+ # It is meant to run during container's init #
5+ # process. Such process is necessary to better #
6+ # exchange files/bus between host/container. #
7+ # Variables DUSER, DUID, DGID are read from the #
8+ # environment; if NOUSER is set, do nothing. #
9+ # ================================================#
10+
11+ DEFAULT_USER=" user"
12+ DEFAULT_UID=" 1000"
13+ DEFAULT_GID=" 100"
14+
15+ [[ ! -z " $NOUSER " ]] && \
16+ # nothing to be done here
17+ exit 0
18+
19+ DUSER=" ${DUSER-$DEFAULT_USER } "
20+ DUID=" ${DUID-$DEFAULT_UID } "
21+ DGID=" ${DGID-$DEFAULT_GID } "
22+
23+ useradd -u " $DUID " \
24+ -g " $DGID " \
25+ -d " /home/$DUSER " -m \
26+ -s /bin/bash \
27+ " $DUSER "
28+
29+ echo $DUSER
30+
Original file line number Diff line number Diff line change 1+ #! /bin/bash -e
2+ # ==============================================#
3+ # Script to support the initialization process #
4+ # in a docker container. #
5+ # ==============================================#
6+
7+ # Executable to which cl arguments should fit
8+ INTERP=" ${ENTRYPOINT-' echo' } "
9+
10+ # Save the input cl arguments
11+ DARGS=" $* "
12+
13+ # Save the current path
14+ CWD=" $PWD "
15+
16+ # Add a user here
17+ USERNAME=$( ${CWD} /config_user.sh)
18+
19+ [[ " $USERNAME " = " 0" ]] && USERNAME=" $USER "
20+
21+ su -l $USERNAME -c " $INTERP $DARGS "
22+
You can’t perform that action at this time.
0 commit comments