#!/usr/bin/with-contenv bash

if [[ -z $JICOFO_COMPONENT_SECRET || -z $JICOFO_AUTH_PASSWORD ]]; then
    echo 'FATAL ERROR: Jicofo component secret and auth password must be set'
    exit 1
fi

if [[ ! -f /config/sip-communicator.properties ]]; then
    tpl /defaults/sip-communicator.properties > /config/sip-communicator.properties
fi

if [[ ! -f /config/logging.properties ]]; then
    cp /defaults/logging.properties /config
fi

chown -R jicofo:jitsi /config