-
Notifications
You must be signed in to change notification settings - Fork 68
/
docker-entrypoint
73 lines (63 loc) · 2.52 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
set -e
MYSQL_CONFIG="/opt/zbox/etc/mysql/my.cnf"
VERSION_FILE="/opt/zbox/app/zentao/VERSION"
export PATH=/opt/zbox/:$PATH
if [ "${1:0:1}" == "-" ]; then
zbox --help
elif [ "$#" == "0" ]; then
# if the container run firstly
if [ ! -d "/opt/zbox" -o ! -d "/opt/zbox/app" ]; then
echo "Installing Zentao version: ${ZENTAO_VER} ..."
tar -zxf /tmp/zbox.tar.gz -C /opt/
rm -rf /opt/zbox/app/zentao[ep]*
if [[ "${BIND_ADDRESS}" == [fF][aA][lL][sS][eE] ]] && [ -f "${MYSQL_CONFIG}" ]; then
sed -e 's/^bind-address.*$/bind-address = 0.0.0.0/' -i ${MYSQL_CONFIG}
fi
elif [ -f "${VERSION_FILE}" -a `cat ${VERSION_FILE}` != ${ZENTAO_VER} ]; then
CURRENT_VER=`cat ${VERSION_FILE}`
echo -e "The Zentao need update.\n Old version: $CURRENT_VER \n New version: $ZENTAO_VER"
# upgrade zentao version
echo "Backuping config / my.php / upload ..."
cp /opt/zbox/app/zentao/config/my.php /opt/zbox/app/
mv /opt/zbox/app/zentao/www/data/upload /opt/zbox/app/
rm -rf /opt/zbox/app/zentao
echo "Upgrading..."
tar -zxf /tmp/zbox.tar.gz -C /tmp/
mv /tmp/zbox/app/zentao /opt/zbox/app/
mv /tmp/upgrade.php /opt/zbox/app/zentao/www/
chmod 664 /opt/zbox/app/zentao/www/upgrade.php
rm -rf /opt/zbox/tmp/apache/httpd.pid /tmp/*
echo "Restoring config / my.php / upload ..."
mv /opt/zbox/app/my.php /opt/zbox/app/zentao/config/my.php
rm -rf /opt/zbox/app/zentao/www/data/upload
mv /opt/zbox/app/upload /opt/zbox/app/zentao/www/data/
touch /opt/zbox/app/zentao/www/ok.txt
echo "Upgraded Zentao version to: ${ZENTAO_VER}\nPlease visit your Zentao website to complete the upgrade task."
fi
# add apache http password for adminer
if [ -n "${ADMINER_USER}" -a -n "${ADMINER_PASSWD}" ]; then
/opt/zbox/bin/htpasswd -b /opt/zbox/auth/users ${ADMINER_USER} ${ADMINER_PASSWD}
chmod 0644 /opt/zbox/auth/users
fi
# compatible old version
if [ -n "${USER}" -a -n "${PASSWD}" ]; then
/opt/zbox/bin/htpasswd -b /opt/zbox/auth/users ${USER} ${PASSWD}
chmod 0644 /opt/zbox/auth/users
fi
# add smtp server ip to hosts
if [ -n "${SMTP_HOST}" ];then
#IS_EXIST_SMTP_HOST=`grep "${SMTP_HOST}" /etc/hosts`
#if [ -z "${IS_EXIST_SMTP_HOST}"];then
echo "${SMTP_HOST}" >> /etc/hosts
#fi
fi
# auto location / to /zentao/
echo "<meta http-equiv=\"refresh\" content=\"0; url=/zentao/\" />" > /opt/zbox/app/htdocs/index.html
# start service and health check
cat /opt/zbox/README
zbox start
tail -f /dev/null
else
exec "$@"
fi