-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
50 lines (39 loc) · 1.17 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
PASS=${PASSWORD:-password}
ENCRYPTED_PASSWORD=`openssl passwd -6 -salt jardajagr ${PASS}`
USER=${USERNAME:-student}
DEFAULT_SHELL=${SHELL:-/bin/bash}
ENTRYPOINT_REMOVE=${ENTRYPOINT_REMOVE:-true}
ENTRYPOINT_DEBUG=${ENTRYPOINT_DEBUG:-true}
ENTRYPOINT_SCENARIO_IS_READY=${ENTRYPOINT_SCENARIO_IS_READY:-true}
ENTRYPOINT_PATH=${ENTRYPOINT_PATH:-/tmp/entrypoint.sh}
if [ "${ENTRYPOINT_DEBUG}" == "true" ]; then
set -x
fi
grep -q $USER /etc/passwd || useradd \
--badnames\
--create-home\
--shell $DEFAULT_SHELL\
--password $ENCRYPTED_PASSWORD\
$USER
echo 'PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /home/$USER/.bashrc
if [ "${SUDO}" == "true" ]; then
usermod -aG sudo $USER
fi
if [ "${ENABLE_SSH}" == "true" ]; then
service ssh start
fi
[ -f $ENTRYPOINT_PATH ] && chmod +x $ENTRYPOINT_PATH && $ENTRYPOINT_PATH
if [ "${ENTRYPOINT_REMOVE}" == "true" ]; then
rm $ENTRYPOINT_PATH
fi
if [ "${ENTRYPOINT_SCENARIO_IS_READY}" == "true" ]; then
echo SCENARIO_IS_READY
fi
if [ "$WEB_SHELL" == "true" ]; then
while true; do
/usr/bin/ttyd -W -p ${WEB_SHELL_PORT:-80} /usr/sbin/lemurs
done
fi
bash
sleep infinity