Fix homebrew formula template

This commit is contained in:
David Newhall II 2019-06-13 02:25:41 -07:00
parent 8cd80fcf83
commit 094705d76c
1 changed files with 35 additions and 31 deletions

View File

@ -22,40 +22,44 @@ class UnifiPoller < Formula
cd bin_path do
system "dep", "ensure"
system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}"
system "mkdir", "-p", "#{var}/log/unifi-poller"
end
end
def caveats
s = <<-EOS
This application will not work until the config file has authentication
information for a Unifi Controller and an Influx Database. Edit the config
file at #{etc}/unifi-poller/up.conf then start the application with
brew services start unifi-poller ~ log file: #{var}/log/unifi-poller/log
The manual explains the config file options: man unifi-poller
EOS
end
plist_options :startup => true
def plist; <<-EOS
<?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>ProgramArguments</key>
<array>
<string>#{bin}/unifi-poller</string>
<string>-c</string>
<string>#{etc}/unifi-poller/up.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>#{var}/log/unifi-poller/log</string>
<key>StandardOutPath</key>
<string>#{var}/log/unifi-poller/log</string>
<key>UserName</key>
<string>nobody</string>
<key>GroupName</key>
<string>nobody</string>
</dict>
</plist>
EOS
end
def plist; <<-EOS
<?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>ProgramArguments</key>
<array>
<string>#{bin}/unifi-poller</string>
<string>-c</string>
<string>#{etc}/unifi-poller/up.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>#{var}/log/unifi-poller/log</string>
<key>StandardOutPath</key>
<string>#{var}/log/unifi-poller/log</string>
</dict>
</plist>
EOS
end
test do
assert_match "unifi-poller v#{version}", shell_output("#{bin}/unifi-poller -v 2>&1", 2)