Run remote Topgrades in Tmux
This commit is contained in:
@@ -37,7 +37,6 @@ impl RunType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "self-update")]
|
|
||||||
/// Tells whether we're performing a dry run.
|
/// Tells whether we're performing a dry run.
|
||||||
pub fn dry(self) -> bool {
|
pub fn dry(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ fn run() -> Result<(), Error> {
|
|||||||
execute(
|
execute(
|
||||||
&mut report,
|
&mut report,
|
||||||
remote_topgrade,
|
remote_topgrade,
|
||||||
|| generic::run_remote_topgrade(run_type, remote_topgrade),
|
|| generic::run_remote_topgrade(run_type, remote_topgrade, config.run_in_tmux()),
|
||||||
config.no_retry(),
|
config.no_retry(),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,17 +137,27 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<()
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_remote_topgrade(run_type: RunType, hostname: &str) -> Result<(), Error> {
|
pub fn run_remote_topgrade(run_type: RunType, hostname: &str, run_in_tmux: bool) -> Result<(), Error> {
|
||||||
let ssh = utils::require("ssh")?;
|
let ssh = utils::require("ssh")?;
|
||||||
|
|
||||||
run_type
|
if run_in_tmux && !run_type.dry() {
|
||||||
.execute(&ssh)
|
#[cfg(unix)]
|
||||||
.args(&[
|
{
|
||||||
"-t",
|
crate::tmux::run_remote_topgrade(hostname, &ssh)?;
|
||||||
hostname,
|
Err(ErrorKind::SkipStep)?
|
||||||
"env",
|
}
|
||||||
&format!("TOPGRADE_PREFIX={}", hostname),
|
|
||||||
"topgrade",
|
unreachable!("Tmux execution is only implemented in Unix");
|
||||||
])
|
} else {
|
||||||
.check_run()
|
run_type
|
||||||
|
.execute(&ssh)
|
||||||
|
.args(&[
|
||||||
|
"-t",
|
||||||
|
hostname,
|
||||||
|
"env",
|
||||||
|
&format!("TOPGRADE_PREFIX={}", hostname),
|
||||||
|
"topgrade",
|
||||||
|
])
|
||||||
|
.check_run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,3 +82,19 @@ pub fn run_in_tmux() -> ! {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_remote_topgrade(hostname: &str, ssh: &Path) -> Result<(), Error> {
|
||||||
|
let command = format!(
|
||||||
|
"{ssh} -t {hostname} env TOPGRADE_PREFIX={hostname} topgrade",
|
||||||
|
ssh = ssh.display(),
|
||||||
|
hostname = hostname
|
||||||
|
);
|
||||||
|
Command::new(which("tmux").unwrap())
|
||||||
|
.args(&["new-window", "-a", "-t", "topgrade:1", "-n", hostname, &command])
|
||||||
|
.env_remove("TMUX")
|
||||||
|
.spawn()
|
||||||
|
.context(ErrorKind::ProcessExecution)?
|
||||||
|
.wait()
|
||||||
|
.context(ErrorKind::ProcessExecution)?
|
||||||
|
.check()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user