#!/bin/sh
#
# Author: Michael Conrad <do5mc at aprs4r.org>
#

# set etc path
[ -z "$APRS4R_ETC" ] && APRS4R_ETC=/etc/aprs4r

# set log path 
[ -z "$APRS4R_LOG" ] && APRS4R_LOG=/var/log/aprs4r

# set lib dir
if [ -z "$APRS4R_LIB" ]; then
  APRS4R_LIB=/usr/lib/ruby/site_ruby/1.9
fi


LOG_FILE=$APRS4R_LOG/aprs4r-config.log


write_log() 
{ 
    timestamp=`date +'%Y-%m-%d %H:%M:%S'`

    echo "[$1] $timestamp: $2" >> $LOG_FILE 
}


for file in `ls -1 $APRS4R_ETC/*.yaml`; do 
    echo "checking configuration file $file" 
    write_log "LOG", "configuration update for file $file"

    /usr/bin/ruby $APRS4R_LIB/aprs4r_config.rb $file >> $LOG_FILE
done

