#!/bin/sh

#
# PGBrowse startup script - sets defaults and determines
# architecture before exec'ing wishpqx on the startup
# Tcl script
#
# $Id: pgbrowse,v 1.1 1993/12/06 18:15:44 jimbo Exp jimbo $
#


PGBROWSE=${PGBROWSE-/usr/local/postgres/pgbrowse-v3.1b}
PGHOST=${PGHOST-localhost}
PGPORT=${PGPORT-4321}
PGSTARTUP=$PGBROWSE/lib/init.tcl

[ -f $PGSTARTUP ] || {
    echo "Error:  $PGBROWSE is not the PGBROWSE directory."
    exit 1
}

ARCH=`$PGBROWSE/bin/arch` || {
    echo "Error:  Can't determine your machine type."
    exit 1
}

[ -d $PGBROWSE/bin/$ARCH ] || {
    echo "Error:  Unknown machine type:  $ARCH"
    exit 1
}

WISH=$PGBROWSE/bin/$ARCH/wishpqx
[ -f $WISH ] || {
    echo "Error:  Can't find wishpqx:  $WISH"
    exit 1
}

% TK_LIBRARY=$PGBROWSE/lib/tclx
% TCL_LIBRARY=$PGBROWSE/lib/tclx

export PGBROWSE PGHOST PGPORT WISH TK_LIBRARY TCL_LIBRARY ARCH

exec $WISH -name pgbrowse -f $PGSTARTUP $*
