Example #1
0
  @Override
  public Object execute() throws Exception {

    if (force) {
      if (reboot) {
        systemService.reboot(time, determineSwipeType());
      } else {
        systemService.halt(time);
      }
      return null;
    }

    for (; ; ) {
      String karafName = System.getProperty("karaf.name");
      String msg;
      if (reboot) {
        msg = String.format("Confirm: reboot instance %s (yes/no): ", karafName);
      } else {
        msg = String.format("Confirm: halt instance %s (yes/no): ", karafName);
      }
      String str = null;
      try {
        str = session.readLine(msg, null);
      } catch (UnsupportedOperationException e) {
        // this is a remote client with shutdown argument so here isn't a interactive way
        // so return a prompt message instead of NPE
        System.out.println(
            "please use \"shutdown -f\" or \"shutdown --force\" to shutdown instance: "
                + karafName);
        return null;
      }
      if (str.equalsIgnoreCase("yes")) {
        if (reboot) {
          systemService.reboot(time, determineSwipeType());
        } else {
          systemService.halt(time);
        }
      }
      return null;
    }
  }
Example #2
0
 public void halt(String time) throws Exception {
   systemService.halt(time);
 }
Example #3
0
 public void halt() throws Exception {
   systemService.halt();
 }