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" revision 1 head "https://github.com/NLnetLabs/unbound.git" bottle do sha256 "9d78b7be27bbb26d4ed590b612d373a227ae0dfa092df9234ec26ab46341be32" => :catalina sha256 "8dc0d4c69e2b1a5b9fa302134dcdb5cfe8773684743dbf3054dd9ce937cc0c6a" => :mojave sha256 "c5be68c9d47547bc0ec606a63ea991ebe9b272d7b989808cf13c76366bb10bf5" => :high_sierra sha256 "e29698f9bb6e890ca18dbcd3d5fa320f71376433335fe7191c32d65c6f77607f" => :sierra end depends_on "libevent" depends_on "openssl@1.1" def install args = %W[ --prefix=#{prefix} --sysconfdir=#{etc} --with-libevent=#{Formula["libevent"].opt_prefix} --with-ssl=#{Formula["openssl@1.1"].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