-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrstudio-openrproj-param.sh
More file actions
31 lines (26 loc) · 902 Bytes
/
rstudio-openrproj-param.sh
File metadata and controls
31 lines (26 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# This init script is a variation of open-rproj, which clones
# a Git repository that contains a RStudio project (*.Rproj)
# and opens it in RStudio at startup.
# In addition, it takes as parameter the name of the git account and the git repository.
# Expected parameters :
# - Name of the github account
# - Name of the github repo
# Fetch the parameter
GIT_ACCOUNT=$1
GIT_REPO=$2
# Clone repository and give permissions to the onyxia user
git clone --depth 1 https://github.com/${GIT_ACCOUNT}/${GIT_REPO}.git
chown -R onyxia:users ${GIT_REPO}/
# Open the project
PROJECT_DIR=${WORKSPACE_DIR}/${GIT_REPO}/inputs
echo \
"
setHook('rstudio.sessionInit', function(newSession) {
if (newSession && identical(getwd(), '${WORKSPACE_DIR}'))
{
message('Activation du projet RStudio')
rstudioapi::openProject('${PROJECT_DIR}')
}
}, action = 'append')
" >> /home/onyxia/.Rprofile