#! /bin/sh
dbname=${1}
db2 connect to ${1}
db2 update database configuration for ${1} using logsecond 100
db2 update database configuration for ${1} using locktimeout -1
db2 update database configuration for ${1} using locklist 400

echo Executing process.sql...
db2 -tf process.sql || exit
echo Executing process_params.sql...
db2 -tf process_params.sql || exit
echo Executing lfn.sql...
db2 -tf lfn.sql || exit
echo Executing gridcert.sql...
db2 -tf gridcert.sql || exit
echo Executing filter.sql...
db2 -tf filter.sql || exit
echo Executing filter_params.sql...
db2 -tf filter_params.sql || exit

echo Executing frameset_chanlist.sql...
db2 -tf frameset_chanlist.sql || exit
echo Executing frameset_writer.sql...
db2 -tf frameset_writer.sql || exit
echo Executing frameset.sql...
db2 -tf frameset.sql || exit
echo Executing frameset_loc.sql...
db2 -tf frameset_loc.sql || exit
echo Executing segment_definer.sql...
db2 -tf segment_definer.sql || exit
echo Executing segment.sql...
db2 -tf segment.sql || exit
echo Executing segment_def_map.sql...
db2 -tf segment_def_map.sql || exit
echo Executing segment_lfn_map.sql...
db2 -tf segment_lfn_map.sql || exit
echo Executing state_segment.sql || exit
db2 -td@ -f state_segment.sql || exit

echo Executing summ_value.sql...
db2 -tf summ_value.sql || exit
echo Executing summ_statistics.sql...
db2 -tf summ_statistics.sql || exit
echo Executing summ_spectrum.sql...
db2 -tf summ_spectrum.sql || exit
echo Executing summ_csd.sql...
db2 -tf summ_csd.sql || exit
echo Executing summ_comment.sql...
db2 -tf summ_comment.sql || exit
echo Executing summ_mime.sql...
db2 -tf summ_mime.sql || exit

echo Executing search_summary.sql...
db2 -tf search_summary.sql || exit
echo Executing search_summvars.sql...
db2 -tf search_summvars.sql || exit

db2 -tf grant_base.sql
db2 terminate
