diff --git a/README.md b/README.md index 06891fa5..bf452786 100644 --- a/README.md +++ b/README.md @@ -154,3 +154,8 @@ The configuration should be placed in the following paths depending by the opera * **macOS** - `~/Library/Preferences/topgrade.toml` * **Windows** - `%APPDATA%/topgrade.toml` * **Other Unix systems** - `~/.config/topgrade.toml` + +## Remote execution +You can specify a key called `remote_topgrades` in the configuration file. This key should contain a +list of hostnames that have topgrade installed on them. Topgrade will execute Topgrades on these +remote hosts. diff --git a/src/config.rs b/src/config.rs index d5c73d00..da7fc6d3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -69,6 +69,7 @@ pub struct ConfigFile { commands: Option, git_repos: Option>, disable: Option>, + remote_topgrades: Option>, } impl ConfigFile { @@ -198,4 +199,9 @@ impl Config { pub fn verbose(&self) -> bool { self.opt.verbose } + + /// List of remote hosts to run Topgrade in + pub fn remote_topgrades(&self) -> &Option> { + &self.config_file.remote_topgrades + } } diff --git a/src/main.rs b/src/main.rs index 846f3f28..247dd0ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ #![allow(clippy::cognitive_complexity)] - mod config; mod ctrlc; mod error; @@ -132,6 +131,17 @@ fn run() -> Result<(), Error> { #[cfg(windows)] execute(&mut report, "WSL", || windows::run_wsl_topgrade(run_type), true)?; + if let Some(topgrades) = config.remote_topgrades() { + for remote_topgrade in topgrades { + execute( + &mut report, + remote_topgrade, + || generic::run_remote_topgrade(run_type, remote_topgrade), + config.no_retry(), + )?; + } + } + #[cfg(target_os = "linux")] let distribution = linux::Distribution::detect(); diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 45a165d9..ff0b0dfc 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -136,3 +136,18 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<() Ok(()) } + +pub fn run_remote_topgrade(run_type: RunType, hostname: &str) -> Result<(), Error> { + let ssh = utils::require("ssh")?; + + run_type + .execute(&ssh) + .args(&[ + "-t", + hostname, + "env", + &format!("TOPGRADE_PREFIX={}", hostname), + "topgrade", + ]) + .check_run() +} diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index 33d629cc..89a2ffe5 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -89,8 +89,6 @@ pub fn run_wsl_topgrade(run_type: RunType) -> Result<(), Error> { .check_output() .map_err(|_| ErrorKind::SkipStep)?; - print_separator("WSL"); - run_type .execute(&wsl) .args(&["bash", "-c"])