nagios 4.2.4

* Fix user in config files.
* Add extremely simple test.
* Style nits.
This commit is contained in:
Dominyk Tiller 2017-01-02 22:01:07 +00:00 committed by Tomasz Pajor
parent 6e49f53dc0
commit 8ee48b58ff

View file

@ -1,8 +1,8 @@
class Nagios < Formula
desc "Network monitoring and management system"
homepage "https://www.nagios.org/"
url "https://downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz"
sha256 "d400190c771eb90e0ba16351f6358fa7e22e42a7be986f2066db63518a14397b"
url "https://downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.2.4/nagios-4.2.4.tar.gz"
sha256 "b0055c475683ce50d77b1536ff0cec9abf89139adecf771601fa021ef9a20b70"
bottle do
cellar :any
@ -17,27 +17,27 @@ class Nagios < Formula
depends_on "libpng"
def nagios_sbin
prefix+"cgi-bin"
prefix/"cgi-bin"
end
def nagios_etc
etc+"nagios"
etc/"nagios"
end
def nagios_var
var+"lib/nagios"
var/"lib/nagios"
end
def htdocs
share+"nagios/htdocs"
pkgshare/"htdocs"
end
def user
`id -un`.chomp
Utils.popen_read("id -un").chomp
end
def group
`id -gn`.chomp
Utils.popen_read("id -gn").chomp
end
def install
@ -60,36 +60,17 @@ class Nagios < Formula
system "make", "install"
# Install config
system "make install-config"
system "make install-webconf"
mkdir HOMEBREW_PREFIX+"var/lib/nagios/rw" unless File.exist? HOMEBREW_PREFIX+"var/lib/nagios/rw"
system "make", "install-config"
system "make", "install-webconf"
end
plist_options :startup => true, :manual => "nagios #{HOMEBREW_PREFIX}/etc/nagios/nagios.cfg"
def postinstall
(var/"lib/nagios/rw").mkpath
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>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/nagios</string>
<string>#{nagios_etc}/nagios.cfg</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
EOS
config = etc/"nagios/nagios.cfg"
return unless File.exist?(config)
return if File.read(config).include?(ENV["USER"])
inreplace config, "brew", ENV["USER"]
end
def caveats; <<-EOS.undent
@ -123,4 +104,35 @@ class Nagios < Formula
EOS
end
plist_options :startup => true, :manual => "nagios #{HOMEBREW_PREFIX}/etc/nagios/nagios.cfg"
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>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/nagios</string>
<string>#{nagios_etc}/nagios.cfg</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/nagios --version")
end
end