-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
63 lines (53 loc) · 1.45 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
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# set -e
hex()
{
openssl rand -hex 8
}
echo "Preparing container .."
COMMAND="/usr/bin/shellinaboxd --debug --no-beep -u shellinabox -g shellinabox -c /var/lib/shellinabox -p ${SIAB_PORT} --user-css ${SIAB_USERCSS}"
if [ "$SIAB_PKGS" != "none" ]; then
set +e
/usr/bin/apt-get update
/usr/bin/apt-get install -y $SIAB_PKGS
/usr/bin/apt-get clean
/bin/rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
set -e
fi
if [ "$SIAB_SSL" != "true" ]; then
COMMAND+=" -t"
fi
if [ "${SIAB_ADDUSER}" == "true" ]; then
sudo=""
if [ "${SIAB_SUDO}" == "true" ]; then
sudo="-G sudo"
fi
/usr/sbin/groupadd -g ${SIAB_GROUPID} ${SIAB_GROUP}
/usr/sbin/useradd -u ${SIAB_USERID} -g ${SIAB_GROUPID} -s ${SIAB_SHELL} -d ${SIAB_HOME} -m ${sudo} ${SIAB_USER}
if [ "${SIAB_PASSWORD}" == "putsafepasswordhere" ]; then
SIAB_PASSWORD=$(hex)
echo "Autogenerated password for user ${SIAB_USER}: ${SIAB_PASSWORD}"
fi
echo "${SIAB_USER}:${SIAB_PASSWORD}" | /usr/sbin/chpasswd
unset SIAB_PASSWORD
fi
for service in ${SIAB_SERVICE}; do
COMMAND+=" -s ${service}"
done
if [ "$SIAB_SCRIPT" != "none" ]; then
set +e
/usr/bin/curl -s -k ${SIAB_SCRIPT} > /prep.sh
chmod +x /prep.sh
echo "Running ${SIAB_SCRIPT} .."
/prep.sh
set -e
fi
echo "Starting container .."
if [ "$@" = "shellinabox" ]; then
echo "Executing: ${COMMAND}"
exec ${COMMAND}
else
echo "Not executing: ${COMMAND}"
echo "Executing: ${@}"
exec $@
fi