@Test public void probe() throws Exception { try (SshSession ssh = SecureShells.sshConnect(uri).configFile(sshConfigFile).run()) { try (SshSftpSession sftp = SecureShells.sshSftp(ssh).run()) { Target target = Targets.probe(ssh, sftp); switch (host) { case "ubuntu14": assertThat(target.getInitType(), is(InitType.UPSTART)); assertThat(target, instanceOf(UnixTarget.class)); break; case "ubuntu16": case "debian8": case "centos7": assertThat(target.getInitType(), is(InitType.SYSTEMD)); assertThat(target, instanceOf(UnixTarget.class)); break; case "freebsd10": assertThat(target.getInitType(), is(InitType.UNKNOWN)); assertThat(target, instanceOf(UnixTarget.class)); break; case "openbsd58": assertThat(target.getInitType(), is(InitType.UNKNOWN)); assertThat(target, instanceOf(UnixTarget.class)); break; default: fail("Did you forget to add host " + host + "?"); break; } } } }
static public Target probe(SshSession ssh, SshSftpSession sftp) throws IOException { InitType initType = initType(ssh); Map<String,String> commands = which(ssh, Arrays.asList("doas", "sudo", "tar", "unzip")); String uname = uname(ssh); return new UnixTarget(ssh, sftp, uname, initType, "/tmp", commands); }
Targets { static public Target probe(SshSession ssh, SshSftpSession sftp) throws IOException { InitType initType = initType(ssh); Map<String,String> commands = which(ssh, Arrays.asList("doas", "sudo", "tar", "unzip")); String uname = uname(ssh); return new UnixTarget(ssh, sftp, uname, initType, "/tmp", commands); } }
Targets { static public Target probe(SshSession ssh, SshSftpSession sftp) throws IOException { InitType initType = initType(ssh); Map<String,String> commands = which(ssh, Arrays.asList("doas", "sudo", "tar", "unzip")); String uname = uname(ssh); return new UnixTarget(ssh, sftp, uname, initType, "/tmp", commands); }  }
Targets { static public Target probe(SshSession ssh, SshSftpSession sftp) throws IOException { InitType initType = initType(ssh); Map<String,String> commands = which(ssh, Arrays.asList("doas", "sudo", "tar", "unzip")); String uname = uname(ssh); return new UnixTarget(ssh, sftp, uname, initType, "/tmp", commands); }  static Target connect(String uri); static Target probe(SshSession ssh, SshSftpSession sftp); static SshSession sshConnect(String uri); }
Targets { static public Target probe(SshSession ssh, SshSftpSession sftp) throws IOException { InitType initType = initType(ssh); Map<String,String> commands = which(ssh, Arrays.asList("doas", "sudo", "tar", "unzip")); String uname = uname(ssh); return new UnixTarget(ssh, sftp, uname, initType, "/tmp", commands); }  static Target connect(String uri); static Target probe(SshSession ssh, SshSftpSession sftp); static SshSession sshConnect(String uri);  }