Ejemplo n.º 1
0
 public boolean isEnabled() throws KuraException {
   try {
     // Check if named is running
     int pid = LinuxProcessUtil.getPid(s_procString);
     return (pid > -1);
   } catch (Exception e) {
     throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
   }
 }
Ejemplo n.º 2
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;
  }