#!/bin/sh
# run_sql [sql source file]
#		Will either source a SQL file, or drop you in interactive mode
# Max Baker
# $Id: pg_run,v 1.5 2004/11/17 17:06:42 maxbaker Exp $


DB=netdisco

if [ -r "$1" ]
then
    UPGRADE=`echo $1 | grep ^upgrade`
    if [ "$UPGRADE" = "" ]; then
        echo -n "This will nuke all the data in the table.  You Sure (y/n)?"
        read REPLY
        if [ "$REPLY" = "y" ]; then
            echo "Enter database user password:"
            psql -e -f $1 -U $DB $DB
        else
            echo "Never Mind"
        fi
    else 
        echo "Running Upgrade Script : $1"
        echo "Enter database user password:"
        psql -e -f $1 -U $DB $DB
    fi
else 
	psql -U $DB $DB
fi
