-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
34 lines (24 loc) · 1.11 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
#!/usr/bin/env bash
set -e
runuser="0"
if [[ "${CUR_UID:-"0"}" != '0' ]]; then
addgroup --gid ${CUR_GID} dockeruser > /dev/null || groupmod -n dockeruser $(getent group ${CUR_GID} | cut -d: -f1)
useradd -g dockeruser --uid ${CUR_UID} dockeruser > /dev/null
addgroup dockeruser dockeruser > /dev/null
addgroup dockeruser sudo > /dev/null
#addgroup dockeruser docker > /dev/null
remote_docker_group_id="$(stat -c '%g' /var/run/docker.sock)"
remote_docker_group_name="$(getent group $remote_docker_group_id | cut -d: -f1)"
if test -z "$remote_docker_group_name"; then
remote_docker_group_name="rdocker"
groupadd --gid "$remote_docker_group_id" "$remote_docker_group_name"
fi
addgroup dockeruser "$remote_docker_group_name" > /dev/null
echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
export HOME=/home/dockeruser
echo "source \$WDC_DO_COMMANDS_DIR/bin/do_bash_customization" > /home/dockeruser/.bashrc
echo "export PATH=\"\$PATH:/home/dockeruser/mbin\"" >> /home/dockeruser/.bashrc
chown -R dockeruser:dockeruser /home/dockeruser/
runuser="dockeruser"
fi
exec gosu "$runuser" "$@"