#!/bin/sh if [ -z "$GISBASE" ] ; then echo "You must be in GRASS GIS to run this program." >&2 exit 1 fi ### setup enviro vars ### eval `g.gisenv` : ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?} source ${GISBASE}/etc/r.rast4d/globals/defines.sh if [ "$GRAST4D_DBM" = "sqlite3" ] ; then if [ ! -f $GRAST4D_DATABASE ] ; then if [ ! -d ./db/ ]; then mkdir ./db/ ; fi echo "Initializing SQLite db..." ${GISBASE}/etc/r.rast4d/bin/init_db.sh else echo "$GRAST4D_DATABASE already exists. Doing nothing. Remove that DB file to start over" fi else psql -l | grep $PGDB > /dev/null if [ $? -ne 0 ] ; then # TODO: implement psql magic to call 'createdb' echo "ERROR: PostgreSQL database <$PGDB> does not exist. Run 'createdb $PGDB' as appropriate." exit 1 else echo "Initializing PostgreSQL database..." ${GISBASE}/etc/r.rast4d/bin/init_db.sh fi fi echo "Done. Now you can use the tg.* commands." exit 0