Пример #1
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;
  }
Пример #2
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;
  }
Пример #3
0
  private LinuxNamed() throws KuraException {
    if (OS_VERSION.equals(
            KuraConstants.Mini_Gateway.getImageName()
                + "_"
                + KuraConstants.Mini_Gateway.getImageVersion())
        || OS_VERSION.equals(KuraConstants.Raspberry_Pi.getImageName())
        || OS_VERSION.equals(KuraConstants.BeagleBone.getImageName())) {
      s_persistentConfigFileName = "/etc/bind/named.conf";
      s_procString = "/usr/sbin/named";
      if (TARGET_NAME.equals(KuraConstants.ReliaGATE_15_10.getTargetName())) {
        s_logFileName = "/var/named.log";
        s_rfc1912ZonesFilename = "/etc/bind/named.rfc1912.zones";
      } else {
        s_logFileName = "/var/log/named.log";
        s_rfc1912ZonesFilename = "/etc/named.rfc1912.zones";
      }
    } else if (OS_VERSION.equals(
        KuraConstants.ReliaGATE_50_21_Ubuntu.getImageName()
            + "_"
            + KuraConstants.ReliaGATE_50_21_Ubuntu.getImageVersion())) {
      s_persistentConfigFileName = "/etc/bind/named.conf";
      s_procString = "/usr/sbin/named";
      s_logFileName = "/var/log/named.log";
      s_rfc1912ZonesFilename = "/etc/bind/named.rfc1912.zones";
    } else {
      s_persistentConfigFileName = "/etc/named.conf";
      s_procString = "named -u named -t";
      s_logFileName = "/var/log/named.log";
      s_rfc1912ZonesFilename = "/etc/named.rfc1912.zones";
    }

    // initialize the configuration
    init();

    if (m_dnsServerConfigIP4 == null) {
      Set<IP4Address> forwarders = new HashSet<IP4Address>();
      HashSet<NetworkPair<IP4Address>> allowedNetworks = new HashSet<NetworkPair<IP4Address>>();
      m_dnsServerConfigIP4 = new DnsServerConfigIP4(forwarders, allowedNetworks);
    }
  }