#!/bin/bash


homedir=

if test -z $homedir; then
  echo "This script must be installed before usage"
  exit 1
fi

cd $homedir

. ./sysconfig




# start Short-ID database Daemon (berkeley_db_svc)

echo "going to start SID daemon ($berkeley_db_svc)"

pid_file=$sid_pid_file

if test -f $pid_file 
then 
    pid=`cat $pid_file`
    echo pid file $pid_file is present, check process $pid
    echo aborting
    exit
fi


$berkeley_db_svc -v -h $sid_home -L $pid_file.verbose >>$sid_log 2>&1 &

pid=`cat $pid_file.verbose | perl -ne 'print m/(\d+)/;'`
echo SID daemon pid is $pid
echo $pid > $pid_file


sleep 2
if test -f $pid_file
then 
    echo ' done'
else 
    echo " failed"
    echo " here is the log's tail:"
    tail $sid_log
    rm $pid_file
fi


