#!/bin/bash
#$Id: create_all_data.bash,v 1.3 2023/12/13 07:10:39 sqko Exp $
rig=$1;
test=$2;
if [ "$#" -lt 1 ]; then
    exit;
fi;
if [ "$#" -lt 2 ]; then
    test=`perl -e 'use RFC::Rig; $r=RFC::Rig->new(1);print $r->session()'`;
fi;
file="/home/http/html/rig${rig}/${rig}test${test}/${rig}test${test}*.tex";
if ls $file 1> /dev/null 2>&1; then
    echo "Report exists, skipping data processing";
else
    echo "Generating data..";
    /usr/local/bin/celltest/jdata.pl $rig $test;
    /usr/local/bin/get_all_impedance $rig $test;
    /usr/local/bin/make_iv_curves.pl $rig $test;
    /usr/local/bin/plot_leak.pl $rig $test;
fi;
/usr/local/bin/celltest/create_data_export.pl $rig $test;
if [ "$#" -lt 3 ]; then
    exit;
fi;
email=$3;
/usr/bin/perl -e "use RFC::Main; RFC::Main::mail('$email','Data archive for rig $rig test $test finished','Zip-file ready for download')"
