homebrew-core/Formula/unbound.rb

73 lines
2.3 KiB
Ruby

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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-/Apple/DTD PLIST 1.0/EN" "http:/www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>#{opt_sbin}/unbound</string>
<string>-d</string>
<string>-c</string>
<string>#{etc}/unbound/unbound.conf</string>
</array>
<key>UserName</key>
<string>root</string>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
EOS
end
test do
system sbin/"unbound-control-setup", "-d", testpath
end
end