1
0

Wait until ssh is available

This commit is contained in:
2023-02-16 06:27:17 +00:00
parent f97cb3f10a
commit 24b6749504
3 changed files with 24 additions and 0 deletions

View File

@ -307,6 +307,20 @@ func (q *System) Stop() {
}
}
func (q System) WaitForSSH(timeout time.Duration) error {
for start := time.Now(); time.Since(start) < timeout; {
client, err := q.ssh("root")
if err != nil {
time.Sleep(time.Second / 10)
continue
}
client.Close()
return nil
}
return errors.New("no ssh (timeout)")
}
func (q System) ssh(user string) (client *ssh.Client, err error) {
cfg := &ssh.ClientConfig{
User: user,