Skip to content

Commit

Permalink
Run as bash
Browse files Browse the repository at this point in the history
  • Loading branch information
namse committed Dec 3, 2023
1 parent 2519dda commit 763a026
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions oioi/agent/src/command.rs → oioi/agent/src/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ use anyhow::Result;

pub(crate) async fn run(command: impl AsRef<str>) -> Result<Vec<u8>> {
let command = command.as_ref();
let mut args = command.split_whitespace();
let program = args.next().unwrap();
let args = args.collect::<Vec<_>>();
let args = command.split_whitespace();

let output = tokio::process::Command::new(program)
.args(&args)
let output = tokio::process::Command::new("bash")
.arg("-c")
.args(args)
.output()
.await
.map_err(|e| anyhow::anyhow!("Failed to run {command}: {e}"))?;
Expand Down
2 changes: 1 addition & 1 deletion oioi/agent/src/docker_cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;

pub(crate) async fn pull_image(image: &str) -> Result<()> {
crate::command::run(format!("docker pull {image}")).await?;
crate::bash::run(format!("docker pull {image}")).await?;
Ok(())
}
4 changes: 2 additions & 2 deletions oioi/agent/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod command;
mod bash;
mod container_config;
mod docker_cli;
mod docker_engine;
Expand Down Expand Up @@ -41,7 +41,7 @@ async fn real_main() -> Result<()> {
last_updated_at = Some(updated_at);

if !docker_login_script.is_empty() {
command::run(docker_login_script.as_str()).await?;
bash::run(docker_login_script.as_str()).await?;
println!("Docker Logged in.");
}

Expand Down

0 comments on commit 763a026

Please sign in to comment.