2016-11-11 00:12:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2017-03-21 18:59:12 +01:00
|
|
|
source "${EJABBERD_HOME}/scripts/lib/base_config.sh"
|
|
|
|
source "${EJABBERD_HOME}/scripts/lib/config.sh"
|
|
|
|
source "${EJABBERD_HOME}/scripts/lib/base_functions.sh"
|
|
|
|
source "${EJABBERD_HOME}/scripts/lib/functions.sh"
|
2016-11-11 00:12:54 +01:00
|
|
|
|
|
|
|
# Instead of having to mount a direction, specify the ssl certs
|
|
|
|
# via environment variables:
|
|
|
|
# `EJABBERD_SSLCERT_HOST` and `EJABBERD_SSLCERT_{domain_name}`.
|
|
|
|
# For example: `EJABBERD_SSLCERT_EXAMPLE_COM`.
|
|
|
|
|
|
|
|
write_file_from_env() {
|
2017-03-21 18:59:12 +01:00
|
|
|
echo "Writing $1 to $2"
|
2016-11-11 00:12:54 +01:00
|
|
|
mkdir -p "$(dirname $2)"
|
2017-03-21 18:59:12 +01:00
|
|
|
echo "${!1}" > $2
|
2016-11-11 00:12:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Write the host certificate
|
|
|
|
is_set ${EJABBERD_SSLCERT_HOST} \
|
|
|
|
&& write_file_from_env "EJABBERD_SSLCERT_HOST" ${SSLCERTHOST}
|
|
|
|
|
|
|
|
# Write the domain certificates for each XMPP_DOMAIN
|
|
|
|
for xmpp_domain in ${XMPP_DOMAIN} ; do
|
|
|
|
var="EJABBERD_SSLCERT_$(echo $xmpp_domain | awk '{print toupper($0)}' | sed 's/\./_/g;s/-/_/g')"
|
|
|
|
if is_set ${!var} ; then
|
|
|
|
file_exist "${SSLCERTDIR}/${xmpp_domain}.pem" \
|
|
|
|
|| write_file_from_env "$var" "${SSLCERTDIR}/${xmpp_domain}.pem"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|