class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://nlnetlabs.nl/downloads/unbound/unbound-1.9.3.tar.gz" sha256 "1b55dd9170e4bfb327fb644de7bbf7f0541701149dff3adf1b63ffa785f16dfa" head "https://github.com/NLnetLabs/unbound.git" bottle do sha256 "e4a175d3455d6dd751ba7d204b56940d5656b4b046bbeaaf244980a64aebc532" => :mojave sha256 "26f015c9843fdf02463b5e3d1abd0d0db719d35438c4c2657861addac87d76e5" => :high_sierra sha256 "453370364375c32863dbe33cf71dfc4e6868197beb8870463f9ede676e9eef28" => :sierra end depends_on "libevent" depends_on "openssl" def install args = %W[ --prefix=#{prefix} --sysconfdir=#{etc} --with-libevent=#{Formula["libevent"].opt_prefix} --with-ssl=#{Formula["openssl"].opt_prefix} --enable-event-api ] args << "--with-libexpat=#{MacOS.sdk_path}/usr" if MacOS.sdk_path_if_needed system "./configure", *args inreplace "doc/example.conf", 'username: "unbound"', 'username: "@@HOMEBREW-UNBOUND-USER@@"' system "make" system "make", "test" system "make", "install" end def post_install conf = etc/"unbound/unbound.conf" return unless conf.exist? return unless conf.read.include?('username: "@@HOMEBREW-UNBOUND-USER@@"') inreplace conf, 'username: "@@HOMEBREW-UNBOUND-USER@@"', "username: \"#{ENV["USER"]}\"" end plist_options :startup => true def plist; <<~EOS Label #{plist_name} KeepAlive RunAtLoad ProgramArguments #{opt_sbin}/unbound -d -c #{etc}/unbound/unbound.conf UserName root StandardErrorPath /dev/null StandardOutPath /dev/null EOS end test do system sbin/"unbound-control-setup", "-d", testpath end end