From 1a91e9477c54876f55a5b01db6c627b9451eac34 Mon Sep 17 00:00:00 2001 From: unifi-poller-bot Date: Wed, 12 Jun 2019 18:22:37 -0700 Subject: [PATCH] Add ETC folder and plist fix github setup --- integrations/promunifi/.travis.yml | 13 ++++--- integrations/promunifi/Makefile | 9 ++--- .../promunifi/templates/unifi-poller.rb.tmpl | 34 ++++++++++++++++++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/integrations/promunifi/.travis.yml b/integrations/promunifi/.travis.yml index 12225e54..45dcc358 100644 --- a/integrations/promunifi/.travis.yml +++ b/integrations/promunifi/.travis.yml @@ -23,10 +23,15 @@ script: # get deploy key for golift/homebrew-repo. after_success: - | - openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in github_deploy_key.enc -out github_deploy_key -d - $(npm bin)/set-up-ssh --key "$encrypted_9f3147001275_key" \ - --iv "$encrypted_9f3147001275_iv" \ - --path-encrypted-key ".travis/github_deploy_key.enc" + declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" + echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d + chmod 600 "$SSH_FILE" \ + && printf "%s\n" \ + "Host github.com" \ + " IdentityFile $SSH_FILE" \ + " StrictHostKeyChecking no" \ + " LogLevel ERROR" >> ~/.ssh/config deploy: - provider: releases api_key: diff --git a/integrations/promunifi/Makefile b/integrations/promunifi/Makefile index eb7f723f..613e92e0 100644 --- a/integrations/promunifi/Makefile +++ b/integrations/promunifi/Makefile @@ -179,13 +179,14 @@ install: man readme $(BINARY) @echo - Otherwise, build and install a package: make rpm -or- make deb @echo See the Package Install wiki for more info: $(URL)/wiki/Package-Install @[ "$$(uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false) - @[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local" && false) + @[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) + @[ "$(ETC)" != "" ] || (echo "Unable to continue, ETC not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) # Copying the binary, config file, unit file, and man page into the env. - /usr/bin/install -m 0755 -d $(PREFIX)/bin $(PREFIX)/share/man/man1 $(PREFIX)/etc/$(BINARY) $(PREFIX)/share/doc/$(BINARY)/examples + /usr/bin/install -m 0755 -d $(PREFIX)/bin $(PREFIX)/share/man/man1 $(ETC)/$(BINARY) $(PREFIX)/share/doc/$(BINARY)/examples /usr/bin/install -m 0755 -cp $(BINARY) $(PREFIX)/bin/$(BINARY) /usr/bin/install -m 0644 -cp $(BINARY).1.gz $(PREFIX)/share/man/man1 - /usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/ - [ -f $(PREFIX)/etc/$(BINARY)/up.conf ] || /usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/up.conf + /usr/bin/install -m 0644 -cp examples/up.conf.example $(ETC)/$(BINARY)/ + [ -f $(ETC)/$(BINARY)/up.conf ] || /usr/bin/install -m 0644 -cp examples/up.conf.example $(ETC)/$(BINARY)/up.conf /usr/bin/install -m 0644 -cp *.html examples/{*dash.json,up.conf.example} $(PREFIX)/share/doc/$(BINARY)/ # These go to their own folder so the img src in the html pages continue to work. /usr/bin/install -m 0644 -cp examples/*.png $(PREFIX)/share/doc/$(BINARY)/examples diff --git a/integrations/promunifi/templates/unifi-poller.rb.tmpl b/integrations/promunifi/templates/unifi-poller.rb.tmpl index c086d8c8..acfb8a67 100644 --- a/integrations/promunifi/templates/unifi-poller.rb.tmpl +++ b/integrations/promunifi/templates/unifi-poller.rb.tmpl @@ -21,10 +21,42 @@ class UnifiPoller < Formula bin_path.install Dir["*"] cd bin_path do system "dep", "ensure" - system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}" + system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}" end end + plist_options :startup => true + + def plist; <<-EOS.undent + + + + + Label + #{plist_name} + ProgramArguments + + #{bin}/unifi-poller + -c + #{etc}/unifi-poller/up.conf + + RunAtLoad + + KeepAlive + + StandardErrorPath + #{var}/log/unifi-poller/log + StandardOutPath + #{var}/log/unifi-poller/log + UserName + nobody + GroupName + nobody + + + EOS + end + test do assert_match "unifi-poller v#{version}", shell_output("#{bin}/unifi-poller -v 2>&1", 2) end