RStudio server source bash script with environment variables prior to startup



How can I get RStudio server to source a bash script prior to starting a R session?

I have read and tried to source a bash script in the Renviron shell script, but no success.

Background: I compiled R from source with intel MKL available as a shared library. The R binary will fail to start with the following message:

/opt/R/3.4.3/lib64/R/bin/exec/R: error while loading shared libraries: cannot open shared object file: No such file or directory

echo 'source /opt/intel/mkl/bin/ intel64'>>/etc/profile.d/
is set, i.e. some environment variables are sourced prior to starting R from bash.

see also the discussion, but I believe as this is a question regarding RStudio (server) in particular it is more suited here.