#!/bin/sh

#drop template_gis
#it may be used to drop any postgresql template, by supplying argument

source /postgis_env.sh

for ARGVN in $1 $2 $3 $4 ; do
    if [ `expr substr $ARGVN 1 11` = "--template=" ]; then
	 	TDB=`echo $ARGVN | sed -e s/^--template=//`
	elif [ `expr substr $ARGVN 1 6` = "--dba=" ]; then
		DBAUSER=`echo $ARGVN | sed -e s/^--dba=//`
    elif [ -n $ARGVN ]; then
        echo "Usage of `basename $0`"
        echo "Supply arguments as follows"
        echo "--template=templatename of the template to remove"
		echo "--dba=dbaname of the dba to run administrational programs as"
		echo "You must usually be either root, or a postgresql dba in order"
		echo "to use `basename $0`"
        exit 1
    fi
done

source /postgres_lib.sh

sudo_dba $DBAUSER

export DBAUSER TDB
$SUDO -c "/rmtemplate_gis.sh"
