#%Module####################################################################
module-whatis  matlab_2022a_20231207.simg
prepend-path PATH /cvmfs/neurodesk.ardc.edu.au/containers/matlab_2022a_20231207


# Append custom license paths so that a license can be stored outside the container
if { [info exists env(HOME)] } {
    set additional_bind_paths "$env(HOME):/home/matlab/.matlab/R2022a_licenses,$env(HOME):/opt/matlab/R2022a/licenses"
}

if { ![info exists env(HOME)] } {
    set additional_bind_paths "/tmp:/home/matlab/.matlab/R2022a_licenses,/tmp:/opt/matlab/R2022a/licenses"
}

if { [info exists env(SINGULARITY_BINDPATH)] } {
    append-path -delim "," SINGULARITY_BINDPATH $additional_bind_paths
}

if { [info exists env(APPTAINER_BINDPATH)] } {
    append-path -delim "," APPTAINER_BINDPATH $additional_bind_paths
}

if { ![info exists env(SINGULARITY_BINDPATH)] && ![info exists env(APPTAINER_BINDPATH)] } {
    # Neither variable is set, so set SINGULARITY_BINDPATH, because it's backwards compatible with APPTAINER
    setenv SINGULARITY_BINDPATH $additional_bind_paths
}