RStudio server source bash script with environment variables prior to startup

rstudio
rstudioserver

#1

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

I have read https://rviews.rstudio.com/2017/04/19/r-for-enterprise-understanding-r-s-startup/ 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: libmkl_gf_lp64.so: cannot open shared object file: No such file or directory
unless

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

see also the discussion https://stackoverflow.com/questions/48639450/rstudio-server-source-bash-script-with-environment-variables-prior-to-startup?noredirect=1#comment84280466_48639450, but I believe as this is a question regarding RStudio (server) in particular it is more suited here.