-
Notifications
You must be signed in to change notification settings - Fork 8
/
entrypoint.sh
executable file
·35 lines (33 loc) · 1.29 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -e
# source ROS workspace
source /opt/ros/$ROS_DISTRO/setup.bash
[[ -f $WORKSPACE/devel/setup.bash ]] && source $WORKSPACE/devel/setup.bash
[[ -f $WORKSPACE/install/setup.bash ]] && source $WORKSPACE/install/setup.bash
# exec as dockeruser with configured UID/GID
if [[ $DOCKER_UID && $DOCKER_GID ]]; then
if ! getent group $DOCKER_GID > /dev/null 2>&1; then
groupadd -g $DOCKER_GID $DOCKER_USER
fi
if ! getent passwd $DOCKER_UID > /dev/null 2>&1; then
useradd -s /bin/bash \
-u $DOCKER_UID \
-g $DOCKER_GID \
--create-home \
--home-dir /home/$DOCKER_USER \
--groups sudo,video \
--password "$(openssl passwd -1 $DOCKER_USER)" \
$DOCKER_USER && \
touch /home/$DOCKER_USER/.sudo_as_admin_successful
cp /root/.bashrc /home/$DOCKER_USER
ln -s $WORKSPACE /home/$DOCKER_USER/ws
chown -h $DOCKER_UID:$DOCKER_GID $WORKSPACE /home/$DOCKER_USER/ws /home/$DOCKER_USER/.sudo_as_admin_successful
if [[ -d $WORKSPACE/src ]]; then
chown -R $DOCKER_USER:$DOCKER_USER $WORKSPACE/src
fi
fi
[[ $(pwd) == "$WORKSPACE" ]] && cd /home/$DOCKER_USER/ws
exec gosu $DOCKER_USER "$@"
else
exec "$@"
fi