class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://www.unbound.net/downloads/unbound-1.8.1.tar.gz" sha256 "c362b3b9c35d1b8c1918da02cdd5528d729206c14c767add89ae95acae363c5d" head "https://github.com/NLnetLabs/unbound.git" bottle do sha256 "30f001903153859ba2e755086320d037163d925965e77aefd5e9675e7c5eaa9d" => :mojave sha256 "59ccc8d8381ba9cc6eb89640e99f0378879d55b2c0aa07c029c0f64ecc80b65e" => :high_sierra sha256 "fcc55406d9a0c2ac95df9914629456510b73948bd62c6042fc22720ed3e4a85f" => :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} ] 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