class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://nlnetlabs.nl/downloads/unbound/unbound-1.8.3.tar.gz" sha256 "2b692b8311edfad41e7d0380aac34576060d4176add81dc5db419c79b2a4cecc" head "https://github.com/NLnetLabs/unbound.git" bottle do sha256 "e21cbf4085644f6fc3b226a3ef03de317834624a45400054b17c7a18799d721d" => :mojave sha256 "72bd8b7806b868eb355effd760632b7d81b21c31b8b727b4a37b054235aa94ae" => :high_sierra sha256 "0af6432dd3cab953a253da55ec32e49b05141d27b3c3fedcb522e84d74ca8f9b" => :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