#!/bin/sh
set -e
# Start the Open Server up in the background.
if [ $# -eq 1 ]
then
    path=$1
else
    path=`dirname $0`
fi

if [ "$path" != "." ]
then
    cd "$path"
fi

# Check that we are in the correct location.
if [ ! -s setup/pbos.env ]
then
    echo "Could not start the PrimeBase Open Server in:"
    pwd
    echo "Environment file not found."
    echo "Please verify that it is starting in the correct location."
    exit
fi

if [ "$PRIMEBASEHOME" = "" ]
then
	PRIMEBASEHOME="/usr/local/primebase"
fi

if [ ! -d $PRIMEBASEHOME ]
then
    echo "Could not start the PrimeBase Open Server."
    echo "Please create the directory $PRIMEBASEHOME"
    echo "and give all PrimeBase users read, write, and execute privileges."
    exit
fi

if [ -x ./pbos ]
then
	./pbos -b
else
	pbos -b
fi


