#! /bin/bash

# file: setup.sh

# This bash script performs any setup necessary in order to test your entry.
# It is run only once, before running any other code belonging to your entry.

# Install the WFDB Toolbox for MATLAB and Octave
unzip -q sources/wfdb-app-toolbox-*.zip
#tar -xzfv  sources/signal-*.tar.gz

# Configure the toolbox to use the custom native library built on Debian Wheezy
sed -i 's/WFDB_CUSTOMLIB=0;/WFDB_CUSTOMLIB=1;/' ./mcode/wfdbloadlib.m

OCTAVE='octave --quiet --no-window-system --eval '
STR="${OCTAVE} \"cd('mcode');addpath(pwd);savepath;quit;\""
echo "$STR"
eval ${STR}

mkdir -p $(pwd)/forge_files

#STR="${OCTAVE} \"pkg prefix $(pwd)/forge_files/ $(pwd)/forge_files/;pkg local_list ~/.octave_packages;pkg install sources/general.tar.gz; pkg install sources/specfun.tar.gz;pkg install sources/control.tar.gz; pkg install -auto sources/signal.tar.gz;quit;\""
echo "$STR"
eval ${STR}


stty sane

