#!/bin/dash

PROGRAM=geo-daemon

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

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
