-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint
42 lines (39 loc) · 1.06 KB
/
docker-entrypoint
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
#!/bin/bash
set -e
MYSQL_CONFIG="/opt/zbox/etc/mysql/my.cnf"
APACHE_CONFIG="/opt/zbox/etc/apache/httpd.conf"
if [ "${1:0:1}" == "-" ]; then
zbox --help
elif [ "$#" == "0" ]; then
if [ ! -d "/opt/zbox" ]; then
tar -zxf /tmp/zbox.tar.gz -C /opt/
if [[ "${BIND_ADDRESS}" == [fF][aA][lL][sS][eE] ]] && [ -f "${MYSQL_CONFIG}" ]; then
sed -Ei 's/^bind-address/#&/' ${MYSQL_CONFIG}
fi
else
WORK_DIR=`ls /opt/zbox`
if [ -z "${WORK_DIR}" ];then
tar -zxf /tmp/zbox.tar.gz -C /opt/
if [[ "${BIND_ADDRESS}" == [fF][aA][lL][sS][eE] ]] && [ -f "${MYSQL_CONFIG}" ]; then
sed -Ei 's/^bind-address/#&/' ${MYSQL_CONFIG}
fi
fi
fi
export PATH=/opt/zbox/:$PATH
cat /opt/zbox/README && zbox start
if [ -n "${USER}" -a -n "${PASSWD}" ]; then
/opt/zbox/bin/htpasswd -b /opt/zbox/auth/users ${USER} ${PASSWD}
fi
if [ -n "${SMTP_HOST}" ];then
echo "${SMTP_HOST}" >> /etc/hosts
fi
sleep 120
loop=1
while [ ${loop} -eq 1 ]
do
wget http://localhost/ -O /dev/null || exit 1
sleep 30
done
else
exec "$@"
fi