-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathinit.sh
executable file
·51 lines (44 loc) · 1.93 KB
/
init.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
#!/bin//bash
#
# Copyright 2020 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -ex
# Secrets are obtained from ENV variables.
export PASSWORD=${AdminPassword:?"Please specify a AdminPassword variable."}
export DBHOST=${DatabaseHost:?"Please specify a DatabaseHost variable."}
export DBUSER=${DatabaseUser:?"Please specify a DatabaseUser variable."}
export DBPASSWORD=${DatabasePassword:?"Please specify a DatabasePassword variable."}
export DB=${DatabaseName:-"keystone"}
SVC_CFG=/etc/keystone/keystone.conf
SVC_CFG_MERGED=/var/lib/config-data/merged/keystone.conf
# expect that the common.sh is in the same dir as the calling script
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
. ${SCRIPTPATH}/common.sh --source-only
# Copy default service config from container image as base
cp -a ${SVC_CFG} ${SVC_CFG_MERGED}
# Merge all templates from config CM
for dir in /var/lib/config-data/default;do
merge_config_dir ${dir}
done
# set secrets
crudini --set ${SVC_CFG_MERGED} database connection mysql+pymysql://${DBUSER}:${DBPASSWORD}@${DBHOST}/${DB}?read_default_file='/etc/my.cnf'
# custom CA certificates
if [ -d /var/lib/config-data/ca-certificates ]; then
for i in `find /var/lib/config-data/ca-certificates -type f -name 'ca*.crt'`; do
out=$(mktemp /etc/pki/ca-trust/source/anchors/ca_XXXXXX.crt)
cp -vf $i $out
done
update-ca-trust
cp /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /var/lib/config-data/merged
fi