refactoring rmote actions
This commit is contained in:
1 parent
8ca671c89b
commit
41968e63d2
2 files changed
+24
-23
No files matched your search
@@ -213,29 +213,6 @@ export def "skyg remote status all" [] {
|
||||
return ($results | select host status reboot_pending needs_build)
|
||||
}
|
||||
|
||||
# Poll SSH until the host reaches the desired reachability, or the timeout elapses.
|
||||
def wait-for-host [target: string, want_online: bool, timeout: int] {
|
||||
let deadline = (date now) + ($timeout * 1sec)
|
||||
while (date now) < $deadline {
|
||||
let online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
if $online == $want_online {
|
||||
return true
|
||||
}
|
||||
sleep 3sec
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
# Send a desktop notification if notify-send is available; never fail the caller.
|
||||
def notify [title: string, body: string] {
|
||||
try {
|
||||
^notify-send $title $body
|
||||
} catch { }
|
||||
}
|
||||
|
||||
# Reboot every remote host that is pending a reboot (booted-system != current-system).
|
||||
# Detects pending hosts, lists them, asks for confirmation, then reboots each one at a
|
||||
# time, waiting for it to come back online and sending a desktop notification when it does.
|
||||
|
||||
@@ -34,3 +34,27 @@ export def get-remote-boot-info [ host: string@remote_targets ] {
|
||||
{host: $host, status: "error", booted: "", current: "", reboot_pending: false, needs_build: false, local_toplevel: ""}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
# Poll SSH until the host reaches the desired reachability, or the timeout elapses.
|
||||
def wait-for-host [target: string, want_online: bool, timeout: int] {
|
||||
let deadline = (date now) + ($timeout * 1sec)
|
||||
while (date now) < $deadline {
|
||||
let online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
if $online == $want_online {
|
||||
return true
|
||||
}
|
||||
sleep 3sec
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
# Send a desktop notification if notify-send is available; never fail the caller.
|
||||
def notify [title: string, body: string] {
|
||||
try {
|
||||
^notify-send $title $body
|
||||
} catch { }
|
||||
}
|
||||
Reference in new issue
Block a user