#!/bin/sh

homedir=

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

cd $homedir

. ./sysconfig


###  write acis.conf

. bin/setup.acis.conf > acis.conf

###  write ardb.conf

. bin/setup.ardb.conf > ardb.conf


###  write lib/ARDB/LocalConfig.pm

. bin/setup.ardb_local_config.pm  > lib/ARDB/LocalConfig.pm


###  write RI/collections
. bin/setup.ri_collections > RI/collections

###  write RePEc-Index local setup
. bin/setup.ri_local_setup.pm  > lib/RePEc/Index/local_setup.pm

###  write Short IDs local setup

. bin/setup.sid_local.pm  > lib/RePEc/ShortIDs/Local.pm


###  write lib/ACIS/local_conf.pm (?)

###  install ACIS CGI script
###  install static web-visible directory and default stylesheet

echo writing $base_cgi_script_filename
. bin/setup.cgi_frontend > $base_cgi_script_filename
chmod +x $base_cgi_script_filename


echo installing clean-up script
. bin/setup.clean-up.pl > bin/clean-up.pl
chmod +x bin/clean-up.pl


test $log_browsing_cgi_filename && {
    echo installing log browsing script
    . bin/setup.logs-browsing > $log_browsing_cgi_filename
    chmod +x $log_browsing_cgi_filename
}

###  checking directories

test -d $homebin || mkdir $homebin
test -d $homelib || mkdir $homelib

test -d $presentation_dir || mkdir $presentation_dir 
test -d $sessions_dir     || mkdir $sessions_dir
test -d $userdata_dir     || mkdir $userdata_dir
test -d $unconfirmed_dir  || mkdir $unconfirmed_dir

### XXX deleted dir?







