Last active
August 29, 2015 14:21
-
-
Save simecek/d3600620314ca5421846 to your computer and use it in GitHub Desktop.
For each participant, start RStudio with DOQTL preinstalled and send the email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(analogsea) # to access Digital Oceal | |
library(sendmailR) # to send emails | |
library(parallel) | |
library(doParallel)# foreach parallelization | |
# Sys.setenv(DO_PAT = "*****") | |
# Set list of participants' emails | |
# email_list <- c("first_email@gmail.com", "second_email@gmail.com", ...) | |
# if you want to run it in parallel, create a cluster | |
cl <- makeCluster(5) | |
registerDoParallel(cl) | |
droplet_list <- foreach(email=email_list, .packages="analogsea") %dopar% { | |
# start machine | |
d <- docklet_create(size = getOption("do_size", "512mb")) | |
d | |
} | |
foreach(i = 1:length(email_list), .packages="analogsea") %dopar% { | |
# select droplet | |
d = droplet_list[[i]] | |
# pull docker image | |
d %>% docklet_pull("rocker/hadleyverse") | |
d %>% docklet_pull("simecek/doqtl-docker") | |
# run it | |
d %>% docklet_run("-d", " -p 8787:8787", " -e USER=doqtl", " -e PASSWORD=supersecret ", "simecek/doqtl-docker") %>% docklet_images() | |
} | |
# prepare email to all participants | |
from <- "<your_email@your_company.com>" | |
subject <- "R/DOQTL course login credentials" | |
bodymasked <- paste0("To access your RStudio session, please, go to\n\n", | |
"http://XXXXX:8787\n\n", | |
"username: doqtl\n", | |
"password: verysecret\n\n", | |
"This email was sent by a robot. ", | |
"In case of any problem, do not reply to it and ask me directly.\n\n", | |
"Petr Simecek") | |
for (i in 1:length(email_list)) { | |
# select droplet and email | |
d <- droplet_list[[i]] | |
email <- email_list[i] | |
# send email | |
to <- paste0("<",email,">") | |
body <- sub("XXXXX", d$network[[1]][[1]][[1]], bodymasked) | |
sendmail(from, to, subject, body, | |
control=list(smtpServer="ASPMX.L.GOOGLE.COM")) | |
} | |
## stop everything | |
# for (d in droplet_list) droplet_delete(d) | |
# stopCluster(cl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment