#!/bin/sh

RSLIB=/usr/local/R-Linux/lib
RSBIN=/usr/local/R-Linux/bin/R-Linux
RSSTARTUP=/usr/local/R-Linux/bin/rlinux
DESKFILE=/usr/local/R-Linux/share/rtt-rlinux.desktop
TRAMPLIN=/usr/local/R-Linux/bin/tramplin

GKSUDO="`which gksudo 2> /dev/null`"
KDESUDO="`which kdesudo 2> /dev/null`"

MYUID=$(id -u)

if [ $MYUID = "0" ]; then

    export QTDIR=
    export QT_PLUGIN_PATH=
    export LD_LIBRARY_PATH=$RSLIB:$LD_LIBRARY_PATH
    $RSBIN $@

else

if [ -x "$GKSUDO" ]; then
    $GKSUDO --description $DESKFILE "$RSSTARTUP $@"
elif [ -x "$KDESUDO" ]; then
    $KDESUDO "$RSSTARTUP $@"
else

#if [ -a "/etc/fedora-release" ]; then
    $TRAMPLIN
#else
#    export LD_LIBRARY_PATH=$RSLIB:$LD_LIBRARY_PATH
#    $RSBIN $@    
#fi

fi

fi