diff options
author | Rafael Römhild <r.roemhild@s-v.de> | 2016-11-11 00:12:54 +0100 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2016-11-16 11:48:50 +0100 |
commit | 5a01b5f1fc991044920a84bf97959c2e4c21b7d2 (patch) | |
tree | 696255307a36e0b0708c30ca82d42834bcfc6940 /docker/start.sh | |
parent | Minor cosmetic changes on pubsub code (diff) |
add docker support
Diffstat (limited to 'docker/start.sh')
-rwxr-xr-x | docker/start.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 000000000..64a971f66 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -e + +# Environment +export EJABBERD_HTTPS=${EJABBERD_HTTPS:-'true'} +export EJABBERD_STARTTLS=${EJABBERD_STARTTLS:-'true'} +export EJABBERD_S2S_SSL=${EJABBERD_S2S_SSL:-'true'} + +source "${EJABBERD_HOME}/docker/lib/base_config.sh" +source "${EJABBERD_HOME}/docker/lib/config.sh" +source "${EJABBERD_HOME}/docker/lib/base_functions.sh" +source "${EJABBERD_HOME}/docker/lib/functions.sh" + + +# discover hostname +readonly nodename=$(get_nodename) + +# set erlang node to node name from get_nodename +if [[ "$ERLANG_NODE" == "nodename" ]]; then + export ERLANG_NODE="ejabberd@${nodename}" +fi + + +run_scripts() { + local run_script=$1 + local run_script_dir="${EJABBERD_HOME}/docker/${run_script}" + + log "Run ${run_script} scripts..." + for script in ${run_script_dir}/*.sh ; do + if [ -f ${script} -a -x ${script} ] ; then + ${script} + fi + done +} + + +_trap() { + run_scripts "stop" + log "Stopping ejabberd..." + $EJABBERDCTL stop + $EJABBERDCTL stopped + exit 0 +} + + +# Catch signals and shutdown ejabberd +trap _trap SIGTERM SIGINT + +# print logfiles to stdout +tail -F ${LOGDIR}/crash.log \ + ${LOGDIR}/error.log \ + ${LOGDIR}/erlang.log \ + ${LOGDIR}/ejabberd.log & + +# start ejabberd +run_scripts "pre" +log "Starting ejabberd..." +$EJABBERDCTL start +$EJABBERDCTL started +log "Ejabberd started." +run_scripts "post" + +# run forever +while true; do sleep 1; done + +log "Ejabberd stopped." + + +exit 0 |