Skip to content

Commit 8c7db8b

Browse files
committed
Init
0 parents  commit 8c7db8b

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

config_user.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+

entrypoint.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+

0 commit comments

Comments
 (0)