diff --git a/config.example.toml b/config.example.toml index 63dfe89c..f983b346 100644 --- a/config.example.toml +++ b/config.example.toml @@ -22,6 +22,9 @@ # Arguments to pass SSH when upgrading remote systems #ssh_arguments = "-o ConnectTimeout=2" +# Path to Topgrade executable on remote machines +#remote_topgrade_path = [".cargo/bin/topgrade"] + # Arguments to pass tmux when pulling Repositories #tmux_arguments = "-S /var/tmux.sock" diff --git a/src/config.rs b/src/config.rs index 282662ea..3ca481c6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -166,6 +166,7 @@ pub struct ConfigFile { disable: Option>, ignore_failures: Option>, remote_topgrades: Option>, + remote_topgrade_path: Option, ssh_arguments: Option, git_arguments: Option, tmux_arguments: Option, @@ -466,6 +467,11 @@ impl Config { &self.config_file.remote_topgrades } + /// Path to Topgrade executable used for all remote hosts + pub fn remote_topgrade_path(&self) -> &str { + self.config_file.remote_topgrade_path.as_deref().unwrap_or("topgrade") + } + /// Extra SSH arguments pub fn ssh_arguments(&self) -> &Option { &self.config_file.ssh_arguments diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 538aac58..cf7c532b 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -253,10 +253,12 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> { pub fn run_remote_topgrade(ctx: &ExecutionContext, hostname: &str) -> Result<()> { let ssh = utils::require("ssh")?; + let topgrade = ctx.config().remote_topgrade_path(); + if ctx.config().run_in_tmux() && !ctx.run_type().dry() { #[cfg(unix)] { - crate::tmux::run_remote_topgrade(hostname, &ssh, ctx.config().tmux_arguments())?; + crate::tmux::run_remote_topgrade(hostname, &ssh, topgrade, ctx.config().tmux_arguments())?; Err(SkipStep.into()) } @@ -270,7 +272,7 @@ pub fn run_remote_topgrade(ctx: &ExecutionContext, hostname: &str) -> Result<()> } let env = format!("TOPGRADE_PREFIX={}", hostname); - args.extend(&["env", &env, "topgrade"]); + args.extend(&["env", &env, topgrade]); if ctx.config().yes() { args.push("-y"); diff --git a/src/steps/tmux.rs b/src/steps/tmux.rs index e99e6e10..d47f06b9 100644 --- a/src/steps/tmux.rs +++ b/src/steps/tmux.rs @@ -104,11 +104,12 @@ pub fn run_in_tmux(args: &Option) -> ! { } } -pub fn run_remote_topgrade(hostname: &str, ssh: &Path, tmux_args: &Option) -> Result<()> { +pub fn run_remote_topgrade(hostname: &str, ssh: &Path, topgrade: &str, tmux_args: &Option) -> Result<()> { let command = format!( - "{ssh} -t {hostname} env TOPGRADE_PREFIX={hostname} TOPGRADE_KEEP_END=1 topgrade", + "{ssh} -t {hostname} env TOPGRADE_PREFIX={hostname} TOPGRADE_KEEP_END=1 {topgrade}", ssh = ssh.display(), - hostname = hostname + hostname = hostname, + topgrade = topgrade ); Tmux::new(tmux_args) .build()