aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-05-05 23:23:24 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-05-05 23:23:24 +0200
commit6cd7ea7372c8eb6bdc874b73012bbb22db8314ed (patch)
tree17a11761becf68edc6ec24e2ae4c32adb7df484a
parent3575721f996ce0f0070af6449fcc8d15a8afcb06 (diff)
initiate root switching later with a delay
-rw-r--r--src/main.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 7c4403e..7b4f5ab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -156,6 +156,9 @@ fn update_instance(args: Args) -> anyhow::Result<()> {
upload(&clt, base.join("/update/root")?, root_buf)?;
thread::sleep(Duration::from_secs(1));
+ println!("Switching to inactive root partition...");
+ post(&clt, base.join("/switch")?)?;
+
println!("Rebooting...");
reboot(clt, base);
@@ -180,6 +183,20 @@ fn upload(clt: &Client, dst: Url, buf: Vec<u8>) -> anyhow::Result<()> {
Ok(())
}
+fn post(clt: &Client, dst: Url) -> anyhow::Result<()> {
+ let resp = clt.post(dst).send()?;
+
+ match resp.error_for_status_ref() {
+ Ok(_) => {}
+ Err(e) => {
+ println!("Rustkrazy instance returned an error: {}", resp.text()?);
+ return Err(e.into());
+ }
+ }
+
+ Ok(())
+}
+
fn reboot(clt: Client, base: Url) {
thread::spawn(move || clt.post(base.join("/reboot").unwrap()).send().unwrap());
thread::sleep(Duration::from_secs(1));