#!/bin/bash

homedir=

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

cd $homedir

. ./sysconfig


# start RePEc-Index Control Daemon

echo "going to start RI daemon ($ri_daemon)"

### XXX  we need RePEc-Index database check here (BDB) db_verify

if test -f $ri_pid_file 
then 
    echo pid file $ri_pid_file is present
    echo aborting
    exit
fi

$perlbin -I$homelib $ri_daemon -f $ri_socket_file -p $ri_pid_file -H $ri_home >>$ri_log 2>&1 &


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


