Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#159 fixes for docklet_rstudio_addusers remove old shelling out code
to instead use ssh pkg
- Loading branch information
Showing
4 changed files
with
72 additions
and
73 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,26 @@ | ||
# get ps info as a data.frame ---------------------- | ||
## FIXME - don't want to basically duplicate other internal fxns, | ||
## but, the base fxn do_system() needs the change to intern=TRUE | ||
docklet_ps_data <- function(droplet, all = TRUE, ssh_user = "root") { | ||
tmp <- docklet_docker2(droplet, "ps", if (all) "-a", ssh_user = ssh_user) | ||
tmp <- paste0(gsub("\\s\\s+", ",", unname(sapply(tmp, strTrim))), collapse = "\n") | ||
tmp <- gsub("\"|'", "", tmp) | ||
df <- read.csv(text = paste0(tmp, "\n", collapse = ""), stringsAsFactors = FALSE) | ||
setNames(df, tolower(names(df))) | ||
} | ||
docklet_ps_data <- function(droplet, all = TRUE, ssh_user = "root", | ||
keyfile = NULL, ssh_passwd = NULL, verbose = FALSE) { | ||
|
||
docklet_docker2 <- function(droplet, cmd, args = NULL, docker_args = NULL, ssh_user = "root") { | ||
args <- paste(args, collapse = "") | ||
droplet_ssh2(droplet, user = ssh_user, paste(c("docker", docker_args, cmd, args), collapse = " ")) | ||
tmp <- docklet_docker2(droplet, "ps", if (all) "-a", ssh_user = ssh_user, | ||
keyfile = keyfile, ssh_passwd = ssh_passwd) | ||
tmp <- paste0(gsub("\\s\\s+", ",", unname(sapply(tmp, strTrim))), | ||
collapse = "\n") | ||
tmp <- gsub("\"|'", "", tmp) | ||
df <- read.csv(text = paste0(tmp, "\n", collapse = ""), | ||
stringsAsFactors = FALSE) | ||
stats::setNames(df, tolower(names(df))) | ||
} | ||
|
||
droplet_ssh2 <- function(droplet, ..., user = "root", verbose = FALSE) { | ||
droplet <- as.droplet(droplet) | ||
docklet_docker2 <- function(droplet, cmd, args = NULL, docker_args = NULL, | ||
ssh_user = "root", keyfile = NULL, ssh_passwd = NULL, verbose = FALSE) { | ||
|
||
lines <- paste(c(...), collapse = " \\\n&& ") | ||
if (lines == "") stop("Provide commands", call. = FALSE) | ||
cmd <- paste0( | ||
"ssh ", ssh_options(), | ||
" ", user, "@", droplet_ip(droplet), | ||
" ", shQuote(lines) | ||
args <- paste(args, collapse = "") | ||
droplet_ssh(droplet, paste(c("docker", docker_args, cmd, args), | ||
collapse = " "), | ||
user = ssh_user, keyfile = keyfile, ssh_passwd = ssh_passwd, | ||
verbose = verbose | ||
) | ||
do_system2(droplet, cmd, verbose = verbose) | ||
} | ||
|
||
do_system2 <- function(droplet, cmd, verbose = FALSE) { | ||
cli_tools() | ||
mssg(verbose, cmd) | ||
system(cmd, intern = TRUE) | ||
} | ||
|
||
# FIXME: remove me, hold-over from before using ssh pkg | ||
ssh_options <- function() { | ||
opts <- c( | ||
BatchMode = "yes", | ||
StrictHostKeyChecking = "no", | ||
UserKnownHostsFile = file.path(tempdir(), "hosts") | ||
) | ||
paste0("-o ", names(opts), "=", opts, collapse = " ") | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.