Shell script to build database