diff options
Diffstat (limited to 'docker/monasca/monasca-api/extend_start.sh')
-rw-r--r-- | docker/monasca/monasca-api/extend_start.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/docker/monasca/monasca-api/extend_start.sh b/docker/monasca/monasca-api/extend_start.sh new file mode 100644 index 0000000..6152e41 --- /dev/null +++ b/docker/monasca/monasca-api/extend_start.sh | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | SERVICE="monasca-api" | ||
4 | |||
5 | # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases | ||
6 | # of the KOLLA_BOOTSTRAP variable being set, including empty. | ||
7 | if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then | ||
8 | # Set the database name in the monasca database schema | ||
9 | sed "s/USE \`mon\`;/USE \`${MONASCA_DATABASE_NAME}\`;/g" \ | ||
10 | /monasca-api/devstack/files/schema/mon_mysql.sql > /tmp/mon_mysql.sql | ||
11 | # Load the schema | ||
12 | mysql --host=${MONASCA_DATABASE_ADDRESS} \ | ||
13 | --port=${MONASCA_DATABASE_PORT} \ | ||
14 | --user=${MONASCA_DATABASE_USER} \ | ||
15 | --password=${MONASCA_DATABASE_PASSWORD} \ | ||
16 | < /tmp/mon_mysql.sql | ||
17 | exit 0 | ||
18 | fi | ||
19 | |||
20 | # NOTE(pbourke): httpd will not clean up after itself in some cases which | ||
21 | # results in the container not being able to restart. (bug #1489676, 1557036) | ||
22 | if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then | ||
23 | # Loading Apache2 ENV variables | ||
24 | . /etc/apache2/envvars | ||
25 | rm -rf /var/run/apache2/* | ||
26 | else | ||
27 | rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd* | ||
28 | fi | ||
29 | |||
30 | # When Apache first starts it writes out the custom log files with root | ||
31 | # ownership. This later prevents the Monasca API (which runs under the | ||
32 | # 'monasca' user) from updating them. To avoid this we create the log | ||
33 | # files with the required permissions here, before Apache does. | ||
34 | MONASCA_API_LOG_DIR="/var/log/kolla/monasca" | ||
35 | for LOG_TYPE in error access; do | ||
36 | if [ ! -f "${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log" ]; then | ||
37 | touch ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log | ||
38 | fi | ||
39 | if [[ $(stat -c %U:%G ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log) != "monasca:kolla" ]]; then | ||
40 | chown monasca:kolla ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log | ||
41 | fi | ||
42 | done | ||