set -e

# First use download_databases to download the databases, then use this
# script to build the G:C:F database in the directory $OPENADDR_HOME

export OPENADDR_HOME="${OPENADDR_HOME:-~/etc/openaddr}"

cd ~/src/njh/Geo-Coder-Free
git pull
if [[ -f $OPENADDR_HOME/openaddresses.sql ]]; then
	mv $OPENADDR_HOME/openaddresses.sql $OPENADDR_HOME/openaddresses.sql.keep
	chmod 444 $OPENADDR_HOME/openaddresses.sql.keep
fi
REDIS_SERVER= make 2>&1 | tee /tmp/create_db.out.$$
