#!/bin/bash

# Capture command line arguments
RSESSION_ARGS="$@"

# Location of R
export R_HOME=/usr/lib64/R

# Query R for location of doc dir
export R_DOC_DIR=`$R_HOME/bin/R --vanilla --slave -e "cat(R.home('doc'))"`

# Determine LD_LIBRARY_PATH required for R
. $R_HOME/etc/ldpaths

# Run R session (keep running if exit status is EX_CONTINUE)
while true
do
  /usr/lib/rstudio-server/bin/rsession-run --standalone=1 $RSESSION_ARGS
  if [ "$?" -ne "100" ]; then
    exit $?
  fi
done




