예제 #1
0
  public boolean disable() throws KuraException {
    try {
      int result = -1;
      // If so, stop it.
      if (OS_VERSION.equals(
          KuraConstants.Mini_Gateway.getImageName()
              + "_"
              + KuraConstants.Mini_Gateway.getImageVersion())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind stop");
      } else if (OS_VERSION.equals(KuraConstants.Raspberry_Pi.getImageName())
          || OS_VERSION.equals(KuraConstants.BeagleBone.getImageName())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind9 stop");
      } else if (OS_VERSION.equals(
          KuraConstants.Intel_Edison.getImageName()
              + "_"
              + KuraConstants.Intel_Edison.getImageVersion()
              + "_"
              + KuraConstants.Intel_Edison.getTargetName())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind stop");
      } else if (OS_VERSION.equals(
          KuraConstants.ReliaGATE_50_21_Ubuntu.getImageName()
              + "_"
              + KuraConstants.ReliaGATE_50_21_Ubuntu.getImageVersion())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind9 stop");
      } else {
        result = LinuxProcessUtil.start("/etc/init.d/named stop");
      }

      if (result == 0) {
        s_logger.debug("DNS server stopped.");
        s_logger.trace(m_dnsServerConfigIP4.toString());
        return true;
      } else {
        s_logger.debug("tried to kill DNS server for interface but it is not running");
      }
    } catch (Exception e) {
      throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    }

    return true;
  }
예제 #2
0
  public boolean restart() throws KuraException {
    try {
      if (LinuxProcessUtil.start("/etc/init.d/named restart") == 0) {
        s_logger.debug("DNS server restarted.");
      } else {
        throw new KuraException(KuraErrorCode.INTERNAL_ERROR, "error restarting");
      }
    } catch (Exception e) {
      throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    }

    return true;
  }
예제 #3
0
  public boolean enable() throws KuraException {
    // write config happened during 'set config' step

    try {
      // Check if named is running
      int pid = LinuxProcessUtil.getPid(s_procString);
      if (pid > -1) {
        // If so, disable it
        s_logger.error("DNS server is already running, bringing it down...");
        disable();
      }
      // Start named
      int result = -1;
      if (OS_VERSION.equals(
          KuraConstants.Mini_Gateway.getImageName()
              + "_"
              + KuraConstants.Mini_Gateway.getImageVersion())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind start");
      } else if (OS_VERSION.equals(
          KuraConstants.ReliaGATE_10_05.getImageName()
              + "_"
              + KuraConstants.ReliaGATE_10_05.getImageVersion())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind start");
      } else if (OS_VERSION.equals(KuraConstants.Raspberry_Pi.getImageName())
          || OS_VERSION.equals(KuraConstants.BeagleBone.getImageName())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind9 start");
      } else if (OS_VERSION.equals(
          KuraConstants.Intel_Edison.getImageName()
              + "_"
              + KuraConstants.Intel_Edison.getImageVersion()
              + "_"
              + KuraConstants.Intel_Edison.getTargetName())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind start");
      } else if (OS_VERSION.equals(
          KuraConstants.ReliaGATE_50_21_Ubuntu.getImageName()
              + "_"
              + KuraConstants.ReliaGATE_50_21_Ubuntu.getImageVersion())) {
        result = LinuxProcessUtil.start("/etc/init.d/bind9 start");
      } else {
        s_logger.info("Linux named enable fallback");
        result = LinuxProcessUtil.start("/etc/init.d/named start");
      }
      if (result == 0) {
        s_logger.debug("DNS server started.");
        s_logger.trace(m_dnsServerConfigIP4.toString());
        return true;
      }
    } catch (Exception e) {
      throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    }

    return false;
  }