class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://unbound.net/downloads/unbound-1.5.9.tar.gz" sha256 "01328cfac99ab5b8c47115151896a244979e442e284eb962c0ea84b7782b6990" bottle do cellar :any sha256 "e76d88065a95409c1e0bb322334daf3dffc0a1d2dbe86f5b6c0349b5d26ab8d0" => :sierra sha256 "0be2dedc49de0ba2afa1ac12542e20155625eb6bbad784065dd7c01da0550863" => :el_capitan sha256 "0b641ab092cbd5aa02b33054f6f3fa27c76787bd17d7c4f1cd9dc7d798725a60" => :yosemite sha256 "bdf1c759a2767507889a253069dc2cb9ef9c3bb558e08113665b59a6bcbbc204" => :mavericks end depends_on "openssl" depends_on "libevent" 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" unless MacOS::CLT.installed? system "./configure", *args inreplace "doc/example.conf", 'username: "unbound"', 'username: "@@HOMEBREW-UNBOUND-USER@@"' system "make", "install" end def post_install if File.read(etc/"unbound/unbound.conf").include?('username: "@@HOMEBREW-UNBOUND-USER@@"') inreplace etc/"unbound/unbound.conf", 'username: "@@HOMEBREW-UNBOUND-USER@@"', "username: \"#{ENV["USER"]}\"" end end plist_options :startup => true def plist; <<-EOS.undent 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