unbound: fix post_install. (#12093)

Ensure that we check the configuration file exists and simplify by using
the `Pathname`.
This commit is contained in:
Mike McQuaid 2017-04-05 10:06:16 +01:00 committed by GitHub
parent f8195fcf7f
commit 2e91cc6cd1

View file

@ -43,9 +43,11 @@ class Unbound < Formula
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
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