#!/bin/dash

PROGRAM=canonizer-daemon

ENV_TYPE=`cat /etc/yandex/environment.type`
BIN_DIR=/usr/lib/yandex/webmaster/canonizer/daemon
LOCAL_CONFIG=$BIN_DIR/$PROGRAM.$ENV_TYPE.properties
GLOBAL_CONFIG=/etc/yandex/webmaster/configs/wmconsole.$ENV_TYPE.properties
LOG_DIR=/var/log/webmaster

LoadConfig() {
    for line in `cat $1 | awk -F'=' -v OFS='=' '{ gsub(/\./, "_", $1); print}'`; do
        eval "$line"
    done;
}

LoadConfig $GLOBAL_CONFIG

if [ ! -z $LOCAL_CONFIG ] && [ -e $LOCAL_CONFIG ]; then
    LoadConfig $LOCAL_CONFIG
fi
