#!/bin/bash

# Create Matlab Runtime and install directories, change directory to install
mkdir -p /sharedStorage/software/MATLAB/MatlabRuntime
mkdir /sharedStorage/matlab_install
cd /sharedStorage/matlab_install

# Install Matlab Runtime, link for v 910
wget https://ssd.mathworks.com/supportfiles/downloads/R2021a/Release/8/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2021a_Update_8_glnxa64.zip
unzip MATLAB_Runtime_R2021a_Update_8_glnxa64.zip
./install -mode silent -agreeToLicense yes -outputFile ~/myapp_log.txt -destinationFolder /sharedStorage/software/MATLAB/MatlabRuntime
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sharedStorage/software/MATLAB/MatlabRuntime/v910/runtime/glnxa64:/sharedStorage/software/MATLAB/MatlabRuntime/v910/bin/glnxa64:/sharedStorage/software/MATLAB/MatlabRuntime/v910/sys/os/glnxa64:/sharedStorage/software/MATLAB/MatlabRuntime/v910/extern/bin/glnxa64

# remove Matlab install directory
cd /sharedStorage
rm -rf matlab_install

# Create binaries directory, change directory to it
mkdir -p /sharedStorage/software/k-Wave
cd /sharedStorage/software/k-Wave

# Download binaries, unpack, remove download file, set correct permissions
wget https://www.fit.vutbr.cz/~jarosjir/download/kupco.tgz
tar   -xf kupco.tgz
rm kupco.tgz
chmod 755 -R *
