Skip to content

Commit e4a4f55

Browse files
committed
Decided to keep (so far) only one file fot docker init.
1 parent f82e852 commit e4a4f55

2 files changed

Lines changed: 37 additions & 31 deletions

File tree

config_user.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

entrypoint.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,42 @@ DARGS="$*"
1313
# Save the current path
1414
CWD="$PWD"
1515

16+
function config_user()
17+
{
18+
#================================================#
19+
# Config a User #
20+
# ------------- #
21+
# It is meant to run during container's init #
22+
# process. Such process is necessary to better #
23+
# exchange files/bus between host/container. #
24+
# Variables DUSER, DUID, DGID are read from the #
25+
# environment; if NOUSER is set, do nothing. #
26+
#================================================#
27+
28+
DEFAULT_USER="user"
29+
DEFAULT_UID="1000"
30+
DEFAULT_GID="100"
31+
32+
[[ ! -z "$NOUSER" ]] && \
33+
# nothing to be done here
34+
return 0
35+
36+
DUSER="${DUSER-$DEFAULT_USER}"
37+
DUID="${DUID-$DEFAULT_UID}"
38+
DGID="${DGID-$DEFAULT_GID}"
39+
40+
useradd -u "$DUID" \
41+
-g "$DGID" \
42+
-d "/home/$DUSER" -m \
43+
-s /bin/bash \
44+
"$DUSER"
45+
46+
echo $DUSER
47+
}
48+
49+
1650
# Add a user here
17-
USERNAME=$(${CWD}/config_user.sh)
51+
USERNAME=$(config_user)
1852

1953
# If no user created, define the current one (root)
2054
[[ `id $USERNAME` ]] || USERNAME="$USER"
@@ -39,3 +73,5 @@ fi
3973

4074
su -l $USERNAME -c "cd $WORKDIR && $INTERP $DARGS"
4175

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

0 commit comments

Comments
 (0)